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_check_duplicate_face_names(): """Test the check_duplicate_face_names 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)] face_1 = Face('Face 1', Face3D(pts_1)) face_2 = Face('Face 2', Face3D(pts_2)) face_3 = Face('Face 3', Face3D(pts_3)) face_4 = Face('Face 4', Face3D(pts_4)) face_5 = Face('Face 5', Face3D(pts_5)) face_6 = Face('Face 6', Face3D(pts_6)) face_7 = Face('Face 1', Face3D(pts_6)) room_1 = Room('Test Room', [face_1, face_2, face_3, face_4, face_5, face_6]) room_2 = Room('Test Room', [face_1, face_2, face_3, face_4, face_5, face_7]) model_1 = Model('Test House', [room_1]) model_2 = Model('Test House', [room_2]) assert model_1.check_duplicate_face_names(False) assert not model_2.check_duplicate_face_names(False) with pytest.raises(ValueError): model_2.check_duplicate_face_names(True)
def test_check_non_zero(): """Test the check_non_zero 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(10, 0.0001, 3), Point3D(0, 0.0001, 3), Point3D(0, 0, 3)] face_1 = Face('Face 1', Face3D(pts_1)) face_2 = Face('Face 2', Face3D(pts_2)) face_3 = Face('Face 3', Face3D(pts_3)) face_4 = Face('Face 4', Face3D(pts_4)) face_5 = Face('Face 5', Face3D(pts_5)) face_6 = Face('Face 6', Face3D(pts_6)) face_7 = Face('Face 7', Face3D(pts_7)) room_1 = Room('Zone: SHOE_BOX [920980]', [face_1, face_2, face_3, face_4, face_5, face_6], 0.01, 1) room_2 = Room('Zone: SHOE_BOX [920980]', [face_1, face_2, face_3, face_4, face_5, face_6, face_7]) model_1 = Model('South House', [room_1]) model_2 = Model('North House', [room_2]) assert model_1.check_non_zero(0.01, False) assert not model_2.check_non_zero(0.01, False) with pytest.raises(ValueError): model_2.check_non_zero(0.01, True)
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_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_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_check_non_zero(): """Test the check_non_zero 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(10, 0.0001, 3), Point3D(0, 0.0001, 3), Point3D(0, 0, 3) ] face_1 = Face('Face 1', Face3D(pts_1)) face_2 = Face('Face 2', Face3D(pts_2)) face_3 = Face('Face 3', Face3D(pts_3)) face_4 = Face('Face 4', Face3D(pts_4)) face_5 = Face('Face 5', Face3D(pts_5)) face_6 = Face('Face 6', Face3D(pts_6)) face_7 = Face('Face 7', Face3D(pts_7)) room_1 = Room('Zone: SHOE_BOX [920980]', [face_1, face_2, face_3, face_4, face_5, face_6], 0.01, 1) room_2 = Room('Zone: SHOE_BOX [920980]', [face_1, face_2, face_3, face_4, face_5, face_6, face_7]) assert room_1.check_non_zero(0.01, False) assert not room_2.check_non_zero(0.01, False)
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_init_open(): """Test the initialization of a room with open geometry.""" 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, 2.5, 3), Point3D(0, 2.5, 3), Point3D(0, 0, 3) ] pts_7 = [ Point3D(10, 2.5, 3), Point3D(10, 5, 3), Point3D(0, 5, 3), Point3D(0, 2.5, 3) ] face_1 = Face('Face 1', Face3D(pts_1)) face_2 = Face('Face 2', Face3D(pts_2)) face_3 = Face('Face 3', Face3D(pts_3)) face_4 = Face('Face 4', Face3D(pts_4)) face_5 = Face('Face 5', Face3D(pts_5)) face_6 = Face('Face 6', Face3D(pts_6)) face_7 = Face('Face 7', Face3D(pts_7)) room = Room('Zone: SHOE_BOX [920980]', [face_1, face_2, face_3, face_4, face_5, face_6, face_7], 0.01, 1) assert not room.check_solid(0.01, 1, False) with pytest.raises(ValueError): room.check_solid(0.01, 1, True)
def test_average_orientation(): """Test the average orientation 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) ] face_1 = Face('Face 1', Face3D(pts_1), boundary_condition=boundary_conditions.ground) face_2 = Face('Face 2', Face3D(pts_2), boundary_condition=boundary_conditions.ground) face_3 = Face('Face 3', Face3D(pts_3)) face_4 = Face('Face 4', Face3D(pts_4), boundary_condition=boundary_conditions.ground) face_5 = Face('Face 5', Face3D(pts_5), boundary_condition=boundary_conditions.ground) face_6 = Face('Face 6', Face3D(pts_6)) room = Room('PAssive Solar Earthship', [face_1, face_2, face_3, face_4, face_5, face_6], 0.01, 1) assert room.average_orientation() == 180 assert room.average_orientation(Vector2D(1, 0)) == 90
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 build_hb_room(_faces, _original_room): """ Build a new room, based on the original, but with the new faces """ room = Room(_original_room.identifier, _faces, tolerance, angle_tolerance) room.display_name = _original_room.display_name room.properties.radiance.modifier_set = _original_room.properties.radiance.modifier_set room.properties.energy.construction_set = _original_room.properties.energy.construction_set room.properties.energy.program_type = _original_room.properties.energy.program_type return room
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_check_duplicate_construction_set_identifiers(): """Test the check_duplicate_construction_set_identifiers 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) base_constr_set = ConstructionSet('Lower Floor Construction Set') first_floor.properties.energy.construction_set = base_constr_set second_floor.properties.energy.construction_set = base_constr_set 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]) assert model.properties.energy.check_duplicate_construction_set_identifiers(False) constr_set.unlock() constr_set.identifier = 'Lower Floor Construction Set' constr_set.lock() assert not model.properties.energy.check_duplicate_construction_set_identifiers(False) with pytest.raises(ValueError): model.properties.energy.check_duplicate_construction_set_identifiers(True)
def test_to_dict_multizone_house(): """Test the Model to_dict method with a multi-zone house.""" 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) mod_set = ModifierSet('Attic_Construction_Set') mod_set.floor_set.interior_modifier = Plastic('AtticFloor', 0.4) mod_set.roof_ceiling_set.exterior_modifier = Plastic('AtticRoof', 0.6) attic.properties.radiance.modifier_set = mod_set Room.solve_adjacency([first_floor, second_floor, attic], 0.01) model = Model('Multi_Zone_Single_Family_House', [first_floor, second_floor, attic]) 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']) == 2 assert len(model_dict['properties']['radiance']['modifier_sets']) == 1 assert model_dict['rooms'][0]['faces'][5]['boundary_condition']['type'] == 'Surface' assert model_dict['rooms'][1]['faces'][0]['boundary_condition']['type'] == 'Surface' assert model_dict['rooms'][1]['faces'][5]['boundary_condition']['type'] == 'Surface' assert model_dict['rooms'][2]['faces'][0]['boundary_condition']['type'] == 'Surface' assert model_dict['rooms'][2]['properties']['radiance']['modifier_set'] == \ mod_set.identifier
def test_init(): """Test the initialization of a room and basic properties.""" 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)) room = Room('ZoneSHOE_BOX920980', [face_1, face_2, face_3, face_4, face_5, face_6], 0.01, 1) str(room) # test the string representation of the room assert room.identifier == 'ZoneSHOE_BOX920980' assert room.display_name == 'ZoneSHOE_BOX920980' assert room.multiplier == 1 assert room.story is None assert isinstance(room.geometry, Polyface3D) assert len(room.geometry.vertices) == 8 assert len(room) == 6 assert room.center == Point3D(5, 5, 1.5) assert room.volume == 300 assert room.floor_area == 100 assert room.exposed_area == 220 assert room.exterior_wall_area == 120 assert room.exterior_aperture_area == 0 assert room.average_floor_height == 0 assert not room.has_parent assert room.check_solid(0.01, 1) == '' assert room[0].normal == Vector3D(0, 0, -1) assert room[1].normal == Vector3D(-1, 0, 0) assert room[2].normal == Vector3D(0, -1, 0) assert room[3].normal == Vector3D(0, 1, 0) assert room[4].normal == Vector3D(1, 0, 0) assert room[5].normal == Vector3D(0, 0, 1)
def model_complete_multi_zone_office(directory): 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)) first_floor.properties.energy.program_type = prog_type_lib.office_program second_floor.properties.energy.program_type = prog_type_lib.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('Multi_Zone_Single_Family_House', [first_floor, second_floor, attic]) dest_file = os.path.join(directory, 'model_complete_multi_zone_office.json') with open(dest_file, 'w') as fp: json.dump(model.to_dict(), fp, indent=4)
def test_check_duplicate_modifier_set_identifiers(): """Test the check_duplicate_modifier_set_identifiers method.""" 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)) 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) mod_set_bottom = ModifierSet('Lower_Floor_Modifier_Set') first_floor.properties.radiance.modifier_set = mod_set_bottom second_floor.properties.radiance.modifier_set = mod_set_bottom 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') mod_set.floor_set.interior_modifier = Plastic('AtticFloor', 0.4) mod_set.roof_ceiling_set.exterior_modifier = Plastic('AtticRoof', 0.6) attic.properties.radiance.modifier_set = mod_set Room.solve_adjacency([first_floor, second_floor, attic], 0.01) model = Model('Multi_Zone_Single_Family_House', [first_floor, second_floor, attic]) assert model.properties.radiance.check_duplicate_modifier_set_identifiers(False) == '' mod_set.unlock() mod_set.identifier = 'Lower_Floor_Modifier_Set' mod_set.lock() assert model.properties.radiance.check_duplicate_modifier_set_identifiers(False) != '' with pytest.raises(ValueError): model.properties.radiance.check_duplicate_modifier_set_identifiers(True)
def test_init_coplanar(): """Test the initialization of a room with coplanar faces.""" 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, 2.5, 3), Point3D(0, 2.5, 3), Point3D(0, 0, 3)] pts_7 = [Point3D(10, 2.5, 3), Point3D(10, 5, 3), Point3D(0, 5, 3), Point3D(0, 2.5, 3)] pts_8 = [Point3D(10, 5, 3), Point3D(10, 10, 3), Point3D(0, 10, 3), Point3D(0, 5, 3)] face_1 = Face('Face 1', Face3D(pts_1)) face_2 = Face('Face 2', Face3D(pts_2)) face_3 = Face('Face 3', Face3D(pts_3)) face_4 = Face('Face 4', Face3D(pts_4)) face_5 = Face('Face 5', Face3D(pts_5)) face_6 = Face('Face 6', Face3D(pts_6)) face_7 = Face('Face 7', Face3D(pts_7)) face_8 = Face('Face 8', Face3D(pts_8)) room = Room('Zone: SHOE_BOX [920980]', [face_1, face_2, face_3, face_4, face_5, face_6, face_7, face_8], 0.01, 1) str(room) # test the string representation of the room assert room.name == 'ZoneSHOE_BOX920980' assert room.display_name == 'Zone: SHOE_BOX [920980]' assert isinstance(room.geometry, Polyface3D) assert len(room.geometry.vertices) == 12 assert len(room) == 8 assert room.center == Point3D(5, 5, 1.5) assert room.volume == 300 assert room.floor_area == 100 assert room.exposed_area == 220 assert room.exterior_wall_area == 120 assert room.exterior_aperture_area == 0 assert room.average_floor_height == 0 assert not room.has_parent assert room.check_solid(0.01, 1)
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) model_1 = Model('SouthHouse', [room_1]) model_2 = Model('NorthHouse', [room_2]) assert model_1.check_self_intersecting(False) assert not model_2.check_self_intersecting(False) with pytest.raises(ValueError): model_2.check_self_intersecting(True)
from honeybee.room import Room from honeybee.radiance.material.glass import Glass from honeybee.radiance.sky.certainIlluminance import CertainIlluminanceLevel from honeybee.radiance.recipe.pointintime.gridbased import GridBased # create a test room room = Room(origin=(0, 0, 3.2), width=4.2, depth=6, height=3.2, rotation_angle=45) # add fenestration # # add a window to the back wall room.add_fenestration_surface(wall_name='back', width=2, height=2, sill_height=0.7) # add another window with custom material. This time to the right wall glass_60 = Glass.by_single_trans_value('tvis_0.6', 0.6) room.add_fenestration_surface('right', 4, 1.5, 1.2, radiance_material=glass_60) # run a grid-based analysis for this room # generate the sky sky = CertainIlluminanceLevel(illuminance_value=2000) # Swap this and try and get from open_mesh # generate grid of test points test_points = room.generate_test_points(grid_size=0.5, height=0.75)
def test_to_dict_multizone_house(): """Test the Model to_dict method with a multi-zone house.""" 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)) first_floor.properties.energy.program_type = office_program second_floor.properties.energy.program_type = office_program first_floor.properties.energy.hvac = IdealAirSystem() second_floor.properties.energy.hvac = IdealAirSystem() 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('Attic Face 1', Face3D(pts_1)) face_2 = Face('Attic Face 2', Face3D(pts_2)) face_3 = Face('Attic Face 3', Face3D(pts_3)) face_4 = Face('Attic Face 4', Face3D(pts_4)) face_5 = Face('Attic Face 5', 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_adjcency([first_floor, second_floor, attic], 0.01) model = Model('Multi Zone Single Family House', [first_floor, second_floor, attic]) model_dict = model.to_dict() assert 'energy' in model_dict['properties'] assert 'materials' in model_dict['properties']['energy'] assert 'constructions' in model_dict['properties']['energy'] assert 'construction_sets' in model_dict['properties']['energy'] assert 'global_construction_set' in model_dict['properties']['energy'] assert len(model_dict['properties']['energy']['materials']) == 16 assert len(model_dict['properties']['energy']['constructions']) == 16 assert len(model_dict['properties']['energy']['construction_sets']) == 2 assert model_dict['rooms'][0]['faces'][5]['boundary_condition'][ 'type'] == 'Surface' assert model_dict['rooms'][1]['faces'][0]['boundary_condition'][ 'type'] == 'Surface' assert model_dict['rooms'][1]['faces'][5]['boundary_condition'][ 'type'] == 'Surface' assert model_dict['rooms'][2]['faces'][0]['boundary_condition'][ 'type'] == 'Surface' assert model_dict['rooms'][2]['properties']['energy']['construction_set'] == \ constr_set.name assert model_dict['rooms'][0]['properties']['energy']['program_type'] == \ model_dict['rooms'][1]['properties']['energy']['program_type'] == \ office_program.name assert model_dict['rooms'][0]['properties']['energy']['hvac'] == \ model_dict['rooms'][1]['properties']['energy']['hvac'] == \ IdealAirSystem().to_dict() """
def processItem(item): tpBuilding = item[0] tpShadingFacesCluster = item[1] buildingName = item[2] defaultProgramIdentifier = item[3] defaultConstructionSetIdentifier = item[4] coolingSetpoint = item[5] heatingSetpoint = item[6] humidifyingSetpoint = item[7] dehumidifyingSetpoint = item[8] roomNameKey = item[9] roomTypeKey = item[10] if buildingName: buildingName = buildingName.replace(" ","_") else: buildingName = "GENERICBUILDING" rooms = [] tpCells = [] _ = tpBuilding.Cells(None, tpCells) # Sort cells by Z Levels tpCells.sort(key=lambda c: cellFloor(c), reverse=False) fl = floorLevels(tpCells, 2) spaceNames = [] for spaceNumber, tpCell in enumerate(tpCells): tpDictionary = tpCell.GetDictionary() tpCellName = None tpCellStory = None tpCellProgramIdentifier = None tpCellConstructionSetIdentifier = None tpCellConditioned = True if tpDictionary: keyName = getKeyName(tpDictionary, 'Story') tpCellStory = DictionaryValueAtKey.processItem(tpDictionary, keyName) if tpCellStory: tpCellStory = tpCellStory.replace(" ","_") else: tpCellStory = fl[spaceNumber] if roomNameKey: keyName = getKeyName(tpDictionary, roomNameKey) else: keyName = getKeyName(tpDictionary, 'Name') tpCellName = DictionaryValueAtKey.processItem(tpDictionary,keyName) if tpCellName: tpCellName = createUniqueName(tpCellName.replace(" ","_"), spaceNames, 1) else: tpCellName = tpCellStory+"_SPACE_"+(str(spaceNumber+1)) if roomTypeKey: keyName = getKeyName(tpDictionary, roomTypeKey) else: keyName = getKeyName(tpDictionary, 'Program') tpCellProgramIdentifier = DictionaryValueAtKey.processItem(tpDictionary, keyName) if tpCellProgramIdentifier: program = prog_type_lib.program_type_by_identifier(tpCellProgramIdentifier) elif defaultProgramIdentifier: program = prog_type_lib.program_type_by_identifier(defaultProgramIdentifier) else: program = prog_type_lib.office_program #Default Office Program as a last resort keyName = getKeyName(tpDictionary, 'construction_set') tpCellConstructionSetIdentifier = DictionaryValueAtKey.processItem(tpDictionary, keyName) if tpCellConstructionSetIdentifier: constr_set = constr_set_lib.construction_set_by_identifier(tpCellConstructionSetIdentifier) elif defaultConstructionSetIdentifier: constr_set = constr_set_lib.construction_set_by_identifier(defaultConstructionSetIdentifier) else: constr_set = constr_set_lib.construction_set_by_identifier("Default Generic Construction Set") else: tpCellStory = fl[spaceNumber] tpCellName = tpCellStory+"_SPACE_"+(str(spaceNumber+1)) program = prog_type_lib.office_program constr_set = constr_set_lib.construction_set_by_identifier("Default Generic Construction Set") spaceNames.append(tpCellName) tpCellFaces = [] _ = tpCell.Faces(None, tpCellFaces) if tpCellFaces: hbRoomFaces = [] for tpFaceNumber, tpCellFace in enumerate(tpCellFaces): tpCellFaceNormal = topologic.FaceUtility.NormalAtParameters(tpCellFace, 0.5, 0.5) hbRoomFacePoints = [] tpFaceVertices = [] _ = tpCellFace.ExternalBoundary().Vertices(None, tpFaceVertices) for tpVertex in tpFaceVertices: hbRoomFacePoints.append(Point3D(tpVertex.X(), tpVertex.Y(), tpVertex.Z())) hbRoomFace = Face(tpCellName+'_Face_'+str(tpFaceNumber+1), Face3D(hbRoomFacePoints)) tpFaceApertures = [] _ = tpCellFace.Apertures(tpFaceApertures) if tpFaceApertures: for tpFaceApertureNumber, tpFaceAperture in enumerate(tpFaceApertures): apertureTopology = topologic.Aperture.Topology(tpFaceAperture) tpFaceApertureDictionary = apertureTopology.GetDictionary() if tpFaceApertureDictionary: tpFaceApertureType = DictionaryValueAtKey.processItem(tpFaceApertureDictionary,'type') hbFaceAperturePoints = [] tpFaceApertureVertices = [] _ = apertureTopology.ExternalBoundary().Vertices(None, tpFaceApertureVertices) for tpFaceApertureVertex in tpFaceApertureVertices: hbFaceAperturePoints.append(Point3D(tpFaceApertureVertex.X(), tpFaceApertureVertex.Y(), tpFaceApertureVertex.Z())) if(tpFaceApertureType): if ("door" in tpFaceApertureType.lower()): hbFaceAperture = Door(tpCellName+'_Face_'+str(tpFaceNumber+1)+'_Door_'+str(tpFaceApertureNumber), Face3D(hbFaceAperturePoints)) else: hbFaceAperture = Aperture(tpCellName+'_Face_'+str(tpFaceNumber+1)+'_Window_'+str(tpFaceApertureNumber), Face3D(hbFaceAperturePoints)) else: hbFaceAperture = Aperture(tpCellName+'_Face_'+str(tpFaceNumber+1)+'_Window_'+str(tpFaceApertureNumber), Face3D(hbFaceAperturePoints)) hbRoomFace.add_aperture(hbFaceAperture) else: tpFaceDictionary = tpCellFace.GetDictionary() if (abs(tpCellFaceNormal[2]) < 1e-6) and tpFaceDictionary: #It is a mostly vertical wall and has a dictionary apertureRatio = DictionaryValueAtKey.processItem(tpFaceDictionary,'apertureRatio') if apertureRatio: hbRoomFace.apertures_by_ratio(apertureRatio, tolerance=0.01) fType = honeybee.facetype.get_type_from_normal(Vector3D(tpCellFaceNormal[0],tpCellFaceNormal[1],tpCellFaceNormal[2]), roof_angle=30, floor_angle=150) hbRoomFace.type = fType hbRoomFaces.append(hbRoomFace) room = Room(tpCellName, hbRoomFaces, 0.01, 1) heat_setpt = ScheduleRuleset.from_constant_value('Room Heating', heatingSetpoint, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value('Room Cooling', coolingSetpoint, schedule_types.temperature) humidify_setpt = ScheduleRuleset.from_constant_value('Room Humidifying', humidifyingSetpoint, schedule_types.humidity) dehumidify_setpt = ScheduleRuleset.from_constant_value('Room Dehumidifying', dehumidifyingSetpoint, schedule_types.humidity) setpoint = Setpoint('Room Setpoint', heat_setpt, cool_setpt, humidify_setpt, dehumidify_setpt) simple_office = ScheduleDay('Simple Weekday', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) #Todo: Remove hardwired scheduleday schedule = ScheduleRuleset('Office Water Use', simple_office, None, schedule_types.fractional) #Todo: Remove hardwired schedule shw = ServiceHotWater('Office Hot Water', 0.1, schedule) #Todo: Remove hardwired schedule hot water room.properties.energy.program_type = program room.properties.energy.construction_set = constr_set room.properties.energy.add_default_ideal_air() #Ideal Air Exchange room.properties.energy.setpoint = setpoint #Heating/Cooling/Humidifying/Dehumidifying room.properties.energy.service_hot_water = shw #Service Hot Water if tpCellStory: room.story = tpCellStory rooms.append(room) Room.solve_adjacency(rooms, 0.01) #for room in rooms: #room.properties.energy.construction_set = constr_set #Room.stories_by_floor_height(rooms, min_difference=2.0) if(tpShadingFacesCluster): hbShades = [] tpShadingFaces = [] _ = tpShadingFacesCluster.Faces(None, tpShadingFaces) for faceIndex, tpShadingFace in enumerate(tpShadingFaces): faceVertices = [] _ = tpShadingFace.ExternalBoundary().Vertices(None, faceVertices) facePoints = [] for aVertex in faceVertices: facePoints.append(Point3D(aVertex.X(), aVertex.Y(), aVertex.Z())) hbShadingFace = Face3D(facePoints, None, []) hbShade = Shade("SHADINGSURFACE_" + str(faceIndex+1), hbShadingFace) hbShades.append(hbShade) model = Model(buildingName, rooms, orphaned_shades=hbShades) return model
def process(self): if not any(socket.is_linked for socket in self.outputs): return ifc_files = self.inputs['IFC'].sv_get(deepcopy=False)[0] offsets = self.inputs['Offset'].sv_get(deepcopy=False)[0] file_paths = self.inputs['File path'].sv_get(deepcopy=False)[0] hbjsons = [] for idx, ifc_file in enumerate(ifc_files): file_path = file_paths[idx] offset = offsets[idx] unit_scale = ifcopenshell.util.unit.calculate_unit_scale(ifc_file) id2hb = {} hb_model = Model("Model") for ifc_material_layer in ifc_file.by_type('IfcMaterialLayer'): if not ifc_material_layer.ToMaterialLayerSet: continue material_id = ifc_material_layer.id() thickness = float(ifc_material_layer.LayerThickness) hb_material = EnergyMaterial(str(material_id), thickness, 0.1, 0.1, 1400) hb_material.display_name = ifc_material_layer.Material.Name + " - " + str(ifc_material_layer.LayerThickness) id2hb[material_id] = hb_material for ifc_material_layer_set in ifc_file.by_type('IfcMaterialLayerSet'): construction_id = ifc_material_layer_set.id() layers = [ id2hb[ifc_material_layer.id()] for ifc_material_layer in ifc_material_layer_set.MaterialLayers ] hb_construction = OpaqueConstruction(str(construction_id), layers) hb_construction.display_name = ifc_material_layer_set.LayerSetName id2hb[construction_id] = hb_construction for ifc_building_storey in ifc_file.by_type('IfcBuildingStorey'): if not ifc_building_storey.IsDecomposedBy: continue ifc_spaces = [ x for x in ifc_building_storey.IsDecomposedBy[0].RelatedObjects if x.is_a("IfcSpace") ] if not ifc_spaces: continue for ifc_space in ifc_spaces: space_matrix = ifcopenshell.util.placement.get_local_placement(ifc_space.ObjectPlacement) space_matrix[:3,3] *= unit_scale faces = [] for ifc_rel_space_boundary in ifc_space.BoundedBy: if ifc_rel_space_boundary.ParentBoundary is not None: continue surface_id = ifc_rel_space_boundary.id() vertices = [ (space_matrix @ np.append(v,1))[:-1] for v in ifc_topologic.getLocalVertices(ifc_rel_space_boundary, unit_scale, 0.0) ] geom = Face3D([ Point3D.from_array(v) for v in vertices ]) hb_face = Face(str(surface_id), geom) hb_face.display_name = ifc_rel_space_boundary.Name ifc_building_element = ifc_rel_space_boundary.RelatedBuildingElement if ifc_building_element is not None: for ifc_rel_associates in ifc_building_element.HasAssociations: if not ifc_rel_associates.is_a("IfcRelAssociatesMaterial"): continue ifc_material = ifc_rel_associates.RelatingMaterial if ifc_material.is_a('IfcMaterialLayerSetUsage'): ifc_material = ifc_material.ForLayerSet elif not ifc_material.is_a('IfcMaterialLayerSet'): continue hb_face.properties.energy.construction = id2hb[ifc_material.id()] break for ifc_inner_boundary in ifc_rel_space_boundary.InnerBoundaries: if ifc_inner_boundary.ParentBoundary != ifc_rel_space_boundary: continue sub_surface_id = ifc_inner_boundary.id() name = ifc_inner_boundary.Name vertices = [ (space_matrix @ np.append(v,1))[:-1] for v in ifc_topologic.getLocalVertices(ifc_inner_boundary, unit_scale, offset) ] geom = Face3D([ Point3D.from_array(v) for v in vertices ]) if ifc_inner_boundary.RelatedBuildingElement.is_a("IfcWindow"): hb_aperture = Aperture(str(sub_surface_id), geom) hb_face.add_aperture(hb_aperture) id2hb[sub_surface_id] = hb_aperture elif ifc_inner_boundary.RelatedBuildingElement.is_a("IfcDoor"): hb_door = Door(str(sub_surface_id), geom) hb_face.add_door(hb_door) id2hb[sub_surface_id] = hb_door id2hb[sub_surface_id].display_name = ifc_inner_boundary.Name faces.append(hb_face) id2hb[surface_id] = hb_face space_id = ifc_space.id() hb_room = Room(str(space_id), faces) hb_room.display_name = ifc_space.Name hb_room.story = ifc_building_storey.Name for hb_face in hb_room.faces: ifc_rel_space_boundary = ifc_file.by_id(int(hb_face.identifier)) if ifc_rel_space_boundary.CorrespondingBoundary is None: if ifc_rel_space_boundary.Description == "2a": hb_face.boundary_condition = boundary_conditions.outdoors elif ifc_rel_space_boundary.Description == "2b": hb_face.boundary_condition = boundary_conditions.adiabatic else: adjacent_surface_id = ifc_rel_space_boundary.CorrespondingBoundary.id() if adjacent_surface_id in id2hb: hb_face.boundary_condition = boundary_conditions.surface(id2hb[adjacent_surface_id]) id2hb[adjacent_surface_id].boundary_condition = boundary_conditions.surface(hb_face) for ifc_inner_boundary in ifc_rel_space_boundary.InnerBoundaries: if ifc_inner_boundary.ParentBoundary != ifc_rel_space_boundary: continue hb_sub_surface = id2hb[ifc_inner_boundary.id()] hb_adjacent_sub_surface = id2hb[ifc_inner_boundary.CorrespondingBoundary.id()] hb_sub_surface.boundary_condition = boundary_conditions.surface(hb_adjacent_sub_surface, True) hb_adjacent_sub_surface.boundary_condition = boundary_conditions.surface(hb_sub_surface, True) else: hb_face.boundary_condition = boundary_conditions.outdoors hb_model.add_room(hb_room) f = open(file_path, "w") json.dump(hb_model.to_dict(), f, indent=4) f.close() hbjsons.append(hb_model) self.outputs['HBJSON'].sv_set([hbjsons])
def processItem(item): osModel = item[0] weatherFilePath = item[1] designDayFilePath = item[2] tpBuilding = item[3] tpShadingSurfacesCluster = item[4] floorLevels = item[5] buildingName = item[6] buildingType = item[7] defaultSpaceType = item[8] northAxis = item[9] glazingRatio = item[10] coolingTemp = item[11] heatingTemp = item[12] rooms = [] tpCells = [] _ = tpBuilding.Cells(None, tpCells) # Sort cells by Z Levels tpCells.sort(key=lambda c: c.CenterOfMass().Z(), reverse=False) for spaceNumber, tpCell in enumerate(tpCells): tpDictionary = tpCell.GetDictionary() tpCellName = None tpCellStory = None if tpDictionary: tpCellName = valueAtKey(tpDictionary, 'name') tpCellStory = valueAtKey(tpDictionary, 'story') tpCellFaces = [] _ = tpCell.Faces(None, tpCellFaces) if tpCellFaces: hbRoomFaces = [] for tpFaceNumber, tpCellFace in enumerate(tpCellFaces): hbRoomFacePoints = [] tpFaceVertices = [] _ = tpCellFace.ExternalBoundary().Vertices( None, tpFaceVertices) for tpVertex in tpFaceVertices: hbRoomFacePoints.append( Point3D(tpVertex.X(), tpVertex.Y(), tpVertex.Z())) hbRoomFace = Face( tpCellName + '_Face_' + str(tpFaceNumber + 1), Face3D(hbRoomFacePoints)) faceNormal = topologic.FaceUtility.NormalAtParameters( tpFace, 0.5, 0.5) ang = math.degrees(math.acos(faceNormal.dot([0, 0, 1]))) print("HBJSONByTopology: Angle between face normal and UP", ang) if ang > 175: hbRoomFace.type = "floor" tpFaceApertures = [] _ = tpCellFace.Apertures(tpFaceApertures) if tpFaceApertures: for tpFaceApertureNumber, tpFaceAperture in enumerate( tpFaceApertures): apertureTopology = topologic.Aperture.Topology( tpFaceAperture) tpFaceApertureDictionary = apertureTopology.GetDictionary( ) if tpFaceApertureDictionary: tpFaceApertureType = valueAtKey( tpFaceApertureDictionary, 'type') hbFaceAperturePoints = [] tpFaceApertureVertices = [] _ = apertureTopology.ExternalBoundary().Vertices( None, tpFaceApertureVertices) for tpFaceApertureVertex in tpFaceApertureVertices: hbFaceAperturePoints.append( Point3D(tpFaceApertureVertex.X(), tpFaceApertureVertex.Y(), tpFaceApertureVertex.Z())) if (tpFaceApertureType): if ("door" in tpFaceApertureType.lower()): hbFaceAperture = Door( tpCellName + '_Face_' + str(tpFaceNumber + 1) + '_Door_' + str(tpFaceApertureNumber), Face3D(hbFaceAperturePoints)) else: hbFaceAperture = Aperture( tpCellName + '_Face_' + str(tpFaceNumber + 1) + '_Window_' + str(tpFaceApertureNumber), Face3D(hbFaceAperturePoints)) else: hbFaceAperture = Aperture( tpCellName + '_Face_' + str(tpFaceNumber + 1) + '_Window_' + str(tpFaceApertureNumber), Face3D(hbFaceAperturePoints)) hbRoomFace.add_aperture(hbFaceAperture) hbRoomFaces.append(hbRoomFace) if tpCellName == None: tpCellName = "GENERICROOM_" + (str(spaceNumber + 1)) room = Room(tpCellName, hbRoomFaces, 0.01, 1) #ToDo: Figure out how to add Story number heat_setpt = ScheduleRuleset.from_constant_value( 'Room Heating', heatingTemp, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value( 'Room Cooling', coolingTemp, schedule_types.temperature) humidify_setpt = ScheduleRuleset.from_constant_value( 'Room Humidifying', 30, schedule_types.humidity) #Todo: Remove hardwired number dehumidify_setpt = ScheduleRuleset.from_constant_value( 'Room Dehumidifying', 55, schedule_types.humidity) #Todo: Remove hardwired number setpoint = Setpoint('Room Setpoint', heat_setpt, cool_setpt, humidify_setpt, dehumidify_setpt) simple_office = ScheduleDay( 'Simple Weekday', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) schedule = ScheduleRuleset('Office Water Use', simple_office, None, schedule_types.fractional) shw = ServiceHotWater('Office Hot Water', 0.1, schedule) room.properties.energy.program_type = prog_type_lib.office_program #Default Office Program room.properties.energy.add_default_ideal_air() #Ideal Air Exchange room.properties.energy.setpoint = setpoint #Heating/Cooling/Humidifying/Dehumidifying room.properties.energy.service_hot_water = shw #Service Hot Water if tpCellStory: room.story = tpCellStory rooms.append(room) Room.solve_adjacency(rooms, 0.01) Room.stories_by_floor_height(rooms, min_difference=2.0) hbShades = [] shadingFaces = [] _ = tpShadingSurfacesCluster.Faces(None, shadingFaces) for faceIndex, shadingFace in enumerate(shadingFaces): faceVertices = [] _ = shadingFace.ExternalBoundary().Vertices(None, faceVertices) facePoints = [] for aVertex in faceVertices: facePoints.append(Point3D(aVertex.X(), aVertex.Y(), aVertex.Z())) hbShadingFace = Face3D(facePoints, None, []) hbShade = Shade("SHADINGSURFACE_" + str(faceIndex), hbShadingFace) hbShades.append(hbShade) model = Model('TopologicModel', rooms, orphaned_shades=hbShades) return model.to_dict()
raise ValueError('_mod_set_ has been specified but honeybee-radiance ' 'has failed to import.\n{}'.format(e)) if all_required_inputs(ghenv.Component): # duplicate the input objects to avoid editing them faces = (face.duplicate() for face in _faces) # generate a default name if _name_ is None: # create a default Room name display_name = 'Room_{}'.format(document_counter('room_count')) else: display_name = _name_ name = clean_and_id_string(display_name) # create the Room room = Room(name, faces, tolerance, angle_tolerance) room.display_name = display_name # check that the Room geometry is closed. if room.check_solid(tolerance, angle_tolerance, False) != '': give_warning( ghenv.Component, 'Input _faces do not form a closed volume.\n' 'Room volume must be closed to access most honeybee features.\n' 'Preview the output Room to see the holes in your model.') # try to assign the modifier set if _mod_set_ is not None: if isinstance(_mod_set_, str): _mod_set_ = modifier_set_by_identifier(_mod_set_) room.properties.radiance.modifier_set = _mod_set_