def test_overhang_scale(): """Test the scale method.""" simple_awning = Overhang(2, 10) new_simple_awning = simple_awning.scale(2) assert new_simple_awning.depth == 4 assert new_simple_awning.angle == 10
def test_overhang_dict_methods(): """Test the to/from dict methods.""" simple_awning = Overhang(2, 10) shd_dict = simple_awning.to_dict() new_simple_awning = Overhang.from_dict(shd_dict) assert new_simple_awning == simple_awning assert shd_dict == new_simple_awning.to_dict()
def test_overhang_equality(): """Test the equality of Overhang objects.""" simple_awning = Overhang(2, 10) simple_awning_dup = simple_awning.duplicate() simple_awning_alt = Overhang(3, 10) assert simple_awning is simple_awning assert simple_awning is not simple_awning_dup assert simple_awning == simple_awning_dup assert simple_awning != simple_awning_alt
def test_dict_to_object_shd_par(): """Test the dict_to_object method with shading parameters.""" simple_border = ExtrudedBorder(0.3) simple_awning = Overhang(2, 10) louvers1 = LouversByDistance(0.5, 0.3, 1, 30) louvers2 = LouversByCount(3, 0.3, 1, 30) assert isinstance(dict_to_object(simple_border.to_dict()), ExtrudedBorder) assert isinstance(dict_to_object(simple_awning.to_dict()), Overhang) assert isinstance(dict_to_object(louvers1.to_dict()), LouversByDistance) assert isinstance(dict_to_object(louvers2.to_dict()), LouversByCount)
def test_overhang_add_shading_to_face(): """Test the add_shading_to_face method.""" simple_awning = Overhang(2, 0) height = 3 width = 10 seg = LineSegment3D.from_end_points(Point3D(0, 0, 2), Point3D(width, 0, 2)) face = Face('test_face', Face3D.from_extrusion(seg, Vector3D(0, 0, height))) simple_awning.add_shading_to_face(face, 0.01) assert len(face.outdoor_shades) == 1 assert face.outdoor_shades[0].center.z == pytest.approx(2 + 3, rel=1e-1) assert face.outdoor_shades[0].area == pytest.approx(20, rel=1e-3)
def test_room2d_init_clockwise(): """Test the initialization of Room2D objects with clockwise vertices.""" pts = (Point3D(0, 10, 3), Point3D(10, 10, 3), Point3D(10, 0, 3), Point3D(0, 0, 3)) ashrae_base = SimpleWindowRatio(0.4) overhang = Overhang(1) boundarycs = (bcs.outdoors, bcs.outdoors, bcs.ground, bcs.ground) window = (ashrae_base, ashrae_base, None, None) shading = (overhang, None, None, None) room2d = Room2D('TestZone', Face3D(pts), 3, boundarycs, window, shading) assert room2d.floor_geometry.boundary == tuple(reversed(pts)) assert room2d.boundary_conditions == tuple(reversed(boundarycs)) assert room2d.window_parameters == tuple(reversed(window)) assert room2d.shading_parameters == tuple(reversed(shading)) pts_hole = (Point3D(2, 8, 3), Point3D(8, 8, 3), Point3D(8, 2, 3), Point3D(2, 2, 3)) boundarycs = (bcs.outdoors, bcs.outdoors, bcs.ground, bcs.ground, bcs.outdoors, bcs.outdoors, bcs.ground, bcs.ground) window = (ashrae_base, ashrae_base, None, None, ashrae_base, ashrae_base, None, None) shading = (overhang, None, None, None, overhang, None, None, None) room2d = Room2D('TestZone', Face3D(pts, holes=[pts_hole]), 3, boundarycs, window, shading) assert room2d.floor_geometry.boundary == tuple(reversed(pts)) assert room2d.floor_geometry.holes[0] == pts_hole assert room2d.boundary_conditions == \ (bcs.ground, bcs.ground, bcs.outdoors, bcs.outdoors, bcs.outdoors, bcs.outdoors, bcs.ground, bcs.ground) assert room2d.window_parameters == \ (None, None, ashrae_base, ashrae_base, ashrae_base, ashrae_base, None, None) assert room2d.shading_parameters == \ (None, None, None, overhang, overhang, None, None, None)
def test_story_set_outdoor_window_shading_parameters(): """Test the Story set_outdoor_window_parameters method.""" pts_1 = (Point3D(0, 0, 3), Point3D(0, 10, 3), Point3D(10, 10, 3), Point3D(10, 0, 3)) pts_2 = (Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(20, 10, 3), Point3D(20, 0, 3)) pts_3 = (Point3D(0, 10, 3), Point3D(0, 20, 3), Point3D(10, 20, 3), Point3D(10, 10, 3)) pts_4 = (Point3D(10, 10, 3), Point3D(10, 20, 3), Point3D(20, 20, 3), Point3D(20, 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) story = Story('OfficeFloor', [room2d_1, room2d_2, room2d_3, room2d_4]) story.solve_room_2d_adjacency(0.01) ashrae_base = SimpleWindowRatio(0.4) overhang = Overhang(1) story.set_outdoor_window_parameters(ashrae_base) story.set_outdoor_shading_parameters(overhang) assert story.room_2ds[0].window_parameters[1] is None assert story.room_2ds[0].window_parameters[2] == ashrae_base assert story.room_2ds[0].shading_parameters[1] is None assert story.room_2ds[0].shading_parameters[2] == overhang assert story.exterior_wall_area == 60 * 4 assert story.exterior_aperture_area == 60 * 4 * 0.4
def test_to_dict(): """Test the Building to_dict method.""" pts_1 = (Point3D(0, 0, 2), Point3D(10, 0, 2), Point3D(10, 10, 2), Point3D(0, 10, 2)) pts_2 = (Point3D(10, 0, 3), Point3D(20, 0, 3), Point3D(20, 10, 3), Point3D(10, 10, 3)) room2d_1 = Room2D('Office1', Face3D(pts_1), 5) room2d_2 = Room2D('Office2', Face3D(pts_2), 3) story = Story('Office_Floor', [room2d_1, room2d_2]) story.solve_room_2d_adjacency(0.01) story.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story.set_outdoor_shading_parameters(Overhang(1)) story.multiplier = 4 building = Building('Office_Building', [story]) building.separate_top_bottom_floors() bd = building.to_dict() assert bd['type'] == 'Building' assert bd['identifier'] == 'Office_Building' assert bd['display_name'] == 'Office_Building' assert 'unique_stories' in bd assert len(bd['unique_stories']) == 3 assert 'properties' in bd assert bd['properties']['type'] == 'BuildingProperties'
def test_room2d_init_with_windows(): """Test the initialization of Room2D objects with windows.""" pts = (Point3D(0, 0, 3), Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(0, 10, 3)) ashrae_base = SimpleWindowRatio(0.4) overhang = Overhang(1) boundarycs = (bcs.outdoors, bcs.ground, bcs.outdoors, bcs.ground) window = (ashrae_base, None, ashrae_base, None) shading = (overhang, None, None, None) room2d = Room2D('SquareShoebox', Face3D(pts), 3, boundarycs, window, shading) assert len(room2d.floor_geometry.vertices) == 4 assert room2d.floor_geometry.vertices == tuple(pts) assert len(room2d) == 4 assert room2d.floor_to_ceiling_height == 3 assert isinstance(room2d.boundary_conditions[0], Outdoors) assert isinstance(room2d.boundary_conditions[1], Ground) assert room2d.window_parameters[0] == ashrae_base assert room2d.window_parameters[1] is None assert room2d.shading_parameters[0] == overhang assert room2d.shading_parameters[1] is None assert room2d.floor_height == 3 assert room2d.ceiling_height == 6 assert room2d.volume == 300 assert room2d.floor_area == 100 assert room2d.exterior_wall_area == 60 assert room2d.exterior_aperture_area == 60 * 0.4
def test_to_honeybee(): """Test the to_honeybee method.""" pts = (Point3D(0, 0, 3), Point3D(5, 0, 3), Point3D(5, 10, 3), Point3D(0, 10, 3)) ashrae_base = SimpleWindowRatio(0.5) overhang = Overhang(1) boundarycs = (bcs.outdoors, bcs.ground, bcs.outdoors, bcs.ground) window = (ashrae_base, None, ashrae_base, None) shading = (overhang, None, None, None) room2d = Room2D('ZoneSHOE_BOX920980', Face3D(pts), 3, boundarycs, window, shading) room, adj = room2d.to_honeybee(1, tolerance=0.1) assert room.identifier == 'ZoneSHOE_BOX920980' assert room.display_name == 'ZoneSHOE_BOX920980' assert isinstance(room.geometry, Polyface3D) assert len(room.geometry.vertices) == 8 assert len(room) == 6 assert room.volume == 150 assert room.floor_area == 50 assert room.exterior_wall_area == 30 assert room.exterior_aperture_area == 15 assert room.average_floor_height == 3 assert room.check_solid(0.01, 1) == '' assert len(room[1].apertures) == 1 assert len(room[2].apertures) == 0 assert len(room[3].apertures) == 1 assert len(room[1].outdoor_shades) == 1 assert len(room[3].outdoor_shades) == 0
def test_to_dict(): """Test the Room2D to_dict method with energy properties.""" mass_set = ConstructionSet('Thermal Mass Construction Set') pts = (Point3D(0, 0, 3), Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(0, 10, 3)) ashrae_base = SimpleWindowRatio(0.4) overhang = Overhang(1) boundarycs = (bcs.outdoors, bcs.ground, bcs.outdoors, bcs.ground) window = (ashrae_base, None, ashrae_base, None) shading = (overhang, None, None, None) room = Room2D('ShoeBoxZone', Face3D(pts), 3, boundarycs, window, shading) rd = room.to_dict() assert 'properties' in rd assert rd['properties']['type'] == 'Room2DProperties' assert 'energy' in rd['properties'] assert rd['properties']['energy']['type'] == 'Room2DEnergyProperties' assert 'program_type' not in rd['properties']['energy'] or \ rd['properties']['energy']['program_type'] is None assert 'construction_set' not in rd['properties']['energy'] or \ rd['properties']['energy']['construction_set'] is None assert 'hvac' not in rd['properties']['energy'] or \ rd['properties']['energy']['hvac'] is None room.properties.energy.construction_set = mass_set room.properties.energy.program_type = office_program rd = room.to_dict() assert rd['properties']['energy']['construction_set'] is not None assert rd['properties']['energy']['program_type'] is not None
def test_set_construction_set(): """Test the setting of a ConstructionSet on a Room2D.""" pts = (Point3D(0, 0, 3), Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(0, 10, 3)) ashrae_base = SimpleWindowRatio(0.4) overhang = Overhang(1) boundarycs = (bcs.outdoors, bcs.ground, bcs.outdoors, bcs.ground) window = (ashrae_base, None, ashrae_base, None) shading = (overhang, None, None, None) room = Room2D('SquareShoebox', Face3D(pts), 3, boundarycs, window, shading) mass_set = ConstructionSet('Thermal Mass Construction Set') concrete20 = EnergyMaterial('20cm Concrete', 0.2, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) concrete10 = EnergyMaterial('10cm Concrete', 0.1, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) thick_constr = OpaqueConstruction('Thick Concrete Construction', [concrete20]) thin_constr = OpaqueConstruction('Thin Concrete Construction', [concrete10]) shade_constr = ShadeConstruction('Light Shelf', 0.5, 0.5) mass_set.wall_set.exterior_construction = thick_constr mass_set.roof_ceiling_set.interior_construction = thin_constr mass_set.shade_construction = shade_constr room.properties.energy.construction_set = mass_set assert room.properties.energy.construction_set == mass_set hb_room, adj = room.to_honeybee() assert hb_room.properties.energy.construction_set == mass_set assert hb_room[1].properties.energy.construction == thick_constr assert hb_room[5].properties.energy.construction == thin_constr assert hb_room[1].shades[0].properties.energy.construction == shade_constr
def test_overhang_init(): """Test the initalization of Overhang objects and basic properties.""" simple_awning = Overhang(2, 10) str(simple_awning) # test the string representation assert simple_awning.depth == 2 assert simple_awning.angle == 10
def test_room2d_init_invalid(): """Test the initialization of Room2D objects with invalid inputs.""" pts = (Point3D(0, 0, 3), Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(0, 10, 3)) ashrae_base = SimpleWindowRatio(0.4) overhang = Overhang(1) boundarycs = [bcs.outdoors, bcs.ground, bcs.outdoors, bcs.ground] window = [ashrae_base, None, ashrae_base, None] shading = [overhang, None, None, None] Room2D('SquareShoebox', Face3D(pts), 3, boundarycs, window, shading) old_bc = boundarycs.pop(-1) with pytest.raises(AssertionError): Room2D('SquareShoebox', Face3D(pts), 3, boundarycs, window, shading) boundarycs.append(old_bc) old_glz = window.pop(-1) with pytest.raises(AssertionError): Room2D('SquareShoebox', Face3D(pts), 3, boundarycs, window, shading) window.append(old_glz) old_shd = shading.pop(-1) with pytest.raises(AssertionError): Room2D('SquareShoebox', Face3D(pts), 3, boundarycs, window, shading) shading.append(old_shd) new_bcs = [bcs.ground, bcs.outdoors, bcs.outdoors, bcs.ground] with pytest.raises(AssertionError): Room2D('SquareShoebox', Face3D(pts), 3, new_bcs, window, shading) new_glz = [None, ashrae_base, ashrae_base, None] with pytest.raises(AssertionError): Room2D('SquareShoebox', Face3D(pts), 3, boundarycs, new_glz, shading)
def test_room2d_remove_duplicate_vertices(): """Test the Room2D remove_duplicate_vertices method.""" pts = (Point3D(0, 0, 3), Point3D(10, 0, 3), Point3D(10, 0, 3.001), Point3D(10, 10, 3), Point3D(0, 10, 3)) ashrae_base = SimpleWindowRatio(0.4) overhang = Overhang(1) boundarycs = (bcs.outdoors, bcs.ground, bcs.ground, bcs.outdoors, bcs.ground) window = (ashrae_base, None, None, ashrae_base, None) shading = (overhang, None, None, None, None) room2d = Room2D('SquareShoebox', Face3D(pts), 3, boundarycs, window, shading) assert len(room2d.boundary_conditions) == 5 assert len(room2d.window_parameters) == 5 assert len(room2d.shading_parameters) == 5 room2d.remove_duplicate_vertices(0.01) assert len(room2d.boundary_conditions) == 4 assert len(room2d.window_parameters) == 4 assert len(room2d.shading_parameters) == 4 pts = (Point3D(0, 0, 3), Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(0, 10, 3), Point3D(0, 0.0001, 3)) ashrae_base = SimpleWindowRatio(0.4) overhang = Overhang(1) boundarycs = (bcs.outdoors, bcs.ground, bcs.outdoors, bcs.ground, bcs.outdoors) window = (ashrae_base, None, ashrae_base, None, ashrae_base) shading = (overhang, None, None, None, overhang) room2d = Room2D('SquareShoebox', Face3D(pts), 3, boundarycs, window, shading) assert len(room2d.boundary_conditions) == 5 assert len(room2d.window_parameters) == 5 assert len(room2d.shading_parameters) == 5 room2d.remove_duplicate_vertices(0.01) assert len(room2d.boundary_conditions) == 4 assert len(room2d.window_parameters) == 4 assert len(room2d.shading_parameters) == 4
def test_to_from_dict(): """Test the to/from dict of Room2D objects.""" pts = (Point3D(0, 0, 3), Point3D(5, 0, 3), Point3D(5, 10, 3), Point3D(0, 10, 3)) ashrae_base = SimpleWindowRatio(0.4) overhang = Overhang(1) boundarycs = (bcs.outdoors, bcs.ground, bcs.outdoors, bcs.ground) window = (ashrae_base, None, ashrae_base, None) shading = (overhang, None, None, None) room = Room2D('ShoeBoxZone', Face3D(pts), 3, boundarycs, window, shading, True) room_dict = room.to_dict() new_room = Room2D.from_dict(room_dict) assert isinstance(new_room, Room2D) assert new_room.to_dict() == room_dict
def test_to_from_dict(): """Test the to/from dict of Story objects.""" pts_1 = (Point3D(0, 0, 2), Point3D(10, 0, 2), Point3D(10, 10, 2), Point3D(0, 10, 2)) pts_2 = (Point3D(10, 0, 3), Point3D(20, 0, 3), Point3D(20, 10, 3), Point3D(10, 10, 3)) room2d_1 = Room2D('Office1', Face3D(pts_1), 5) room2d_2 = Room2D('Office2', Face3D(pts_2), 3) story = Story('OfficeFloor', [room2d_1, room2d_2]) story.solve_room_2d_adjacency(0.01) story.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story.set_outdoor_shading_parameters(Overhang(1)) story_dict = story.to_dict() new_story = Story.from_dict(story_dict) assert isinstance(new_story, Story) assert new_story.to_dict() == story_dict
def test_room2d_init_from_polygon_clockwise(): """Test the initialization of Room2D objects from a clockwise Polygon2D.""" pts_3d = (Point3D(0, 10, 3), Point3D(10, 10, 3), Point3D(10, 0, 3), Point3D(0, 0, 3)) pts = (Point2D(0, 10), Point2D(10, 10), Point2D(10, 0), Point2D(0, 0)) polygon = Polygon2D(pts) ashrae_base = SimpleWindowRatio(0.4) overhang = Overhang(1) boundarycs = (bcs.outdoors, bcs.outdoors, bcs.ground, bcs.ground) window = (ashrae_base, ashrae_base, None, None) shading = (overhang, None, None, None) room2d = Room2D.from_polygon('SquareShoebox', polygon, 3, 3, boundarycs, window, shading) assert room2d.floor_geometry.boundary == tuple(reversed(pts_3d)) assert room2d.boundary_conditions == tuple(reversed(boundarycs)) assert room2d.window_parameters == tuple(reversed(window)) assert room2d.shading_parameters == tuple(reversed(shading))
def room2d_simple(directory): """Generate simple Room2D sample.""" mass_set = ConstructionSet('Thermal Mass Construction Set') pts = (Point3D(0, 0, 3), Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(0, 10, 3)) ashrae_base = SimpleWindowRatio(0.4) overhang = Overhang(1) boundarycs = (bcs.outdoors, bcs.ground, bcs.outdoors, bcs.ground) window = (ashrae_base, None, ashrae_base, None) shading = (overhang, None, None, None) room = Room2D('Shoe Box Zone', Face3D(pts), 3, boundarycs, window, shading) room.properties.energy.construction_set = mass_set room.properties.energy.program_type = office_program dest_file = os.path.join(directory, 'room2d_simple.json') with open(dest_file, 'w') as fp: json.dump(room.to_dict(True), fp, indent=4)
def test_building_window_shading_parameters(): """Test the Building set_outdoor_window_parameters method.""" pts_1 = (Point3D(0, 0, 3), Point3D(0, 10, 3), Point3D(10, 10, 3), Point3D(10, 0, 3)) pts_2 = (Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(20, 10, 3), Point3D(20, 0, 3)) pts_3 = (Point3D(0, 10, 3), Point3D(0, 20, 3), Point3D(10, 20, 3), Point3D(10, 10, 3)) pts_4 = (Point3D(10, 10, 3), Point3D(10, 20, 3), Point3D(20, 20, 3), Point3D(20, 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) story = Story('Office_Floor', [room2d_1, room2d_2, room2d_3, room2d_4]) story.solve_room_2d_adjacency(0.01) story.multiplier = 4 building = Building('Office_Building', [story]) assert building.exterior_aperture_area == 0 assert building.unique_room_2ds[0].window_parameters[2] is None ashrae_base = SimpleWindowRatio(0.4) story.set_outdoor_window_parameters(ashrae_base) assert building.exterior_aperture_area == 60 * 4 * 4 * 0.4 assert building.unique_room_2ds[0].window_parameters[2] == ashrae_base assert building.unique_room_2ds[0].shading_parameters[2] is None overhang = Overhang(1) story.set_outdoor_shading_parameters(overhang) assert building.unique_room_2ds[0].shading_parameters[2] == overhang assert len(building.unique_stories) == 1 assert len(building.all_stories()) == 4 assert len(building.unique_room_2ds) == 4 building.separate_top_bottom_floors() assert len(building.unique_stories) == 3 assert len(set(story.identifier for story in building.unique_stories)) == 3 assert len(building.all_stories()) == 4 assert len(building.unique_room_2ds) == 12
def test_scale(): """Test the Room2D scale method.""" pts = (Point3D(1, 1, 2), Point3D(2, 1, 2), Point3D(2, 2, 2), Point3D(1, 2, 2)) plane_1 = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 0)) room = Room2D('SquareShoebox', Face3D(pts, plane_1), 3) room.set_outdoor_window_parameters(SingleWindow(1, 1, 1)) room.set_outdoor_shading_parameters(Overhang(1)) new_r = room.duplicate() new_r.scale(2) assert new_r.floor_geometry[0] == Point3D(2, 2, 4) assert new_r.floor_geometry[1] == Point3D(4, 2, 4) assert new_r.floor_geometry[2] == Point3D(4, 4, 4) assert new_r.floor_geometry[3] == Point3D(2, 4, 4) assert new_r.floor_area == room.floor_area * 2 ** 2 assert new_r.volume == room.volume * 2 ** 3 assert new_r.window_parameters[0].width == 2 assert new_r.window_parameters[0].height == 2 assert new_r.window_parameters[0].sill_height == 2 assert new_r.shading_parameters[0].depth == 2
def test_to_dict(): """Test the Story to_dict method.""" pts_1 = (Point3D(0, 0, 2), Point3D(10, 0, 2), Point3D(10, 10, 2), Point3D(0, 10, 2)) pts_2 = (Point3D(10, 0, 3), Point3D(20, 0, 3), Point3D(20, 10, 3), Point3D(10, 10, 3)) room2d_1 = Room2D('Office1', Face3D(pts_1), 5) room2d_2 = Room2D('Office2', Face3D(pts_2), 3) story = Story('OfficeFloor', [room2d_1, room2d_2]) story.solve_room_2d_adjacency(0.01) story.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story.set_outdoor_shading_parameters(Overhang(1)) sd = story.to_dict() assert sd['type'] == 'Story' assert sd['identifier'] == 'OfficeFloor' assert sd['display_name'] == 'OfficeFloor' assert 'room_2ds' in sd assert len(sd['room_2ds']) == 2 assert sd['floor_to_floor_height'] == 5 assert sd['multiplier'] == 1 assert 'properties' in sd assert sd['properties']['type'] == 'StoryProperties'
def test_energy_properties(): """Test the existence of the Room2D energy properties.""" pts = (Point3D(0, 0, 3), Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(0, 10, 3)) ashrae_base = SimpleWindowRatio(0.4) overhang = Overhang(1) boundarycs = (bcs.outdoors, bcs.ground, bcs.outdoors, bcs.ground) window = (ashrae_base, None, ashrae_base, None) shading = (overhang, None, None, None) room = Room2D('SquareShoebox', Face3D(pts), 3, boundarycs, window, shading) room.properties.energy.program_type = office_program room.properties.energy.add_default_ideal_air() assert hasattr(room.properties, 'energy') assert isinstance(room.properties.energy, Room2DEnergyProperties) assert isinstance(room.properties.energy.construction_set, ConstructionSet) assert isinstance(room.properties.energy.program_type, ProgramType) assert isinstance(room.properties.energy.hvac, IdealAirSystem) assert room.properties.energy.program_type == office_program assert room.properties.energy.is_conditioned
def test_to_from_dict(): """Test the to/from dict of Building objects.""" pts_1 = (Point3D(0, 0, 2), Point3D(10, 0, 2), Point3D(10, 10, 2), Point3D(0, 10, 2)) pts_2 = (Point3D(10, 0, 3), Point3D(20, 0, 3), Point3D(20, 10, 3), Point3D(10, 10, 3)) room2d_1 = Room2D('Office1', Face3D(pts_1), 5) room2d_2 = Room2D('Office2', Face3D(pts_2), 3) story = Story('Office_Floor', [room2d_1, room2d_2]) story.solve_room_2d_adjacency(0.01) story.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story.set_outdoor_shading_parameters(Overhang(1)) story.multiplier = 4 building = Building('Office_Building', [story]) building.separate_top_bottom_floors() building_dict = building.to_dict() new_building = Building.from_dict(building_dict) assert isinstance(new_building, Building) assert new_building.to_dict() == building_dict
def test_to_dict(): """Test the Room2D to_dict method.""" pts = (Point3D(0, 0, 3), Point3D(5, 0, 3), Point3D(5, 10, 3), Point3D(0, 10, 3)) ashrae_base = SimpleWindowRatio(0.4) overhang = Overhang(1) boundarycs = (bcs.outdoors, bcs.ground, bcs.outdoors, bcs.ground) window = (ashrae_base, None, ashrae_base, None) shading = (overhang, None, None, None) room = Room2D('ShoeBoxZone', Face3D(pts), 3, boundarycs, window, shading, True, False) rd = room.to_dict() assert rd['type'] == 'Room2D' assert rd['identifier'] == 'ShoeBoxZone' assert rd['display_name'] == 'ShoeBoxZone' assert 'floor_boundary' in rd assert len(rd['floor_boundary']) == 4 assert 'floor_holes' not in rd assert rd['floor_height'] == 3 assert rd['floor_to_ceiling_height'] == 3 assert 'boundary_conditions' in rd assert len(rd['boundary_conditions']) == 4 assert 'window_parameters' in rd assert len(rd['window_parameters']) == 4 assert 'shading_parameters' in rd assert len(rd['shading_parameters']) == 4 assert rd['is_ground_contact'] assert not rd['is_top_exposed'] assert 'properties' in rd assert rd['properties']['type'] == 'Room2DProperties' room_2 = Room2D('ShoeBoxZone', Face3D(pts), 3) rd = room_2.to_dict() assert 'boundary_conditions' in rd assert len(rd['boundary_conditions']) == 4 assert 'window_parameters' not in rd assert 'shading_parameters' not in rd
Args: _depth: A number for the overhang depth. _angle_: A number for the for an angle to rotate the overhang in degrees. Default is 0 for no rotation. Returns: shd_par: Shading Parameters that can be applied to a Dragonfly object using the "DF Apply Facade Parameters" component. """ ghenv.Component.Name = "DF Overhang Parameters" ghenv.Component.NickName = 'OverhangPar' ghenv.Component.Message = '1.2.0' ghenv.Component.Category = "Dragonfly" ghenv.Component.SubCategory = '0 :: Create' ghenv.Component.AdditionalHelpFromDocStrings = "6" try: # import the core dragonfly dependencies from dragonfly.shadingparameter import Overhang except ImportError as e: raise ImportError('\nFailed to import dragonfly:\n\t{}'.format(e)) try: from ladybug_rhino.grasshopper import all_required_inputs except ImportError as e: raise ImportError('\nFailed to import dragonfly:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component): _angle_ = _angle_ if _angle_ is not None else 0.0 shd_par = Overhang(_depth, _angle_)
def shading_par_overhang(directory): simple_awning = Overhang(2, 10) dest_file = os.path.join(directory, 'shading_par_overhang.json') with open(dest_file, 'w') as fp: json.dump(simple_awning.to_dict(), fp, indent=4)