def test_building_footprint_courtyard(): """Test the building footprint method with courtyard geometry.""" pts_1 = (Point3D(0, 0, 3), Point3D(0, 5, 3), Point3D(15, 5, 3), Point3D(15, 0, 3)) pts_2 = (Point3D(15, 0, 3), Point3D(15, 15, 3), Point3D(20, 15, 3), Point3D(20, 0, 3)) pts_3 = (Point3D(0, 5, 3), Point3D(0, 20, 3), Point3D(5, 20, 3), Point3D(5, 5, 3)) pts_4 = (Point3D(5, 15, 3), Point3D(5, 20, 3), Point3D(20, 20, 3), Point3D(20, 15, 3)) room2d_1 = Room2D('Office1', Face3D(pts_1), 3) room2d_2 = Room2D('Office2', Face3D(pts_2), 3) room2d_3 = Room2D('Office3', Face3D(pts_3), 3) room2d_4 = Room2D('Office4', Face3D(pts_4), 3) int_rms = Room2D.intersect_adjacency( [room2d_1, room2d_2, room2d_3, room2d_4], 0.01) story = Story('Office_Floor', int_rms) story.rotate_xy(5, Point3D(0, 0, 0)) story.solve_room_2d_adjacency(0.01) story.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story.multiplier = 4 building = Building('Office_Building', [story]) footprint = building.footprint(0.01) assert len(footprint) == 1 assert isinstance(footprint[0], Face3D) assert len(footprint[0].boundary) == 8 assert len(footprint[0].holes) == 1 assert len(footprint[0].holes[0]) == 4
def test_to_geojson(): """Test the Model to_geojson method.""" pts_1 = (Point3D(50, 50, 3), Point3D(60, 50, 3), Point3D(60, 60, 3), Point3D(50, 60, 3)) pts_2 = (Point3D(60, 50, 3), Point3D(70, 50, 3), Point3D(70, 60, 3), Point3D(60, 60, 3)) pts_3 = (Point3D(50, 70, 3), Point3D(70, 70, 3), Point3D(70, 80, 3), Point3D(50, 80, 3)) room2d_1 = Room2D('Residence1', Face3D(pts_1), 3) room2d_2 = Room2D('Residence2', Face3D(pts_2), 3) room2d_3 = Room2D('Retail', Face3D(pts_3), 3) story_big = Story('RetailFloor', [room2d_3]) story = Story('ResidenceFloor', [room2d_1, room2d_2]) story.solve_room_2d_adjacency(0.01) story.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story.multiplier = 3 building = Building('ResidenceBuilding', [story]) story_big.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story_big.multiplier = 1 building_big = Building('RetailBuildingBig', [story_big]) pts_1 = (Point3D(0, 0, 3), Point3D(0, 5, 3), Point3D(15, 5, 3), Point3D(15, 0, 3)) pts_2 = (Point3D(15, 0, 3), Point3D(15, 15, 3), Point3D(20, 15, 3), Point3D(20, 0, 3)) pts_3 = (Point3D(0, 5, 3), Point3D(0, 20, 3), Point3D(5, 20, 3), Point3D(5, 5, 3)) pts_4 = (Point3D(5, 15, 3), Point3D(5, 20, 3), Point3D(20, 20, 3), Point3D(20, 15, 3)) pts_5 = (Point3D(-5, -5, 3), Point3D(-10, -5, 3), Point3D(-10, -10, 3), Point3D(-5, -10, 3)) room2d_1 = Room2D('Office1', Face3D(pts_1), 3) room2d_2 = Room2D('Office2', Face3D(pts_2), 3) room2d_3 = Room2D('Office3', Face3D(pts_3), 3) room2d_4 = Room2D('Office4', Face3D(pts_4), 3) room2d_5 = Room2D('Office5', Face3D(pts_5), 3) int_rms = Room2D.intersect_adjacency( [room2d_1, room2d_2, room2d_3, room2d_4, room2d_5], 0.01) story = Story('OfficeFloor', int_rms) story.rotate_xy(5, Point3D(0, 0, 0)) story.solve_room_2d_adjacency(0.01) story.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story.multiplier = 5 building_mult = Building('OfficeBuilding', [story]) tree_canopy_geo1 = Face3D.from_regular_polygon(6, 6, Plane(o=Point3D(5, -10, 6))) tree_canopy_geo2 = Face3D.from_regular_polygon(6, 2, Plane(o=Point3D(-5, -10, 3))) tree_canopy = ContextShade('TreeCanopy', [tree_canopy_geo1, tree_canopy_geo2]) model = Model('TestGeoJSON', [building, building_big, building_mult], [tree_canopy]) location = Location('Boston', 'MA', 'USA', 42.366151, -71.019357) geojson_folder = './tests/geojson/' model.to_geojson(location, folder=geojson_folder) geo_fp = os.path.join( geojson_folder, model.identifier, '{}.geojson'.format(model.identifier)) assert os.path.isfile(geo_fp) nukedir(os.path.join(geojson_folder, model.identifier), True)
def test_to_urbanopt(): """Test the Model.to.urbanopt method.""" pts_1 = (Point3D(50, 50, 3), Point3D(60, 50, 3), Point3D(60, 60, 3), Point3D(50, 60, 3)) pts_2 = (Point3D(60, 50, 3), Point3D(70, 50, 3), Point3D(70, 60, 3), Point3D(60, 60, 3)) pts_3 = (Point3D(50, 70, 3), Point3D(70, 70, 3), Point3D(70, 80, 3), Point3D(50, 80, 3)) room2d_1 = Room2D('Residence1', Face3D(pts_1), 3) room2d_2 = Room2D('Residence2', Face3D(pts_2), 3) room2d_3 = Room2D('Retail', Face3D(pts_3), 3) story_big = Story('RetailFloor', [room2d_3]) story = Story('ResidenceFloor', [room2d_1, room2d_2]) story.solve_room_2d_adjacency(0.01) story.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story.multiplier = 3 building = Building('ResidenceBuilding', [story]) story_big.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story_big.multiplier = 1 building_big = Building('RetailBuildingBig', [story_big]) pts_1 = (Point3D(0, 0, 3), Point3D(0, 5, 3), Point3D(15, 5, 3), Point3D(15, 0, 3)) pts_2 = (Point3D(15, 0, 3), Point3D(15, 15, 3), Point3D(20, 15, 3), Point3D(20, 0, 3)) pts_3 = (Point3D(0, 5, 3), Point3D(0, 20, 3), Point3D(5, 20, 3), Point3D(5, 5, 3)) pts_4 = (Point3D(5, 15, 3), Point3D(5, 20, 3), Point3D(20, 20, 3), Point3D(20, 15, 3)) pts_5 = (Point3D(-5, -5, 3), Point3D(-10, -5, 3), Point3D(-10, -10, 3), Point3D(-5, -10, 3)) room2d_1 = Room2D('Office1', Face3D(pts_1), 3) room2d_2 = Room2D('Office2', Face3D(pts_2), 3) room2d_3 = Room2D('Office3', Face3D(pts_3), 3) room2d_4 = Room2D('Office4', Face3D(pts_4), 3) room2d_5 = Room2D('Office5', Face3D(pts_5), 3) int_rms = Room2D.intersect_adjacency( [room2d_1, room2d_2, room2d_3, room2d_4, room2d_5], 0.01) story = Story('OfficeFloor', int_rms) story.rotate_xy(5, Point3D(0, 0, 0)) story.solve_room_2d_adjacency(0.01) story.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story.multiplier = 5 building_mult = Building('OfficeBuilding', [story]) # set program type building.properties.energy.set_all_room_2d_program_type(office_program) building_big.properties.energy.set_all_room_2d_program_type(office_program) building_mult.properties.energy.set_all_room_2d_program_type( office_program) # get context shade tree_canopy_geo1 = Face3D.from_regular_polygon(6, 6, Plane(o=Point3D(5, -10, 6))) tree_canopy_geo2 = Face3D.from_regular_polygon( 6, 2, Plane(o=Point3D(-5, -10, 3))) tree_canopy = ContextShade('TreeCanopy', [tree_canopy_geo1, tree_canopy_geo2]) # create the Model object model = Model('TestGeoJSON', [building, building_big, building_mult], [tree_canopy]) # create the urbanopt folder location = Location('Boston', 'MA', 'USA', 42.366151, -71.019357) sim_folder = './tests/urbanopt_model' geojson, hb_model_jsons, hb_models = \ model.to.urbanopt(model, location, folder=sim_folder) # check that the appropriate files were generated assert os.path.isfile(geojson) for model_json in hb_model_jsons: assert os.path.isfile(model_json) for h_model in hb_models: assert isinstance(h_model, hb_model.Model) # clean up the files nukedir(sim_folder, True)