def test_material_to_from_idf(): """Test the initialization of EnergyMaterial objects from EnergyPlus strings.""" ep_str_1 = "Material,\n" \ " M01 100mm brick, !- Name\n" \ " MediumRough, !- Roughness\n" \ " 0.1016, !- Thickness {m}\n" \ " 0.89, !- Conductivity {W/m-K}\n" \ " 1920, !- Density {kg/m3}\n" \ " 790, !- Specific Heat {J/kg-K}\n" \ " 0.9, !- Thermal Absorptance\n" \ " 0.7, !- Solar Absorptance\n" \ " 0.7; !- Visible Absorptance" mat_1 = EnergyMaterial.from_idf(ep_str_1) ep_str_2 = "Material, M01 100mm brick, MediumRough, " \ "0.1016, 0.89, 1920, 790, 0.9, 0.7, 0.7;" mat_2 = EnergyMaterial.from_idf(ep_str_2) ep_str_3 = "Material, M01 100mm brick, MediumRough, " \ "0.1016, 0.89, 1920, 790;" mat_3 = EnergyMaterial.from_idf(ep_str_3) assert mat_1.identifier == mat_2.identifier == mat_3.identifier idf_str = mat_1.to_idf() new_mat_1 = EnergyMaterial.from_idf(idf_str) assert idf_str == new_mat_1.to_idf()
def test_material_init(): """Test the initialization of EnergyMaterial objects and basic properties.""" concrete = EnergyMaterial('Concrete', 0.2, 0.5, 800, 1200, 'MediumSmooth', 0.95, 0.75, 0.8) str(concrete) # test the string representation of the material concrete_dup = concrete.duplicate() assert concrete.identifier == concrete_dup.identifier == 'Concrete' assert concrete.thickness == concrete_dup.thickness == 0.2 assert concrete.conductivity == concrete_dup.conductivity == 0.5 assert concrete.density == concrete_dup.density == 800 assert concrete.specific_heat == concrete_dup.specific_heat == 1200 assert concrete.roughness == concrete_dup.roughness == 'MediumSmooth' assert concrete.thermal_absorptance == concrete_dup.thermal_absorptance == 0.95 assert concrete.solar_absorptance == concrete_dup.solar_absorptance == 0.75 assert concrete.visible_absorptance == concrete_dup.visible_absorptance == 0.8 assert concrete.resistivity == 1 / 0.5 assert concrete.u_value == pytest.approx(2.5, rel=1e-2) assert concrete.r_value == pytest.approx(0.4, rel=1e-2) assert concrete.mass_area_density == pytest.approx(160, rel=1e-2) assert concrete.area_heat_capacity == pytest.approx(192000, rel=1e-2) concrete.r_value = 0.5 assert concrete.conductivity != concrete_dup.conductivity assert concrete.r_value == 0.5 assert concrete.conductivity == pytest.approx(0.4, rel=1e-2)
def test_opaque_temperature_profile(): """Test the opaque construction temperature profile.""" concrete = EnergyMaterial('Concrete', 0.15, 2.31, 2322, 832) insulation = EnergyMaterial('Insulation', 0.05, 0.049, 265, 836) wall_gap = EnergyMaterial('Wall Air Gap', 0.1, 0.67, 1.2925, 1006.1) gypsum = EnergyMaterial('Gypsum', 0.0127, 0.16, 784.9, 830) wall_constr = OpaqueConstruction('Wall Construction', [concrete, insulation, wall_gap, gypsum]) temperatures, r_values = wall_constr.temperature_profile(-18, 21) assert len(temperatures) == 7 assert temperatures[0] == pytest.approx(-18, rel=1e-2) assert temperatures[-1] == pytest.approx(21, rel=1e-2) assert len(r_values) == 6 assert sum(r_values) == pytest.approx(wall_constr.r_factor, rel=1e-1) assert r_values[-1] == pytest.approx((1 / wall_constr.in_h_simple()), rel=1) for i, mat in enumerate(wall_constr.materials): assert mat.r_value == pytest.approx(r_values[i + 1]) temperatures, r_values = wall_constr.temperature_profile( 36, 21, 4, 2., 180.0, 100000) assert len(temperatures) == 7 assert temperatures[0] == pytest.approx(36, rel=1e-2) assert temperatures[-1] == pytest.approx(21, rel=1e-2) assert len(r_values) == 6
def test_set_construction_set(): """Test the setting of a ConstructionSet on a Room2D.""" pts = (Point3D(0, 0, 3), Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(0, 10, 3)) ashrae_base = SimpleWindowRatio(0.4) overhang = Overhang(1) boundarycs = (bcs.outdoors, bcs.ground, bcs.outdoors, bcs.ground) window = (ashrae_base, None, ashrae_base, None) shading = (overhang, None, None, None) room = Room2D('SquareShoebox', Face3D(pts), 3, boundarycs, window, shading) mass_set = ConstructionSet('Thermal Mass Construction Set') concrete20 = EnergyMaterial('20cm Concrete', 0.2, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) concrete10 = EnergyMaterial('10cm Concrete', 0.1, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) thick_constr = OpaqueConstruction('Thick Concrete Construction', [concrete20]) thin_constr = OpaqueConstruction('Thin Concrete Construction', [concrete10]) shade_constr = ShadeConstruction('Light Shelf', 0.5, 0.5) mass_set.wall_set.exterior_construction = thick_constr mass_set.roof_ceiling_set.interior_construction = thin_constr mass_set.shade_construction = shade_constr room.properties.energy.construction_set = mass_set assert room.properties.energy.construction_set == mass_set hb_room, adj = room.to_honeybee() assert hb_room.properties.energy.construction_set == mass_set assert hb_room[1].properties.energy.construction == thick_constr assert hb_room[5].properties.energy.construction == thin_constr assert hb_room[1].shades[0].properties.energy.construction == shade_constr
def create_std_mass_material(): ''' Simple 'Mass' Layer for inside/outside of simple constuctions ''' try: # Set the default material properties roughness = 'MediumRough' therm_absp = 0.9 sol_absp = 0.7 vis_absp = 0.7 name = 'MASSLAYER' thickness = 0.0254 conductivity = 2 density = 2500 spec_heat = 460 # Create the material mat = EnergyMaterial(clean_and_id_ep_string(name), thickness, conductivity, density, spec_heat, roughness, therm_absp, sol_absp, vis_absp) mat.display_name = name return mat except Exception as e: print('Error creating HB Material', e) return None
def test_assign_to_room(): """Test the assignment of internal masses to rooms.""" concrete20 = EnergyMaterial('20cm Concrete', 0.2, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) concrete10 = EnergyMaterial('10cm Concrete', 0.1, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) thick_constr = OpaqueConstruction('Thick Concrete Construction', [concrete20]) thin_constr = OpaqueConstruction('Thin Concrete Construction', [concrete10]) room = Room.from_box('ShoeBox', 5, 10, 3, 0) table_verts = [ Point3D(1, 1, 1), Point3D(2, 1, 1), Point3D(2, 2, 1), Point3D(1, 2, 1) ] table_geo = Face3D(table_verts) table_mass = InternalMass.from_geometry('Concrete Table', thick_constr, [table_geo], 'Meters') chair_mass = InternalMass('Concrete Chair', thin_constr, 1) assert len(room.properties.energy.internal_masses) == 0 room.properties.energy.internal_masses = [table_mass] assert len(room.properties.energy.internal_masses) == 1 room.properties.energy.add_internal_mass(chair_mass) idf_str = room.to.idf(room) assert idf_str.find('InternalMass,') > -1
def test_opaque_dict_methods(): """Test the to/from dict methods.""" concrete = EnergyMaterial('Concrete', 0.15, 2.31, 2322, 832) insulation = EnergyMaterial('Insulation', 0.05, 0.049, 265, 836) wall_gap = EnergyMaterial('Wall Air Gap', 0.1, 0.67, 1.2925, 1006.1) gypsum = EnergyMaterial('Gypsum', 0.0127, 0.16, 784.9, 830) wall_constr = OpaqueConstruction('Wall Construction', [concrete, insulation, wall_gap, gypsum]) constr_dict = wall_constr.to_dict() new_constr = OpaqueConstruction.from_dict(constr_dict) assert constr_dict == new_constr.to_dict()
def test_setting_construction(): """Test the setting of constructions on the ConstructionSet.""" default_set = ConstructionSet('Thermal Mass Construction Set') concrete20 = EnergyMaterial('20cm Concrete', 0.2, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) concrete10 = EnergyMaterial('10cm Concrete', 0.1, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) stone_door = EnergyMaterial('Stone Door', 0.05, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) thick_constr = OpaqueConstruction('Thick Concrete Construction', [concrete20]) thin_constr = OpaqueConstruction('Thin Concrete Construction', [concrete10]) door_constr = OpaqueConstruction('Stone Door', [stone_door]) light_shelf = ShadeConstruction('Light Shelf', 0.5, 0.5, True) default_set.wall_set.exterior_construction = thick_constr assert default_set.wall_set.exterior_construction == thick_constr assert len(default_set.modified_constructions_unique) == 1 assert len(default_set.modified_materials_unique) == 1 assert isinstance(default_set.wall_set.exterior_construction[0], EnergyMaterial) with pytest.raises(AttributeError): default_set.wall_set.exterior_construction[0].thickness = 0.15 default_set.wall_set.interior_construction = thin_constr assert default_set.wall_set.interior_construction == thin_constr default_set.wall_set.ground_construction = thick_constr assert default_set.wall_set.ground_construction == thick_constr default_set.floor_set.exterior_construction = thick_constr assert default_set.floor_set.exterior_construction == thick_constr default_set.floor_set.interior_construction = thin_constr assert default_set.floor_set.interior_construction == thin_constr default_set.floor_set.ground_construction = thick_constr assert default_set.floor_set.ground_construction == thick_constr default_set.roof_ceiling_set.exterior_construction = thick_constr assert default_set.roof_ceiling_set.exterior_construction == thick_constr default_set.roof_ceiling_set.interior_construction = thin_constr assert default_set.roof_ceiling_set.interior_construction == thin_constr default_set.roof_ceiling_set.ground_construction = thick_constr assert default_set.roof_ceiling_set.ground_construction == thick_constr default_set.door_set.exterior_construction = door_constr assert default_set.door_set.exterior_construction == door_constr default_set.door_set.interior_construction = door_constr assert default_set.door_set.interior_construction == door_constr default_set.door_set.overhead_construction = door_constr assert default_set.door_set.overhead_construction == door_constr default_set.shade_construction = light_shelf assert default_set.shade_construction == light_shelf assert len(default_set.modified_constructions_unique) == 4 assert len(default_set.modified_materials_unique) == 3
def test_material_lockability(): """Test the lockability of the EnergyMaterial.""" concrete = EnergyMaterial('Concrete [HW]', 0.2, 0.5, 800, 1200) concrete.density = 600 concrete.lock() with pytest.raises(AttributeError): concrete.density = 700 concrete.unlock() concrete.density = 700
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_material_equivalency(): """Test the equality of a material to another EnergyMaterial.""" concrete_1 = EnergyMaterial('Concrete [HW]', 0.2, 0.5, 800, 1200) concrete_2 = concrete_1.duplicate() insulation = EnergyMaterial('Insulation', 0.05, 0.049, 265, 836) assert concrete_1 == concrete_2 assert concrete_1 != insulation collection = [concrete_1, concrete_2, insulation] assert len(set(collection)) == 2 concrete_2.density = 600 assert concrete_1 != concrete_2 assert len(set(collection)) == 3
def opaque_material_by_name(material_name): """Get an opaque material from the library given the material name. Args: material_name: A text string for the name of the material. """ try: # see if the material has already been loaded to a Python object return _idf_opaque_materials[material_name] except KeyError: # material likely needs to be loaded from standards data try: _mat_dict = _opaque_standards_dict[material_name] except KeyError: # material is nowhere to be found; raise an error raise ValueError( '"{}" was not found in the opaque energy material library.'. format(material_name)) # create the Python object from the standards gem dictionary if _mat_dict['material_type'] == 'StandardOpaqueMaterial': _mat_obj = EnergyMaterial.from_standards_dict(_mat_dict) elif _mat_dict['material_type'] in ('MasslessOpaqueMaterial', 'AirGap'): _mat_obj = EnergyMaterialNoMass.from_standards_dict(_mat_dict) else: raise ValueError( 'Standards gem material type "{}" is not recognized.'.format( _mat_dict['material_type'])) _mat_obj.lock() _idf_opaque_materials[ material_name] = _mat_obj # next time, it will be loaded faster return _mat_obj
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_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_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_check_duplicate_construction_names(): """Test the check_duplicate_construction_names method.""" room = Room.from_box('Tiny House Zone', 5, 10, 3) stone = EnergyMaterial('Thick Stone', 0.3, 2.31, 2322, 832, 'Rough', 0.95, 0.75, 0.8) thermal_mass_constr = OpaqueConstruction('Custom Construction', [stone]) room[0].properties.energy.construction = thermal_mass_constr north_face = room[1] 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)) aperture.is_operable = True triple_pane = WindowConstruction( 'Custom Window Construction', [clear_glass, air_gap, clear_glass, air_gap, clear_glass]) aperture.properties.energy.construction = triple_pane north_face.add_aperture(aperture) model = Model('Tiny House', [room]) assert model.properties.energy.check_duplicate_construction_names(False) triple_pane.unlock() triple_pane.name = 'Custom Construction' triple_pane.lock() assert not model.properties.energy.check_duplicate_construction_names( False) with pytest.raises(ValueError): model.properties.energy.check_duplicate_construction_names(True)
def test_opaque_construction_from_idf(): """Test the OpaqueConstruction to/from idf methods.""" concrete = EnergyMaterial('Concrete', 0.15, 2.31, 2322, 832) insulation = EnergyMaterial('Insulation', 0.05, 0.049, 265, 836) wall_gap = EnergyMaterial('Wall Air Gap', 0.1, 0.67, 1.2925, 1006.1) gypsum = EnergyMaterial('Gypsum', 0.0127, 0.16, 784.9, 830) wall_constr = OpaqueConstruction('Wall Construction', [concrete, insulation, wall_gap, gypsum]) constr_str = wall_constr.to_idf() mat_str = [mat.to_idf() for mat in wall_constr.unique_materials] new_wall_constr = OpaqueConstruction.from_idf(constr_str, mat_str) new_constr_str = new_wall_constr.to_idf() assert wall_constr.r_value == new_wall_constr.r_value assert wall_constr.r_factor == new_wall_constr.r_factor assert wall_constr.thickness == new_wall_constr.thickness assert constr_str == new_constr_str
def test_material_defaults(): """Test the EnergyMaterial default properties.""" concrete = EnergyMaterial('Concrete [HW]', 0.2, 0.5, 800, 1200) assert concrete.identifier == 'Concrete [HW]' assert concrete.roughness == 'MediumRough' assert concrete.thermal_absorptance == 0.9 assert concrete.solar_absorptance == concrete.visible_absorptance == 0.7
def test_set_construction_set(): """Test the setting of a ConstructionSet on a Story.""" pts_1 = (Point3D(0, 0, 3), Point3D(0, 10, 3), Point3D(10, 10, 3), Point3D(10, 0, 3)) pts_2 = (Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(20, 10, 3), Point3D(20, 0, 3)) pts_3 = (Point3D(0, 10, 3), Point3D(0, 20, 3), Point3D(10, 20, 3), Point3D(10, 10, 3)) pts_4 = (Point3D(10, 10, 3), Point3D(10, 20, 3), Point3D(20, 20, 3), Point3D(20, 10, 3)) room2d_1 = Room2D('Office1', Face3D(pts_1), 3) room2d_2 = Room2D('Office2', Face3D(pts_2), 3) room2d_3 = Room2D('Office3', Face3D(pts_3), 3) room2d_4 = Room2D('Office4', Face3D(pts_4), 3) story = Story('OfficeFloor', [room2d_1, room2d_2, room2d_3, room2d_4]) story.solve_room_2d_adjacency(0.01) story.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) mass_set = ConstructionSet('Thermal Mass Construction Set') concrete20 = EnergyMaterial('20cm Concrete', 0.2, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) concrete10 = EnergyMaterial('10cm Concrete', 0.1, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) thick_constr = OpaqueConstruction('Thick Concrete Construction', [concrete20]) thin_constr = OpaqueConstruction('Thin Concrete Construction', [concrete10]) shade_constr = ShadeConstruction('Light Shelf', 0.5, 0.5) mass_set.wall_set.exterior_construction = thick_constr mass_set.roof_ceiling_set.interior_construction = thin_constr mass_set.shade_construction = shade_constr story.properties.energy.construction_set = mass_set assert story.properties.energy.construction_set == mass_set assert story[0].properties.energy.construction_set == mass_set rooms = story.to_honeybee() model = hb_model.Model(story.identifier, rooms) assert len(model.properties.energy.construction_sets) == 1 assert model.properties.energy.construction_sets[0] == mass_set assert model.rooms[0].properties.energy.construction_set == mass_set
def test_set_construction_set(): """Test the setting of a ConstructionSet on a Room.""" room = Room.from_box('Shoe Box', 5, 10, 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)) mass_set = ConstructionSet('Thermal Mass Construction Set') concrete20 = EnergyMaterial('20cm Concrete', 0.2, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) concrete10 = EnergyMaterial('10cm Concrete', 0.1, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) stone_door = EnergyMaterial('Stone Door', 0.05, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) thick_constr = OpaqueConstruction('Thick Concrete Construction', [concrete20]) thin_constr = OpaqueConstruction('Thin Concrete Construction', [concrete10]) door_constr = OpaqueConstruction('Stone Door', [stone_door]) shade_constr = ShadeConstruction('Light Shelf', 0.5, 0.5) mass_set.wall_set.exterior_construction = thick_constr mass_set.roof_ceiling_set.exterior_construction = thin_constr mass_set.door_set.exterior_construction = door_constr mass_set.shade_construction = shade_constr room.properties.energy.construction_set = mass_set assert room.properties.energy.construction_set == mass_set assert room[1].properties.energy.construction == thick_constr assert room[5].properties.energy.construction == thin_constr assert room[3].doors[0].properties.energy.construction == door_constr assert room[1].apertures[0].shades[ 0].properties.energy.construction == shade_constr with pytest.raises(AttributeError): room[1].properties.energy.construction.thickness = 0.3 with pytest.raises(AttributeError): room[5].properties.energy.construction.thickness = 0.3 with pytest.raises(AttributeError): room[3].doors[0].properties.energy.construction.thickness = 0.3
def test_internal_mass_equality(): """Test the equality of InternalMass objects.""" rammed_earth = EnergyMaterial('40cm Rammed Earth', 0.4, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) earth_constr = OpaqueConstruction('Rammed Earth Construction', [rammed_earth]) stone = EnergyMaterial('Stone Veneer', 0.1, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) stone_constr = OpaqueConstruction('Stone Veneer', [stone]) chimney_mass = InternalMass('Rammed Earth Chimney', earth_constr, 10) chimney_mass_dup = chimney_mass.duplicate() chimney_mass_alt = InternalMass('Rammed Earth Chimney', stone_constr, 10) assert chimney_mass is chimney_mass assert chimney_mass is not chimney_mass_dup assert chimney_mass == chimney_mass_dup chimney_mass_dup.area = 5 assert chimney_mass != chimney_mass_dup assert chimney_mass != chimney_mass_alt
def test_opaque_lockability(): """Test the lockability of the construction.""" concrete = EnergyMaterial('Concrete', 0.15, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) insulation = EnergyMaterialNoMass('Insulation R-3', 3, 'MediumSmooth') wall_gap = EnergyMaterial('Wall Air Gap', 0.1, 0.67, 1.2925, 1006.1) gypsum = EnergyMaterial('Gypsum', 0.0127, 0.16, 784.9, 830, 'MediumRough', 0.93, 0.6, 0.65) wall_constr = OpaqueConstruction('Generic Wall Construction', [concrete, insulation, wall_gap, gypsum]) wall_constr.materials = [concrete, wall_gap, gypsum] wall_constr.lock() with pytest.raises(AttributeError): wall_constr.materials = [concrete, insulation, wall_gap, gypsum] with pytest.raises(AttributeError): wall_constr[0].density = 600 wall_constr.unlock() wall_constr.materials = [concrete, insulation, wall_gap, gypsum] wall_constr[0].density = 600
def test_internal_mass_dict_methods(): """Test the to/from dict methods.""" rammed_earth = EnergyMaterial('40cm Rammed Earth', 0.4, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) earth_constr = OpaqueConstruction('Rammed Earth Construction', [rammed_earth]) chimney_mass = InternalMass('Rammed Earth Chimney', earth_constr, 10) mass_dict = chimney_mass.to_dict() new_chimney_mass = InternalMass.from_dict(mass_dict) assert new_chimney_mass == chimney_mass assert mass_dict == new_chimney_mass.to_dict()
def test_check_duplicate_construction_set_identifiers(): """Test the check_duplicate_construction_set_identifiers method.""" pts_1 = (Point3D(0, 0, 3), Point3D(0, 10, 3), Point3D(10, 10, 3), Point3D(10, 0, 3)) pts_2 = (Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(20, 10, 3), Point3D(20, 0, 3)) room2d_1 = Room2D('Office1', Face3D(pts_1), 3) room2d_2 = Room2D('Office2', Face3D(pts_2), 3) story = Story('OfficeFloor', [room2d_1, room2d_2]) story.solve_room_2d_adjacency(0.01) story.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story.multiplier = 4 for room in story.room_2ds: room.properties.energy.program_type = office_program room.properties.energy.add_default_ideal_air() building = Building('OfficeBuilding', [story]) building.separate_top_bottom_floors() 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 building.unique_room_2ds[ -1].properties.energy.construction_set = constr_set building.unique_room_2ds[ -2].properties.energy.construction_set = constr_set tree_canopy_geo1 = Face3D.from_regular_polygon(6, 6, Plane(o=Point3D(5, -10, 6))) tree_canopy_geo2 = Face3D.from_regular_polygon( 6, 2, Plane(o=Point3D(-5, -10, 3))) tree_canopy = ContextShade('TreeCanopy', [tree_canopy_geo1, tree_canopy_geo2]) model = Model('NewDevelopment', [building], [tree_canopy]) assert model.properties.energy.check_duplicate_construction_set_identifiers( False) constr_set2 = ConstructionSet('Attic Construction Set') building.unique_room_2ds[ -2].properties.energy.construction_set = constr_set2 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_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_internal_mass_idf_methods(): """Test the to/from IDF methods.""" rammed_earth = EnergyMaterial('40cm Rammed Earth', 0.4, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) earth_constr = OpaqueConstruction('Rammed Earth Construction', [rammed_earth]) chimney_mass = InternalMass('Rammed Earth Chimney', earth_constr, 10) mass_idf = chimney_mass.to_idf('Test Room') new_chimney_mass = InternalMass.from_idf( mass_idf, {'Rammed Earth Construction': earth_constr}) assert new_chimney_mass == chimney_mass assert mass_idf == new_chimney_mass.to_idf('Test Room')
def test_internal_mass_init(): """Test the initialization of InternalMass and basic properties.""" rammed_earth = EnergyMaterial('40cm Rammed Earth', 0.4, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) earth_constr = OpaqueConstruction('Rammed Earth Construction', [rammed_earth]) chimney_mass = InternalMass('Rammed Earth Chimney', earth_constr, 10) str(chimney_mass) # test the string representation assert chimney_mass.identifier == chimney_mass.display_name == 'Rammed Earth Chimney' assert chimney_mass.construction == earth_constr assert chimney_mass.area == 10 stone = EnergyMaterial('Stone Veneer', 0.1, 2.31, 2322, 832, 'MediumRough', 0.95, 0.75, 0.8) stone_constr = OpaqueConstruction('Stone Veneer', [stone]) chimney_mass.construction = stone_constr chimney_mass.area = 8 assert chimney_mass.construction == stone_constr assert chimney_mass.area == 8
def test_opaque_symmetric(): """Test that the opaque construction is_symmetric property.""" concrete = EnergyMaterial('Concrete', 0.15, 2.31, 2322, 832) insulation = EnergyMaterial('Insulation', 0.05, 0.049, 265, 836) wall_gap = EnergyMaterial('Wall Air Gap', 0.1, 0.67, 1.2925, 1006.1) gypsum = EnergyMaterial('Gypsum', 0.0127, 0.16, 784.9, 830) wall_constr_1 = OpaqueConstruction( 'Wall Construction', [concrete, insulation, wall_gap, gypsum]) wall_constr_2 = OpaqueConstruction( 'Wall Construction', [gypsum, wall_gap, gypsum]) wall_constr_3 = OpaqueConstruction( 'Wall Construction', [concrete]) wall_constr_4 = OpaqueConstruction( 'Wall Construction', [concrete, concrete]) wall_constr_5 = OpaqueConstruction( 'Other Wall Construction', [concrete, insulation, wall_gap, insulation, concrete]) assert not wall_constr_1.is_symmetric assert wall_constr_2.is_symmetric assert wall_constr_3.is_symmetric assert wall_constr_4.is_symmetric assert wall_constr_5.is_symmetric
def test_opaque_equivalency(): """Test the equality of an opaque construction to another.""" concrete = EnergyMaterial('Concrete', 0.15, 2.31, 2322, 832) insulation = EnergyMaterial('Insulation', 0.05, 0.049, 265, 836) wall_gap = EnergyMaterial('Wall Air Gap', 0.1, 0.67, 1.2925, 1006.1) gypsum = EnergyMaterial('Gypsum', 0.0127, 0.16, 784.9, 830) wall_constr_1 = OpaqueConstruction( 'Wall Construction', [concrete, insulation, wall_gap, gypsum]) wall_constr_2 = wall_constr_1.duplicate() wall_constr_3 = OpaqueConstruction( 'Wall Construction', [concrete, wall_gap, gypsum, insulation]) wall_constr_4 = OpaqueConstruction( 'Other Wall Construction', [concrete, insulation, wall_gap, gypsum]) collection = [wall_constr_1, wall_constr_1, wall_constr_2, wall_constr_3] assert len(set(collection)) == 2 assert wall_constr_1 == wall_constr_2 assert wall_constr_1 != wall_constr_3 assert wall_constr_1 != wall_constr_4 wall_constr_2.name = 'Roof Construction' assert wall_constr_1 != wall_constr_2
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