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, 10, 0], [10, 10, 0], [10, 0, 0]] vertices_roof = [[10, 0, 3], [10, 10, 3], [0, 10, 3], [0, 0, 3]] wf = Face.from_vertices('wall face', vertices_parent_wall) wa = Aperture.from_vertices('wall window', vertices_wall) wf.add_aperture(wa) Room('Test Room 1', [wf]) assert wa.properties.energy.construction.name == 'Generic Double Pane' wf2 = Face.from_vertices('wall face2', vertices_parent_wall_2) wa2 = Aperture.from_vertices('wall window2', vertices_wall_2) wf2.add_aperture(wa2) Room('Test Room 2', [wf2]) wa.set_adjacency(wa2) assert wa.properties.energy.construction.name == 'Generic Single Pane' ra = Aperture.from_vertices('roof window', vertices_roof) assert ra.properties.energy.construction.name == 'Generic Double Pane' fa = Aperture.from_vertices('floor window', vertices_floor) assert fa.properties.energy.construction.name == 'Generic Double Pane'
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_default_modifiers(): """Test the auto-assigning of modifiers by face type and 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, 10, 0], [10, 10, 0], [10, 0, 0]] vertices_roof = [[10, 0, 3], [10, 10, 3], [0, 10, 3], [0, 0, 3]] wf = Face.from_vertices('wall_face', vertices_parent_wall) wa = Aperture.from_vertices('wall_window', vertices_wall) wf.add_aperture(wa) Room('TestRoom1', [wf]) assert wa.properties.radiance.modifier == generic_exterior_window wf2 = Face.from_vertices('wall_face2', vertices_parent_wall_2) wa2 = Aperture.from_vertices('wall_window2', vertices_wall_2) wf2.add_aperture(wa2) Room('TestRoom2', [wf2]) wa.set_adjacency(wa2) assert wa.properties.radiance.modifier == generic_interior_window ra = Aperture.from_vertices('roof_window', vertices_roof) assert ra.properties.radiance.modifier == generic_exterior_window fa = Aperture.from_vertices('floor_window', vertices_floor) assert fa.properties.radiance.modifier == generic_exterior_window
def test_duplicate(): """Test what happens to energy properties when duplicating a Face.""" verts = [ Point3D(0, 0, 0), Point3D(10, 0, 0), Point3D(10, 0, 10), Point3D(0, 0, 10) ] concrete20 = EnergyMaterial('20cm Concrete', 0.2, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) thick_constr = OpaqueConstruction('Thick Concrete Construction', [concrete20]) face_original = Face('wall_face', Face3D(verts)) face_dup_1 = face_original.duplicate() assert face_original.properties.energy.host is face_original assert face_dup_1.properties.energy.host is face_dup_1 assert face_original.properties.energy.host is not face_dup_1.properties.energy.host assert face_original.properties.energy.construction == \ face_dup_1.properties.energy.construction face_dup_1.properties.energy.construction = thick_constr assert face_original.properties.energy.construction != \ face_dup_1.properties.energy.construction face_dup_2 = face_dup_1.duplicate() assert face_dup_1.properties.energy.construction == \ face_dup_2.properties.energy.construction face_dup_2.properties.energy.construction = None assert face_dup_1.properties.energy.construction != \ face_dup_2.properties.energy.construction
def test_rotate(): """Test the Face 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)) face = Face('Rectangle Face', Face3D(pts, plane)) origin = Point3D(0, 0, 0) axis = Vector3D(1, 0, 0) test_1 = face.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 face.area == test_1.area assert len(face.vertices) == len(test_1.vertices) test_2 = face.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 face.area == test_2.area assert len(face.vertices) == len(test_2.vertices)
def test_rotate_xy(): """Test the Face 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)) face = Face('Rectangle Face', Face3D(pts, plane)) origin_1 = Point3D(1, 1, 0) test_1 = face.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 = face.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_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 model_complete_multiroom_radiance(directory): triple_pane = Glass.from_single_transmittance('Triple_Pane_0.35', 0.35) first_floor = Room.from_box('First_Floor', 10, 10, 3, origin=Point3D(0, 0, 0)) second_floor = Room.from_box('Second_Floor', 10, 10, 3, origin=Point3D(0, 0, 3)) for face in first_floor[1:5]: face.apertures_by_ratio(0.2, 0.01) face.apertures[0].properties.radiance.modifier = triple_pane for face in second_floor[1:5]: face.apertures_by_ratio(0.2, 0.01) pts_1 = [Point3D(0, 0, 6), Point3D(0, 10, 6), Point3D(10, 10, 6), Point3D(10, 0, 6)] pts_2 = [Point3D(0, 0, 6), Point3D(5, 0, 9), Point3D(5, 10, 9), Point3D(0, 10, 6)] pts_3 = [Point3D(10, 0, 6), Point3D(10, 10, 6), Point3D(5, 10, 9), Point3D(5, 0, 9)] pts_4 = [Point3D(0, 0, 6), Point3D(10, 0, 6), Point3D(5, 0, 9)] pts_5 = [Point3D(10, 10, 6), Point3D(0, 10, 6), Point3D(5, 10, 9)] face_1 = Face('AtticFace1', Face3D(pts_1)) face_2 = Face('AtticFace2', Face3D(pts_2)) face_3 = Face('AtticFace3', Face3D(pts_3)) face_4 = Face('AtticFace4', Face3D(pts_4)) face_5 = Face('AtticFace5', Face3D(pts_5)) attic = Room('Attic', [face_1, face_2, face_3, face_4, face_5], 0.01, 1) mod_set = ModifierSet('Attic_Modifier_Set') polyiso = Plastic.from_single_reflectance('PolyIso', 0.45) mod_set.roof_ceiling_set.exterior_modifier = polyiso attic.properties.radiance.modifier_set = mod_set Room.solve_adjacency([first_floor, second_floor, attic], 0.01) model = Model('Multi_Room_Radiance_House', [first_floor, second_floor, attic]) dest_file = os.path.join(directory, 'model_complete_multiroom_radiance.json') with open(dest_file, 'w') as fp: json.dump(model.to_dict(), fp, indent=4)
def test_assign_stories_by_floor_height(): """Test the Model assign_stories_by_floor_height method.""" first_floor = Room.from_box('First_Floor', 10, 10, 3, origin=Point3D(0, 0, 0)) second_floor = Room.from_box('Second_Floor', 10, 10, 3, origin=Point3D(0, 0, 3)) for face in first_floor[1:5]: face.apertures_by_ratio(0.2, 0.01) for face in second_floor[1:5]: face.apertures_by_ratio(0.2, 0.01) pts_1 = [ Point3D(0, 0, 6), Point3D(0, 10, 6), Point3D(10, 10, 6), Point3D(10, 0, 6) ] pts_2 = [ Point3D(0, 0, 6), Point3D(5, 0, 9), Point3D(5, 10, 9), Point3D(0, 10, 6) ] pts_3 = [ Point3D(10, 0, 6), Point3D(10, 10, 6), Point3D(5, 10, 9), Point3D(5, 0, 9) ] pts_4 = [Point3D(0, 0, 6), Point3D(10, 0, 6), Point3D(5, 0, 9)] pts_5 = [Point3D(10, 10, 6), Point3D(0, 10, 6), Point3D(5, 10, 9)] face_1 = Face('AtticFace1', Face3D(pts_1)) face_2 = Face('AtticFace2', Face3D(pts_2)) face_3 = Face('AtticFace3', Face3D(pts_3)) face_4 = Face('AtticFace4', Face3D(pts_4)) face_5 = Face('AtticFace5', Face3D(pts_5)) attic = Room('Attic', [face_1, face_2, face_3, face_4, face_5], 0.01, 1) Room.solve_adjacency([first_floor, second_floor, attic], 0.01) model = Model('MultiZoneSingleFamilyHouse', [first_floor, second_floor, attic]) assert len(model.stories) == 0 model.assign_stories_by_floor_height(2.0) assert len(model.stories) == 3 assert first_floor.story == 'Floor1' assert second_floor.story == 'Floor2' assert attic.story == 'Floor3' model.assign_stories_by_floor_height(4.0, overwrite=True) assert len(model.stories) == 2 assert first_floor.story == second_floor.story == 'Floor1' assert attic.story == 'Floor2'
def test_apertures_by_width_height(): """Test the adding of apertures by width and height.""" pts = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(5, 0, 3), Point3D(5, 0, 0)) face = Face('Test_Wall', Face3D(pts)) face.aperture_by_width_height(4, 2, 0.7) assert len(face.apertures) == 1 assert len(face.apertures[0].geometry.vertices) == 4 assert face.apertures[0].area == pytest.approx(8, rel=1e-2)
def test_to_from_dict(): """Test the to/from dict of Face objects.""" vertices = [[0, 0, 0], [0, 10, 0], [0, 10, 3], [0, 0, 3]] face = Face.from_vertices('testwall', vertices, face_types.wall, boundary_conditions.ground) face_dict = face.to_dict() new_face = Face.from_dict(face_dict) assert isinstance(new_face, Face) assert new_face.to_dict() == face_dict
def test_face_louvers_by_distance_between(): """Test the creation of a louvers_by_distance_between for Face objects.""" pts_1 = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(5, 0, 3), Point3D(5, 0, 0)) face = Face('Rectangle Face', Face3D(pts_1)) face.louvers_by_distance_between(0.5, 0.2, 0.1) assert len(face.outdoor_shades) == 6 for louver in face.outdoor_shades: assert isinstance(louver, Shade) assert louver.area == 5 * 0.2
def test_from_dict(): """Test the Face from_dict method with radiance properties.""" face = Face.from_vertices( 'wall_face', [[0, 0, 0], [10, 0, 0], [10, 0, 10], [0, 0, 10]]) concrete = Plastic.from_single_reflectance('035Concrete', 0.35) face.properties.radiance.modifier = concrete fd = face.to_dict() new_face = Face.from_dict(fd) assert new_face.properties.radiance.modifier == concrete assert new_face.to_dict() == fd
def test_apertures_by_ratio(): """Test the adding of apertures by ratio.""" pts = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(5, 0, 3), Point3D(5, 0, 0)) face = Face('Test_Wall', Face3D(pts)) face.apertures_by_ratio(0.4, 0.01) assert len(face.apertures) == 1 assert len(face.apertures[0].geometry.vertices) == 4 assert sum([ap.area for ap in face.apertures]) == pytest.approx(15 * 0.4, rel=1e-2) assert face.punched_geometry.area == pytest.approx(15 * 0.6, rel=1e-2)
def test_face_louvers_by_count(): """Test the creation of a louvers_by_count for Face objects.""" pts_1 = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(5, 0, 3), Point3D(5, 0, 0)) face = Face('RectangleFace', Face3D(pts_1)) face.louvers_by_count(3, 0.2, 0.1, 5) assert len(face.outdoor_shades) == 3 for louver in face.outdoor_shades: assert isinstance(louver, Shade) assert louver.area == 5 * 0.2 assert louver.has_parent
def test_apertures_by_width_height_rectangle(): """Test the adding of apertures by width/height.""" pts = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(10, 0, 3), Point3D(10, 0, 0)) face = Face('Test_Wall', Face3D(pts)) face.apertures_by_width_height_rectangle(2, 2, 0.5, 2.5, 0.01) assert len(face.apertures) == 4 assert all(len(ap.geometry.vertices) == 4 for ap in face.apertures) assert sum([ap.area for ap in face.apertures]) == pytest.approx(16, rel=1e-2) assert face.punched_geometry.area == pytest.approx(30 - 16, rel=1e-2)
def test_default_modifiers(): """Test the auto-assigning of modifiers by face type and boundary condition.""" vertices_wall = [[0, 0, 0], [0, 10, 0], [0, 10, 3], [0, 0, 3]] vertices_floor = [[0, 0, 0], [0, 10, 0], [10, 10, 0], [10, 0, 0]] vertices_roof = [[10, 0, 3], [10, 10, 3], [0, 10, 3], [0, 0, 3]] wf = Face.from_vertices('wall', vertices_wall) assert wf.properties.radiance.modifier == generic_wall rf = Face.from_vertices('roof', vertices_roof) assert rf.properties.radiance.modifier == generic_ceiling ff = Face.from_vertices('floor', vertices_floor) assert ff.properties.radiance.modifier == generic_floor
def test_default_face_type(): """Test the auto-assigning of face type by normal.""" vertices_wall = [[0, 0, 0], [0, 10, 0], [0, 10, 3], [0, 0, 3]] vertices_floor = [[0, 0, 0], [0, 10, 0], [10, 10, 0], [10, 0, 0]] vertices_roof = list(reversed(vertices_floor)) wf = Face.from_vertices('wall', vertices_wall) assert wf.type == wf.TYPES.wall rf = Face.from_vertices('roof', vertices_roof) assert rf.type == rf.TYPES.roof_ceiling ff = Face.from_vertices('floor', vertices_floor) assert ff.type == ff.TYPES.floor
def test_default_constructions(): """Test the auto-assigning of constructions by face type and boundary condition.""" vertices_wall = [[0, 0, 0], [0, 10, 0], [0, 10, 3], [0, 0, 3]] vertices_floor = [[0, 0, 0], [0, 10, 0], [10, 10, 0], [10, 0, 0]] vertices_roof = [[10, 0, 3], [10, 10, 3], [0, 10, 3], [0, 0, 3]] wf = Face.from_vertices('wall', vertices_wall) assert wf.properties.energy.construction.identifier == 'Generic Exterior Wall' rf = Face.from_vertices('roof', vertices_roof) assert rf.properties.energy.construction.identifier == 'Generic Roof' ff = Face.from_vertices('floor', vertices_floor) assert ff.properties.energy.construction.identifier == 'Generic Ground Slab'
def test_setting_face_type(): """Test the setting of face type to override default.""" vertices = [ Point3D(0, 0, 0), Point3D(0, 10, 0), Point3D(0, 10, 3), Point3D(0, 0, 3) ] face = Face('Vertical Roof', Face3D(vertices), face_types.roof_ceiling) assert face.type == face_types.roof_ceiling face.type = face_types.wall assert face.type == face_types.wall
def test_from_dict(): """Test the Face from_dict method with energy properties.""" face = Face.from_vertices( 'wall_face', [[0, 0, 0], [10, 0, 0], [10, 0, 10], [0, 0, 10]]) concrete20 = EnergyMaterial('20cm Concrete', 0.2, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) thick_constr = OpaqueConstruction('Thick Concrete Construction', [concrete20]) face.properties.energy.construction = thick_constr fd = face.to_dict() new_face = Face.from_dict(fd) assert new_face.properties.energy.construction == thick_constr assert new_face.to_dict() == fd
def test_set_boundary_condition(): """Test the setting of boundary condition to override default.""" vertices = [ Point3D(0, 0, 0), Point3D(0, 10, 0), Point3D(0, 10, 3), Point3D(0, 0, 3) ] face = Face('Wall', Face3D(vertices), face_types.wall, boundary_conditions.ground) assert face.boundary_condition == boundary_conditions.ground face.boundary_condition = boundary_conditions.outdoors assert face.boundary_condition == boundary_conditions.outdoors
def test_check_self_intersecting(): """Test the check_self_intersecting method.""" pts_1 = [Point3D(0, 0, 0), Point3D(0, 10, 0), Point3D(10, 10, 0), Point3D(10, 0, 0)] pts_2 = [Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(0, 10, 3), Point3D(0, 10, 0)] pts_3 = [Point3D(0, 0, 0), Point3D(10, 0, 0), Point3D(10, 0, 3), Point3D(0, 0, 3)] pts_4 = [Point3D(10, 10, 0), Point3D(0, 10, 0), Point3D(0, 10, 3), Point3D(10, 10, 3)] pts_5 = [Point3D(10, 10, 0), Point3D(10, 0, 0), Point3D(10, 0, 3), Point3D(10, 10, 3)] pts_6 = [Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(0, 10, 3), Point3D(0, 0, 3)] pts_7 = [Point3D(10, 0, 3), Point3D(0, 5, 3), Point3D(10, 10, 3), Point3D(0, 0, 3)] pts_8 = [Point3D(0, 5, 3), Point3D(10, 10, 3), Point3D(10, 0, 3)] face_1 = Face('Face1', Face3D(pts_1)) face_2 = Face('Face2', Face3D(pts_2)) face_3 = Face('Face3', Face3D(pts_3)) face_4 = Face('Face4', Face3D(pts_4)) face_5 = Face('Face5', Face3D(pts_5)) face_6 = Face('Face6', Face3D(pts_6)) face_7 = Face('Face7', Face3D(pts_7)) face_8 = Face('Face8', Face3D(pts_8)) room_1 = Room('ZoneSHOE_BOX920980', [face_1, face_2, face_3, face_4, face_5, face_6], 0.01, 1) room_2 = Room('ZoneSHOE_BOX920980', [face_1, face_2, face_3, face_4, face_5, face_7, face_8], 0.01, 1) assert room_1.check_self_intersecting(False) == '' assert room_2.check_self_intersecting(False) != ''
def test_color_face(): """Test ColorFace.""" pts_1 = [Point3D(0, 0, 0), Point3D(0, 10, 0), Point3D(10, 10, 0), Point3D(10, 0, 0)] pts_2 = [Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(0, 10, 3), Point3D(0, 10, 0)] pts_3 = [Point3D(0, 0, 0), Point3D(10, 0, 0), Point3D(10, 0, 3), Point3D(0, 0, 3)] pts_4 = [Point3D(10, 10, 0), Point3D(0, 10, 0), Point3D(0, 10, 3), Point3D(10, 10, 3)] pts_5 = [Point3D(10, 10, 0), Point3D(10, 0, 0), Point3D(10, 0, 3), Point3D(10, 10, 3)] pts_6 = [Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(0, 10, 3), Point3D(0, 0, 3)] face_1 = Face('Face1', Face3D(pts_1)) face_2 = Face('Face2', Face3D(pts_2)) face_3 = Face('Face3', Face3D(pts_3)) face_4 = Face('Face4', Face3D(pts_4)) face_5 = Face('Face5', Face3D(pts_5)) face_6 = Face('Face6', Face3D(pts_6)) face_2.apertures_by_ratio(0.4, 0.01) face_2.apertures[0].overhang(0.5, indoor=False) face_2.apertures[0].overhang(0.5, indoor=True) face_2.apertures[0].move_shades(Vector3D(0, 0, -0.5)) 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, 5, 1), Point3D(2.5, 5, 1), Point3D(2.5, 5, 2.5), Point3D(4.5, 5, 2.5)] door = Door('FrontDoor', Face3D(door_verts)) aperture = Aperture('Partition', Face3D(aperture_verts)) table_geo = Face3D.from_rectangle(2, 2, Plane(o=Point3D(1.5, 4, 1))) table = Shade('Table', table_geo) tree_canopy_geo = Face3D.from_regular_polygon(6, 2, Plane(o=Point3D(5, -3, 4))) tree_canopy = Shade('TreeCanopy', tree_canopy_geo) all_geo = [face_1, face_2, face_3, face_4, face_5, face_6, table, tree_canopy, aperture, door] color_face1 = ColorFace(all_geo, 'display_name') color_face2 = ColorFace(all_geo, 'boundary_condition') assert len(color_face1.faces) == len(color_face2.faces) == len(all_geo) assert len(color_face1.flat_faces) == len(color_face2.flat_faces) == len(all_geo) + 3 assert color_face1.flat_geometry[1].has_holes # ensure punched geometry is used assert color_face1.attr_name == color_face1.attr_name_end == 'display_name' assert color_face2.attr_name == color_face2.attr_name_end == 'boundary_condition' assert color_face1.attributes == \ ('Face1', 'Face2', 'Face2_Glz0', 'Face2_Glz0_OutOverhang0', 'Face2_Glz0_InOverhang0', 'Face3', 'Face4', 'Face5', 'Face6', 'Table', 'TreeCanopy', 'Partition', 'FrontDoor') assert color_face2.attributes == \ ('Ground', 'Outdoors', 'Outdoors', 'N/A', 'N/A', 'Outdoors', 'Outdoors', 'Outdoors', 'Outdoors', 'N/A', 'N/A', 'Outdoors', 'Outdoors') assert isinstance(color_face1.graphic_container, GraphicContainer) assert len(color_face1.attributes_unique) == \ len(color_face1.graphic_container.legend.segment_colors) == \ len(color_face1.attributes) assert len(color_face2.attributes_unique) == \ len(color_face2.graphic_container.legend.segment_colors) == 3 assert isinstance(color_face1.min_point, Point3D) assert isinstance(color_face1.max_point, Point3D)
def test_apertures_by_ratio_rectangle(): """Test the adding of apertures by ratio with rectangle apertures.""" pts = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(5, 0, 3), Point3D(5, 0, 0)) face = Face('Test_Wall', Face3D(pts)) face.apertures_by_ratio_rectangle(0.4, 2, 0.7, 1.5, 0, 0.01) assert len(face.apertures) == 3 assert len(face.apertures[0].geometry.vertices) == 4 assert sum([ap.area for ap in face.apertures]) == pytest.approx(15 * 0.4, rel=1e-2) assert face.punched_geometry.area == pytest.approx(15 * 0.6, rel=1e-2) assert face.apertures[0].geometry.min.z == 0.7 assert face.apertures[0].geometry.max.z - face.apertures[ 0].geometry.min.z == 2
def test_default_boundary_condition(): """Test the auto-assigning of face boundary condition by normal.""" vertices_above = \ [Point3D(0, 0, 0), Point3D(0, 10, 0), Point3D(0, 10, 3), Point3D(0, 0, 3)] vertices_mid = \ [Point3D(0, 0, -1), Point3D(0, 10, -1), Point3D(0, 10, 3), Point3D(0, 0, 3)] vertices_below = \ [Point3D(0, 0, -3), Point3D(0, 10, -3), Point3D(0, 10, 0), Point3D(0, 0, 0)] face_above = Face('Wall Above', Face3D(vertices_above)) face_mid = Face('Wall Mid', Face3D(vertices_mid)) face_below = Face('Wall Below', Face3D(vertices_below)) assert face_above.boundary_condition == boundary_conditions.outdoors assert face_mid.boundary_condition == boundary_conditions.outdoors assert face_below.boundary_condition == boundary_conditions.ground
def test_scale(): """Test the Face 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)) face = Face('Rectangle Face', Face3D(pts, plane)) new_f = face.duplicate() new_f.scale(2) assert new_f.geometry[0] == Point3D(2, 2, 4) assert new_f.geometry[1] == Point3D(4, 2, 4) assert new_f.geometry[2] == Point3D(4, 4, 4) assert new_f.geometry[3] == Point3D(2, 4, 4) assert new_f.area == face.area * 2**2 assert new_f.perimeter == face.perimeter * 2 assert new_f.normal == face.normal
def test_writer_to_idf(): """Test the Face to_idf method.""" face = Face.from_vertices( 'wall_face', [[0, 0, 0], [10, 0, 0], [10, 0, 10], [0, 0, 10]]) assert hasattr(face.to, 'idf') idf_string = face.to.idf(face) assert 'wall_face,' in idf_string assert 'BuildingSurface:Detailed,' in idf_string
def test_from_dict_non_abridged(): """Test the Model from_dict method with non-abridged objects.""" first_floor = Room.from_box('FirstFloor', 10, 10, 3, origin=Point3D(0, 0, 0)) second_floor = Room.from_box('SecondFloor', 10, 10, 3, origin=Point3D(0, 0, 3)) first_floor.properties.energy.program_type = office_program second_floor.properties.energy.program_type = office_program first_floor.properties.energy.add_default_ideal_air() second_floor.properties.energy.add_default_ideal_air() for face in first_floor[1:5]: face.apertures_by_ratio(0.2, 0.01) for face in second_floor[1:5]: face.apertures_by_ratio(0.2, 0.01) pts_1 = [Point3D(0, 0, 6), Point3D(0, 10, 6), Point3D(10, 10, 6), Point3D(10, 0, 6)] pts_2 = [Point3D(0, 0, 6), Point3D(5, 0, 9), Point3D(5, 10, 9), Point3D(0, 10, 6)] pts_3 = [Point3D(10, 0, 6), Point3D(10, 10, 6), Point3D(5, 10, 9), Point3D(5, 0, 9)] pts_4 = [Point3D(0, 0, 6), Point3D(10, 0, 6), Point3D(5, 0, 9)] pts_5 = [Point3D(10, 10, 6), Point3D(0, 10, 6), Point3D(5, 10, 9)] face_1 = Face('AtticFace1', Face3D(pts_1)) face_2 = Face('AtticFace2', Face3D(pts_2)) face_3 = Face('AtticFace3', Face3D(pts_3)) face_4 = Face('AtticFace4', Face3D(pts_4)) face_5 = Face('AtticFace5', Face3D(pts_5)) attic = Room('Attic', [face_1, face_2, face_3, face_4, face_5], 0.01, 1) constr_set = ConstructionSet('Attic Construction Set') polyiso = EnergyMaterial('PolyIso', 0.2, 0.03, 43, 1210, 'MediumRough') roof_constr = OpaqueConstruction('Attic Roof Construction', [roof_membrane, polyiso, wood]) floor_constr = OpaqueConstruction('Attic Floor Construction', [wood, insulation, wood]) constr_set.floor_set.interior_construction = floor_constr constr_set.roof_ceiling_set.exterior_construction = roof_constr attic.properties.energy.construction_set = constr_set Room.solve_adjacency([first_floor, second_floor, attic], 0.01) model = Model('MultiZoneSingleFamilyHouse', [first_floor, second_floor, attic]) model_dict = model.to_dict() model_dict['properties']['energy']['program_types'][0] = office_program.to_dict() model_dict['properties']['energy']['construction_sets'][0] = constr_set.to_dict() rebuilt_model = Model.from_dict(model_dict) assert rebuilt_model.rooms[0].properties.energy.program_type == office_program assert rebuilt_model.rooms[2].properties.energy.construction_set == constr_set
def test_move(): """Test the Face 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)) face = Face('Rectangle Face', Face3D(pts_1, plane_1)) vec_1 = Vector3D(2, 2, 2) new_f = face.duplicate() new_f.move(vec_1) assert new_f.geometry[0] == Point3D(2, 2, 2) assert new_f.geometry[1] == Point3D(4, 2, 2) assert new_f.geometry[2] == Point3D(4, 4, 2) assert new_f.geometry[3] == Point3D(2, 4, 2) assert new_f.normal == face.normal assert face.area == new_f.area assert face.perimeter == new_f.perimeter