def test_default_constructions(): """Test the auto-assigning of constructions by boundary condition.""" vertices_parent_wall = [[0, 0, 0], [0, 10, 0], [0, 10, 3], [0, 0, 3]] vertices_parent_wall_2 = list(reversed(vertices_parent_wall)) vertices_wall = [[0, 1, 0], [0, 2, 0], [0, 2, 2], [0, 0, 2]] vertices_wall_2 = list(reversed(vertices_wall)) vertices_floor = [[0, 0, 0], [0, 1, 0], [1, 1, 0], [1, 0, 0]] vertices_roof = [[1, 0, 3], [1, 1, 3], [0, 1, 3], [0, 0, 3]] wf = Face.from_vertices('wall face', vertices_parent_wall) wdr = Door.from_vertices('wall door', vertices_wall) wf.add_door(wdr) Room('Test Room 1', [wf]) assert wdr.properties.energy.construction.name == 'Generic Exterior Door' wf2 = Face.from_vertices('wall face2', vertices_parent_wall_2) wdr2 = Door.from_vertices('wall door2', vertices_wall_2) wf2.add_door(wdr2) Room('Test Room 2', [wf2]) wdr.set_adjacency(wdr2) assert wdr.properties.energy.construction.name == 'Generic Interior Door' ra = Door.from_vertices('roof door', vertices_roof) assert ra.properties.energy.construction.name == 'Generic Exterior Door' fa = Door.from_vertices('floor door', vertices_floor) assert fa.properties.energy.construction.name == 'Generic Exterior Door'
def test_rotate_xy(): """Test the Door rotate_xy method.""" pts = (Point3D(1, 1, 2), Point3D(2, 1, 2), Point3D(2, 2, 2), Point3D(1, 2, 2)) plane = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 2)) door = Door('Rectangle Door', Face3D(pts, plane)) origin_1 = Point3D(1, 1, 0) test_1 = door.duplicate() test_1.rotate_xy(180, origin_1) assert test_1.geometry[0].x == pytest.approx(1, rel=1e-3) assert test_1.geometry[0].y == pytest.approx(1, rel=1e-3) assert test_1.geometry[0].z == pytest.approx(2, rel=1e-3) assert test_1.geometry[2].x == pytest.approx(0, rel=1e-3) assert test_1.geometry[2].y == pytest.approx(0, rel=1e-3) assert test_1.geometry[2].z == pytest.approx(2, rel=1e-3) test_2 = door.duplicate() test_2.rotate_xy(90, origin_1) assert test_2.geometry[0].x == pytest.approx(1, rel=1e-3) assert test_2.geometry[0].y == pytest.approx(1, rel=1e-3) assert test_1.geometry[0].z == pytest.approx(2, rel=1e-3) assert test_2.geometry[2].x == pytest.approx(0, rel=1e-3) assert test_2.geometry[2].y == pytest.approx(2, rel=1e-3) assert test_1.geometry[2].z == pytest.approx(2, rel=1e-3)
def test_duplicate(): """Test what happens to energy properties when duplicating a Door.""" verts = [ Point3D(0, 0, 0), Point3D(1, 0, 0), Point3D(1, 0, 3), Point3D(0, 0, 3) ] concrete5 = EnergyMaterial('5cm Concrete', 0.05, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) mass_constr = OpaqueConstruction('Concrete Door', [concrete5]) door_original = Door('wall door', Face3D(verts)) door_dup_1 = door_original.duplicate() assert door_original.properties.energy.host is door_original assert door_dup_1.properties.energy.host is door_dup_1 assert door_original.properties.energy.host is not \ door_dup_1.properties.energy.host assert door_original.properties.energy.construction == \ door_dup_1.properties.energy.construction door_dup_1.properties.energy.construction = mass_constr assert door_original.properties.energy.construction != \ door_dup_1.properties.energy.construction door_dup_2 = door_dup_1.duplicate() assert door_dup_1.properties.energy.construction == \ door_dup_2.properties.energy.construction door_dup_2.properties.energy.construction = None assert door_dup_1.properties.energy.construction != \ door_dup_2.properties.energy.construction
def test_rotate(): """Test the Door rotate method.""" pts = (Point3D(0, 0, 2), Point3D(2, 0, 2), Point3D(2, 2, 2), Point3D(0, 2, 2)) plane = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 2)) door = Door('Rectangle Door', Face3D(pts, plane)) origin = Point3D(0, 0, 0) axis = Vector3D(1, 0, 0) test_1 = door.duplicate() test_1.rotate(axis, 180, origin) assert test_1.geometry[0].x == pytest.approx(0, rel=1e-3) assert test_1.geometry[0].y == pytest.approx(0, rel=1e-3) assert test_1.geometry[0].z == pytest.approx(-2, rel=1e-3) assert test_1.geometry[2].x == pytest.approx(2, rel=1e-3) assert test_1.geometry[2].y == pytest.approx(-2, rel=1e-3) assert test_1.geometry[2].z == pytest.approx(-2, rel=1e-3) assert door.area == test_1.area assert len(door.vertices) == len(test_1.vertices) test_2 = door.duplicate() test_2.rotate(axis, 90, origin) assert test_2.geometry[0].x == pytest.approx(0, rel=1e-3) assert test_2.geometry[0].y == pytest.approx(-2, rel=1e-3) assert test_2.geometry[0].z == pytest.approx(0, rel=1e-3) assert test_2.geometry[2].x == pytest.approx(2, rel=1e-3) assert test_2.geometry[2].y == pytest.approx(-2, rel=1e-3) assert test_2.geometry[2].z == pytest.approx(2, rel=1e-3) assert door.area == test_2.area assert len(door.vertices) == len(test_2.vertices)
def test_default_modifiers(): """Test the auto-assigning of modifiers by boundary condition.""" vertices_parent_wall = [[0, 0, 0], [0, 10, 0], [0, 10, 3], [0, 0, 3]] vertices_parent_wall_2 = list(reversed(vertices_parent_wall)) vertices_wall = [[0, 1, 0], [0, 2, 0], [0, 2, 2], [0, 0, 2]] vertices_wall_2 = list(reversed(vertices_wall)) wf = Face.from_vertices('wall_face', vertices_parent_wall) wdr = Door.from_vertices('wall_door', vertices_wall) wf.add_door(wdr) Room('TestRoom1', [wf]) assert wdr.properties.radiance.modifier == generic_door wf2 = Face.from_vertices('wall_face2', vertices_parent_wall_2) wdr2 = Door.from_vertices('wall_door2', vertices_wall_2) wdr.is_glass = True wdr2.is_glass = True wf2.add_door(wdr2) Room('TestRoom2', [wf2]) wdr.set_adjacency(wdr2) assert wdr.properties.radiance.modifier == generic_interior_window ra = Door.from_vertices('wall_door', vertices_parent_wall) ra.is_glass = True assert ra.properties.radiance.modifier == generic_exterior_window
def test_to_from_dict_with_states(): """Test the Door from_dict method with radiance properties.""" dr = Door.from_vertices('front_door', [[0, 0, 0], [10, 0, 0], [10, 0, 10], [0, 0, 10]]) shd1 = StateGeometry.from_vertices( 'wall_overhang1', [[0, 0, 10], [10, 0, 10], [10, 2, 10], [0, 2, 10]]) shd2 = StateGeometry.from_vertices( 'wall_overhang2', [[0, 0, 5], [10, 0, 5], [10, 2, 5], [0, 2, 5]]) ecglass1 = Glass.from_single_transmittance('ElectrochromicState1', 0.4) ecglass2 = Glass.from_single_transmittance('ElectrochromicState2', 0.27) ecglass3 = Glass.from_single_transmittance('ElectrochromicState3', 0.14) ecglass4 = Glass.from_single_transmittance('ElectrochromicState4', 0.01) tint1 = RadianceSubFaceState(ecglass1) tint2 = RadianceSubFaceState(ecglass2) tint3 = RadianceSubFaceState(ecglass3, [shd1]) tint4 = RadianceSubFaceState(ecglass4, [shd1.duplicate(), shd2]) states = (tint1, tint2, tint3, tint4) dr.properties.radiance.dynamic_group_identifier = 'ElectrochromicDoor1' dr.properties.radiance.states = states drd = dr.to_dict() new_door = Door.from_dict(drd) assert new_door.properties.radiance.dynamic_group_identifier == \ dr.properties.radiance.dynamic_group_identifier state_ids1 = [state.modifier for state in states] state_ids2 = [ state.modifier for state in new_door.properties.radiance.states ] assert state_ids1 == state_ids2 assert new_door.to_dict() == drd
def test_to_from_dict(): """Test the to/from dict of Door objects.""" vertices = [[0, 0, 0], [0, 10, 0], [0, 10, 3], [0, 0, 3]] dr = Door.from_vertices('RectangleDoor', vertices) dr_dict = dr.to_dict() new_dr = Door.from_dict(dr_dict) assert isinstance(new_dr, Door) assert new_dr.to_dict() == dr_dict
def test_from_dict(): """Test the Door from_dict method with radiance properties.""" door = Door.from_vertices('wall_door', [[0, 0, 0], [10, 0, 0], [10, 0, 10], [0, 0, 10]]) painted_door = Plastic.from_single_reflectance('PaintedDoor', 0.75) door.properties.radiance.modifier = painted_door ad = door.to_dict() new_door = Door.from_dict(ad) assert new_door.properties.radiance.modifier == painted_door assert new_door.to_dict() == ad
def test_from_dict(): """Test the Door from_dict method with energy properties.""" door = Door.from_vertices('front door', [[0, 0, 0], [10, 0, 0], [10, 0, 10], [0, 0, 10]]) concrete5 = EnergyMaterial('5cm Concrete', 0.05, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) mass_constr = OpaqueConstruction('Concrete Door', [concrete5]) door.properties.energy.construction = mass_constr drd = door.to_dict() new_door = Door.from_dict(drd) assert new_door.properties.energy.construction == mass_constr assert new_door.to_dict() == drd
def test_door_duplicate(): """Test the duplication of door objects.""" pts = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(1, 0, 3), Point3D(1, 0, 0)) dr_1 = Door('TestDoor', Face3D(pts)) dr_2 = dr_1.duplicate() assert dr_1 is not dr_2 for i, pt in enumerate(dr_1.vertices): assert pt == dr_2.vertices[i] assert dr_1.identifier == dr_2.identifier dr_2.move(Vector3D(0, 1, 0)) for i, pt in enumerate(dr_1.vertices): assert pt != dr_2.vertices[i]
def test_scale(): """Test the Door scale method.""" pts = (Point3D(1, 1, 2), Point3D(2, 1, 2), Point3D(2, 2, 2), Point3D(1, 2, 2)) plane = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 2)) door = Door('RectangleDoor', Face3D(pts, plane)) new_dr = door.duplicate() new_dr.scale(2) assert new_dr.geometry[0] == Point3D(2, 2, 4) assert new_dr.geometry[1] == Point3D(4, 2, 4) assert new_dr.geometry[2] == Point3D(4, 4, 4) assert new_dr.geometry[3] == Point3D(2, 4, 4) assert new_dr.area == door.area * 2 ** 2 assert new_dr.perimeter == door.perimeter * 2 assert new_dr.normal == door.normal
def test_to_hbpkl(): """Test the Model to_hbpkl method.""" room = Room.from_box('TinyHouseZone', 5, 10, 3) south_face = room[3] south_face.apertures_by_ratio(0.4, 0.01) south_face.apertures[0].overhang(0.5, indoor=False) south_face.apertures[0].overhang(0.5, indoor=True) south_face.apertures[0].move_shades(Vector3D(0, 0, -0.5)) north_face = room[1] door_verts = [ Point3D(2, 10, 0.1), Point3D(1, 10, 0.1), Point3D(1, 10, 2.5), Point3D(2, 10, 2.5) ] aperture_verts = [ Point3D(4.5, 10, 1), Point3D(2.5, 10, 1), Point3D(2.5, 10, 2.5), Point3D(4.5, 10, 2.5) ] door = Door('FrontDoor', Face3D(door_verts)) north_face.add_door(door) aperture = Aperture('FrontAperture', Face3D(aperture_verts)) north_face.add_aperture(aperture) model = Model('TinyHouse', [room]) path = './tests/json' model_hbpkl = model.to_hbpkl('test', path) assert os.path.isfile(model_hbpkl) new_model = Model.from_hbpkl(model_hbpkl) assert isinstance(new_model, Model) os.remove(model_hbpkl)
def test_set_modifier_set(): """Test the auto-assigning of Room properties.""" room = Room.from_box('Shoe_Box', 5, 10, 3, 90, Point3D(0, 0, 3)) door_verts = [[1, 0, 0.1], [2, 0, 0.1], [2, 0, 3], [1, 0, 3]] room[3].add_door(Door.from_vertices('test_door', door_verts)) room[1].apertures_by_ratio(0.4, 0.01) room[1].apertures[0].overhang(0.5, indoor=False) room[1].apertures[0].overhang(0.5, indoor=True) room[1].apertures[0].move_shades(Vector3D(0, 0, -0.5)) assert room.properties.radiance.modifier_set == generic_modifier_set_visible room.properties.radiance.modifier_set = generic_modifier_set_visible_exterior assert room[1].apertures[0].properties.radiance.modifier == \ generic_modifier_set_visible_exterior.aperture_set.window_modifier insect_screen_set = ModifierSet('Insect_Screen_Set') insect_screen_set.aperture_set.window_modifier = \ generic_exterior_window_insect_screen_solar room.properties.radiance.modifier_set = insect_screen_set assert room[1].apertures[0].properties.radiance.modifier == \ generic_exterior_window_insect_screen_solar with pytest.raises(AttributeError): room[1].properties.radiance.modifier.r_reflectance = 0.3 with pytest.raises(AttributeError): room[5].properties.radiance.modifier.r_reflectance = 0.3 with pytest.raises(AttributeError): room[3].doors[0].properties.radiance.modifier.r_reflectance = 0.3
def test_triangulated_doors(): """Test the triangulated_doors method.""" room = Room.from_box('Tiny House Zone', 5, 10, 3) north_face = room[1] door_verts = [ Point3D(2, 10, 0.1), Point3D(1, 10, 0.1), Point3D(1, 10, 2.5), Point3D(1.5, 10, 2.8), Point3D(2, 10, 2.5) ] door = Door('Front Door', Face3D(door_verts)) north_face.add_door(door) model = Model('Tiny House', [room]) triangulated_doors, parents_to_edit = model.triangulated_doors() assert len(triangulated_doors) == 1 assert len(parents_to_edit) == 1 assert len(triangulated_doors[0]) == 3 assert len(parents_to_edit[0]) == 3 parents_to_edit[0][0] == door.name parents_to_edit[0][1] == north_face.name for dr in triangulated_doors[0]: assert isinstance(dr, Door) assert len(dr.geometry) == 3
def test_sub_faces_invalid(): """Test the adding and removing of invalid sub-faces.""" face_face3d = Face3D.from_rectangle(10, 10, Plane(o=Point3D(0, 0, 3))) ap_face3d = Face3D.from_rectangle(2, 2, Plane(o=Point3D(2, 2, 3))) dr_face3d = Face3D.from_rectangle(2, 2, Plane(o=Point3D(7, 7, 3))) dr_face3d_invalid_1 = Face3D.from_rectangle(2, 2, Plane(o=Point3D(7, 7, 1))) dr_face3d_invalid_2 = \ Face3D([Point3D(0, 0, 0), Point3D(0, 1, 0), Point3D(0, 1, 3), Point3D(0, 0, 3)]) face = Face('Test_Roof', face_face3d) aperture = Aperture('Test_Skylight', ap_face3d) door = Door('Test_Trap_Door', dr_face3d) invalid_aperture_1 = Aperture('Test_Skylight', dr_face3d_invalid_1) invalid_aperture_2 = Aperture('Test_Skylight', dr_face3d_invalid_2) with pytest.raises(AssertionError): face.add_aperture(door) with pytest.raises(AssertionError): face.add_door(aperture) face.add_aperture(invalid_aperture_1) with pytest.raises(ValueError): face.check_apertures_valid(0.01, 1) face.remove_apertures() face.add_aperture(invalid_aperture_2) with pytest.raises(ValueError): face.check_apertures_valid(0.01, 1)
def model_complete_single_zone_office(directory): room = Room.from_box('Tiny_House_Office', 5, 10, 3) room.properties.energy.program_type = prog_type_lib.office_program room.properties.energy.add_default_ideal_air() stone = EnergyMaterial('Thick Stone', 0.3, 2.31, 2322, 832, 'Rough', 0.95, 0.75, 0.8) thermal_mass_constr = OpaqueConstruction('Thermal Mass Floor', [stone]) room[0].properties.energy.construction = thermal_mass_constr south_face = room[3] south_face.apertures_by_ratio(0.4, 0.01) south_face.apertures[0].overhang(0.5, indoor=False) south_face.apertures[0].overhang(0.5, indoor=True) south_face.move_shades(Vector3D(0, 0, -0.5)) light_shelf_out = ShadeConstruction('Outdoor_Light_Shelf', 0.5, 0.5) light_shelf_in = ShadeConstruction('Indoor_Light_Shelf', 0.7, 0.7) south_face.apertures[0].outdoor_shades[ 0].properties.energy.construction = light_shelf_out south_face.apertures[0].indoor_shades[ 0].properties.energy.construction = light_shelf_in north_face = room[1] north_face.overhang(0.25, indoor=False) door_verts = [ Point3D(2, 10, 0.1), Point3D(1, 10, 0.1), Point3D(1, 10, 2.5), Point3D(2, 10, 2.5) ] door = Door('Front_Door', Face3D(door_verts)) north_face.add_door(door) aperture_verts = [ Point3D(4.5, 10, 1), Point3D(2.5, 10, 1), Point3D(2.5, 10, 2.5), Point3D(4.5, 10, 2.5) ] aperture = Aperture('Front_Aperture', Face3D(aperture_verts)) triple_pane = WindowConstruction( 'Triple Pane Window', [clear_glass, air_gap, clear_glass, air_gap, clear_glass]) aperture.properties.energy.construction = triple_pane north_face.add_aperture(aperture) tree_canopy_geo = Face3D.from_regular_polygon( 6, 2, Plane(Vector3D(0, 0, 1), Point3D(5, -3, 4))) tree_canopy = Shade('Tree_Canopy', tree_canopy_geo) table_geo = Face3D.from_rectangle(2, 2, Plane(o=Point3D(1.5, 4, 1))) table = Shade('Table', table_geo) room.add_indoor_shade(table) model = Model('Tiny_House', [room], orphaned_shades=[tree_canopy]) dest_file = os.path.join(directory, 'model_complete_single_zone_office.json') with open(dest_file, 'w') as fp: json.dump(model.to_dict(), fp, indent=4)
def test_move(): """Test the Door move method.""" pts_1 = (Point3D(0, 0, 0), Point3D(2, 0, 0), Point3D(2, 2, 0), Point3D(0, 2, 0)) plane_1 = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 0)) door = Door('RectangleDoor', Face3D(pts_1, plane_1)) vec_1 = Vector3D(2, 2, 2) new_dr = door.duplicate() new_dr.move(vec_1) assert new_dr.geometry[0] == Point3D(2, 2, 2) assert new_dr.geometry[1] == Point3D(4, 2, 2) assert new_dr.geometry[2] == Point3D(4, 4, 2) assert new_dr.geometry[3] == Point3D(2, 4, 2) assert new_dr.normal == door.normal assert door.area == new_dr.area assert door.perimeter == new_dr.perimeter
def test_envelope_components_by_type(): zone_pts = Face3D([ Point3D(0, 0, 0), Point3D(20, 0, 0), Point3D(20, 10, 0), Point3D(0, 10, 0) ]) room = Room.from_polyface3d('SouthRoom', Polyface3D.from_offset_face(zone_pts, 3)) door_pts = [ Point3D(2, 10, 0.01), Point3D(4, 10, 0.01), Point3D(4, 10, 2.50), Point3D(2, 10, 2.50) ] door = Door('FrontDoor', Face3D(door_pts)) room[3].add_door(door) # Door to north face room[1].apertures_by_ratio(0.3) # Window on south face ext_faces, int_faces = room.properties.energy.envelope_components_by_type() walls, roofs, floors, apertures, doors = ext_faces assert len(walls) == 4 assert len(roofs) == 1 assert len(floors) == 0 assert len(apertures) == 1 assert len(doors) == 1 for types in int_faces: assert len(types) == 0
def model_5vertex_sub_faces(directory): room = Room.from_box('TinyHouseZone', 5, 10, 3) north_face = room[1] aperture_verts = [ Point3D(4.5, 10, 1), Point3D(2.5, 10, 1), Point3D(2.5, 10, 2.5), Point3D(3.5, 10, 2.9), Point3D(4.5, 10, 2.5) ] aperture = Aperture('FrontAperture', Face3D(aperture_verts)) north_face.add_aperture(aperture) door_verts = [ Point3D(2, 10, 0.1), Point3D(1, 10, 0.1), Point3D(1, 10, 2.5), Point3D(1.5, 10, 2.8), Point3D(2, 10, 2.5) ] door = Door('FrontDoor', Face3D(door_verts)) north_face.add_door(door) model = Model('TinyHouse', [room]) model_dict = model.to_dict() dest_file = os.path.join(directory, 'model_5vertex_sub_faces.json') with open(dest_file, 'w') as fp: json.dump(model_dict, fp, indent=4)
def test_model_init(): """Test the initialization of the Model and basic properties.""" room = Room.from_box('TinyHouseZone', 5, 10, 3) south_face = room[3] south_face.apertures_by_ratio(0.4, 0.01) south_face.apertures[0].overhang(0.5, indoor=False) south_face.apertures[0].overhang(0.5, indoor=True) south_face.apertures[0].move_shades(Vector3D(0, 0, -0.5)) north_face = room[1] door_verts = [ Point3D(2, 10, 0.1), Point3D(1, 10, 0.1), Point3D(1, 10, 2.5), Point3D(2, 10, 2.5) ] aperture_verts = [ Point3D(4.5, 10, 1), Point3D(2.5, 10, 1), Point3D(2.5, 10, 2.5), Point3D(4.5, 10, 2.5) ] door = Door('FrontDoor', Face3D(door_verts)) north_face.add_door(door) aperture = Aperture('FrontAperture', Face3D(aperture_verts)) north_face.add_aperture(aperture) model = Model('TinyHouse', [room]) str(model) # test the string representation of the object assert model.identifier == 'TinyHouse' assert model.display_name == 'TinyHouse' assert model.units == 'Meters' assert model.tolerance == 0.01 assert model.angle_tolerance == 1.0 assert len(model.rooms) == 1 assert isinstance(model.rooms[0], Room) assert len(model.faces) == 6 assert isinstance(model.faces[0], Face) assert len(model.apertures) == 2 assert isinstance(model.apertures[0], Aperture) assert len(model.doors) == 1 assert isinstance(model.doors[0], Door) assert len(model.indoor_shades) == 1 assert isinstance(model.indoor_shades[0], Shade) assert len(model.outdoor_shades) == 1 assert isinstance(model.outdoor_shades[0], Shade) assert len(model.orphaned_faces) == 0 assert len(model.orphaned_shades) == 0 assert len(model.orphaned_apertures) == 0 assert len(model.orphaned_doors) == 0 assert len(model.stories) == 0 assert model.volume == pytest.approx(150, rel=1e-3) assert model.floor_area == pytest.approx(50, rel=1e-3) assert model.exposed_area == pytest.approx(140, rel=1e-3) assert model.exterior_wall_area == pytest.approx(90, rel=1e-3) assert model.exterior_roof_area == pytest.approx(50, rel=1e-3) assert model.exterior_aperture_area == pytest.approx(9, rel=1e-3) assert model.exterior_wall_aperture_area == pytest.approx(9, rel=1e-3) assert model.exterior_skylight_aperture_area == 0
def test_check_duplicate_sub_face_names(): """Test the check_duplicate_sub_face_names method.""" room = Room.from_box('Tiny House Zone', 5, 10, 3) north_face = room[1] door_verts = [ Point3D(2, 10, 0.1), Point3D(1, 10, 0.1), Point3D(1, 10, 2.5), Point3D(2, 10, 2.5) ] aperture_verts = [ Point3D(4.5, 10, 1), Point3D(2.5, 10, 1), Point3D(2.5, 10, 2.5), Point3D(4.5, 10, 2.5) ] door = Door('Front Door', Face3D(door_verts)) north_face.add_door(door) aperture = Aperture('Front Door', Face3D(aperture_verts)) model = Model('Test House', [room]) assert model.check_duplicate_sub_face_names(False) north_face.add_aperture(aperture) assert not model.check_duplicate_sub_face_names(False) with pytest.raises(ValueError): model.check_duplicate_sub_face_names(True)
def test_check_duplicate_material_names(): """Test the check_duplicate_material_names method.""" room = Room.from_box('Tiny House Zone', 5, 10, 3) stone = EnergyMaterial('Stone', 0.3, 2.31, 2322, 832, 'Rough', 0.95, 0.75, 0.8) thin_stone = EnergyMaterial('Thin Stone', 0.05, 2.31, 2322, 832, 'Rough', 0.95, 0.75, 0.8) thermal_mass_constr = OpaqueConstruction('Custom Construction', [stone]) door_constr = OpaqueConstruction('Custom Door Construction', [thin_stone]) room[0].properties.energy.construction = thermal_mass_constr north_face = room[1] door_verts = [ Point3D(2, 10, 0.1), Point3D(1, 10, 0.1), Point3D(1, 10, 2.5), Point3D(2, 10, 2.5) ] door = Door('Front Door', Face3D(door_verts)) door.properties.energy.construction = door_constr north_face.add_door(door) model = Model('Tiny House', [room]) assert model.properties.energy.check_duplicate_material_names(False) thin_stone.unlock() thin_stone.name = 'Stone' thin_stone.lock() assert not model.properties.energy.check_duplicate_material_names(False) with pytest.raises(ValueError): model.properties.energy.check_duplicate_material_names(True)
def test_scale(): """Test the Model scale method.""" room = Room.from_box('Tiny House Zone', 5, 10, 3) south_face = room[3] south_face.apertures_by_ratio(0.4, 0.01) south_face.apertures[0].overhang(0.5, indoor=False) south_face.apertures[0].overhang(0.5, indoor=True) south_face.apertures[0].move_shades(Vector3D(0, 0, -0.5)) north_face = room[1] door_verts = [Point3D(2, 10, 0.1), Point3D(1, 10, 0.1), Point3D(1, 10, 2.5), Point3D(2, 10, 2.5)] aperture_verts = [Point3D(4.5, 10, 1), Point3D(2.5, 10, 1), Point3D(2.5, 10, 2.5), Point3D(4.5, 10, 2.5)] door = Door('Front Door', Face3D(door_verts)) north_face.add_door(door) aperture = Aperture('Front Aperture', Face3D(aperture_verts)) north_face.add_aperture(aperture) new_room = room.duplicate() model = Model('Tiny House', [new_room]) model.scale(0.5) assert room.floor_area == model.rooms[0].floor_area * 2 ** 2 assert room.volume == model.rooms[0].volume * 2 ** 3 assert south_face.apertures[0].indoor_shades[0].area == \ model.rooms[0][3].apertures[0].indoor_shades[0].area * 2 ** 2 assert south_face.apertures[0].outdoor_shades[0].area == \ model.rooms[0][3].apertures[0].outdoor_shades[0].area * 2 ** 2 assert room[3].apertures[0].area == model.rooms[0][3].apertures[0].area * 2 ** 2 assert room[1].doors[0].area == model.rooms[0][1].doors[0].area * 2 ** 2
def test_duplicate(): """Test what happens to radiance properties when duplicating a Door.""" verts = [ Point3D(0, 0, 0), Point3D(10, 0, 0), Point3D(10, 0, 10), Point3D(0, 0, 10) ] painted_door = Plastic.from_single_reflectance('PaintedDoor', 0.75) dr_original = Door.from_vertices('wall_door', Face3D(verts)) dr_dup_1 = dr_original.duplicate() assert dr_original.properties.radiance.host is dr_original assert dr_dup_1.properties.radiance.host is dr_dup_1 assert dr_original.properties.radiance.host is not dr_dup_1.properties.radiance.host assert dr_original.properties.radiance.modifier == \ dr_dup_1.properties.radiance.modifier dr_dup_1.properties.radiance.modifier = painted_door assert dr_original.properties.radiance.modifier != \ dr_dup_1.properties.radiance.modifier dr_dup_2 = dr_dup_1.duplicate() assert dr_dup_1.properties.radiance.modifier == \ dr_dup_2.properties.radiance.modifier dr_dup_2.properties.radiance.modifier = None assert dr_dup_1.properties.radiance.modifier != \ dr_dup_2.properties.radiance.modifier
def test_writer_to_rad(): """Test the Model to.rad method.""" room = Room.from_box('Tiny_House_Zone', 5, 10, 3) dark_floor = Plastic.from_single_reflectance('DarkFloor', 0.1) room[0].properties.radiance.modifier = dark_floor south_face = room[3] south_face.apertures_by_ratio(0.4, 0.01) south_face.apertures[0].overhang(0.5, indoor=False) south_face.apertures[0].overhang(0.5, indoor=True) south_face.move_shades(Vector3D(0, 0, -0.5)) light_shelf_out = Plastic.from_single_reflectance( 'outdoor_light_shelf_0.5', 0.5) light_shelf_in = Plastic.from_single_reflectance('indoor_light_shelf_0.70', 0.7) south_face.apertures[0].outdoor_shades[ 0].properties.radiance.modifier = light_shelf_out south_face.apertures[0].indoor_shades[ 0].properties.radiance.modifier = light_shelf_in north_face = room[1] north_face.overhang(0.25, indoor=False) door_verts = [ Point3D(2, 10, 0.1), Point3D(1, 10, 0.1), Point3D(1, 10, 2.5), Point3D(2, 10, 2.5) ] door = Door('Front_Door', Face3D(door_verts)) north_face.add_door(door) aperture_verts = [ Point3D(4.5, 10, 1), Point3D(2.5, 10, 1), Point3D(2.5, 10, 2.5), Point3D(4.5, 10, 2.5) ] aperture = Aperture('Front_Aperture', Face3D(aperture_verts)) triple_pane = Glass.from_single_transmittance('custom_triple_pane_0.3', 0.3) aperture.properties.radiance.modifier = triple_pane north_face.add_aperture(aperture) tree_canopy_geo = Face3D.from_regular_polygon( 6, 2, Plane(Vector3D(0, 0, 1), Point3D(5, -3, 4))) tree_canopy = Shade('Tree_Canopy', tree_canopy_geo) table_geo = Face3D.from_rectangle(2, 2, Plane(o=Point3D(1.5, 4, 1))) table = Shade('Table', table_geo) room.add_indoor_shade(table) model = Model('Tiny_House', [room], orphaned_shades=[tree_canopy]) assert hasattr(model.to, 'rad') rad_string = model.to.rad(model) assert len(rad_string) == 2 assert 'outdoor_light_shelf_0.5' in rad_string[1] assert 'Front_Door' in rad_string[0]
def test_to_dict_single_zone(): """Test the Model to_dict method with a single zone model.""" room = Room.from_box('Tiny_House_Zone', 5, 10, 3) dark_floor = Plastic.from_single_reflectance('DarkFloor', 0.1) room[0].properties.radiance.modifier = dark_floor south_face = room[3] south_face.apertures_by_ratio(0.4, 0.01) south_face.apertures[0].overhang(0.5, indoor=False) south_face.apertures[0].overhang(0.5, indoor=True) south_face.move_shades(Vector3D(0, 0, -0.5)) light_shelf_out = Plastic.from_single_reflectance('OutdoorLightShelf', 0.5) light_shelf_in = Plastic.from_single_reflectance('IndoorLightShelf', 0.7) south_face.apertures[0].outdoor_shades[0].properties.radiance.modifier = light_shelf_out south_face.apertures[0].indoor_shades[0].properties.radiance.modifier = light_shelf_in north_face = room[1] north_face.overhang(0.25, indoor=False) door_verts = [Point3D(2, 10, 0.1), Point3D(1, 10, 0.1), Point3D(1, 10, 2.5), Point3D(2, 10, 2.5)] door = Door('Front_Door', Face3D(door_verts)) north_face.add_door(door) aperture_verts = [Point3D(4.5, 10, 1), Point3D(2.5, 10, 1), Point3D(2.5, 10, 2.5), Point3D(4.5, 10, 2.5)] aperture = Aperture('Front_Aperture', Face3D(aperture_verts)) triple_pane = Glass.from_single_transmittance('CustomTriplePane', 0.3) aperture.properties.radiance.modifier = triple_pane north_face.add_aperture(aperture) tree_canopy_geo = Face3D.from_regular_polygon( 6, 2, Plane(Vector3D(0, 0, 1), Point3D(5, -3, 4))) tree_canopy = Shade('Tree_Canopy', tree_canopy_geo) table_geo = Face3D.from_rectangle(2, 2, Plane(o=Point3D(1.5, 4, 1))) table = Shade('Table', table_geo) room.add_indoor_shade(table) model = Model('Tiny_House', [room], orphaned_shades=[tree_canopy]) model_dict = model.to_dict() assert 'radiance' in model_dict['properties'] assert 'modifiers' in model_dict['properties']['radiance'] assert 'modifier_sets' in model_dict['properties']['radiance'] assert len(model_dict['properties']['radiance']['modifiers']) == 5 assert len(model_dict['properties']['radiance']['modifier_sets']) == 0 assert model_dict['rooms'][0]['faces'][0]['properties']['radiance']['modifier'] == \ dark_floor.identifier south_ap_dict = model_dict['rooms'][0]['faces'][3]['apertures'][0] assert south_ap_dict['outdoor_shades'][0]['properties']['radiance']['modifier'] == \ light_shelf_out.identifier assert south_ap_dict['indoor_shades'][0]['properties']['radiance']['modifier'] == \ light_shelf_in.identifier assert model_dict['rooms'][0]['faces'][1]['apertures'][0]['properties']['radiance']['modifier'] == \ triple_pane.identifier
def test_energy_properties(): """Test the existence of the Door energy properties.""" door = Door.from_vertices('wall door', [[0, 0, 0], [1, 0, 0], [1, 0, 3], [0, 0, 3]]) assert hasattr(door.properties, 'energy') assert isinstance(door.properties.energy, DoorEnergyProperties) assert isinstance(door.properties.energy.construction, OpaqueConstruction) assert not door.properties.energy.is_construction_set_by_user
def test_writer(): """Test the Door writer object.""" vertices = [[0, 0, 0], [0, 10, 0], [0, 10, 3], [0, 0, 3]] door = Door.from_vertices('RectangleDoor', vertices) writers = [mod for mod in dir(door.to) if not mod.startswith('_')] for writer in writers: assert callable(getattr(door.to, writer))
def test_to_from_dict(): """Test the Model to_dict and from_dict method with a single zone model.""" room = Room.from_box('Tiny_House_Room', 5, 10, 3) dark_floor = Plastic.from_single_reflectance('DarkFloor', 0.1) room[0].properties.radiance.modifier = dark_floor south_face = room[3] south_face.apertures_by_ratio(0.4, 0.01) south_face.apertures[0].overhang(0.5, indoor=False) south_face.apertures[0].overhang(0.5, indoor=True) south_face.apertures[0].move_shades(Vector3D(0, 0, -0.5)) light_shelf_out = Plastic.from_single_reflectance('OutdoorLightShelf', 0.5) light_shelf_in = Plastic.from_single_reflectance('IndoorLightShelf', 0.7) south_face.apertures[0].shades[0].properties.radiance.modifier = light_shelf_out south_face.apertures[0].shades[1].properties.radiance.modifier = light_shelf_in north_face = room[1] door_verts = [Point3D(2, 10, 0.1), Point3D(1, 10, 0.1), Point3D(1, 10, 2.5), Point3D(2, 10, 2.5)] door = Door('FrontDoor', Face3D(door_verts)) north_face.add_door(door) aperture_verts = [Point3D(4.5, 10, 1), Point3D(2.5, 10, 1), Point3D(2.5, 10, 2.5), Point3D(4.5, 10, 2.5)] aperture = Aperture('FrontAperture', Face3D(aperture_verts)) aperture.is_operable = True triple_pane = Glass.from_single_transmittance('CustomTriplePane', 0.3) aperture.properties.radiance.modifier = triple_pane north_face.add_aperture(aperture) tree_canopy_geo = Face3D.from_regular_polygon( 6, 2, Plane(Vector3D(0, 0, 1), Point3D(5, -3, 4))) tree_canopy = Shade('TreeCanopy', tree_canopy_geo) tree_trans = Glass.from_single_transmittance('TreeTransmittance', 0.75) tree_canopy.properties.radiance.modifier = tree_trans model = Model('TinyHouse', [room], orphaned_shades=[tree_canopy]) model_dict = model.to_dict(included_prop=['radiance']) new_model = Model.from_dict(model_dict) assert model_dict == new_model.to_dict(included_prop=['radiance']) assert dark_floor in new_model.properties.radiance.modifiers assert new_model.rooms[0][0].properties.radiance.modifier == dark_floor assert new_model.rooms[0][3].apertures[0].indoor_shades[0].properties.radiance.modifier == light_shelf_in assert new_model.rooms[0][3].apertures[0].outdoor_shades[0].properties.radiance.modifier == light_shelf_out assert triple_pane in new_model.properties.radiance.modifiers assert new_model.rooms[0][1].apertures[0].properties.radiance.modifier == triple_pane assert new_model.rooms[0][1].apertures[0].is_operable assert len(new_model.orphaned_shades) == 1 assert new_model.rooms[0][0].type == face_types.floor assert new_model.rooms[0][1].type == face_types.wall assert isinstance(new_model.rooms[0][0].boundary_condition, Ground) assert isinstance(new_model.rooms[0][1].boundary_condition, Outdoors) assert new_model.orphaned_shades[0].properties.radiance.modifier == tree_trans
def test_radiance_properties(): """Test the existence of the Door radiance properties.""" door = Door.from_vertices('wall_door', [[0, 0, 0], [10, 0, 0], [10, 0, 10], [0, 0, 10]]) assert hasattr(door.properties, 'radiance') assert isinstance(door.properties.radiance, DoorRadianceProperties) assert door.properties.radiance.modifier == generic_door assert door.properties.radiance.modifier_blk == black assert not door.properties.radiance.is_modifier_set_on_object