def material_opaque_wall_gap(directory): wall_gap = EnergyMaterialNoMass('Generic Wall Air Gap', 0.15, roughness='Smooth') dest_file = os.path.join(directory, 'material_opaque_wall_gap.json') with open(dest_file, 'w') as fp: json.dump(wall_gap.to_dict(), fp, indent=4)
def test_material_nomass_init_from_idf(): """Test the initialization of EnergyMaterialNoMass objects from strings.""" ep_str_1 = "Material:NoMass,\n" \ "CP02 CARPET PAD, !- Name\n" \ "Smooth, !- Roughness\n" \ "0.1, !- Thermal Resistance {m2-K/W}\n" \ "0.9, !- Thermal Absorptance\n" \ "0.8, !- Solar Absorptance\n" \ "0.8; !- Visible Absorptance" mat_1 = EnergyMaterialNoMass.from_idf(ep_str_1) idf_str = mat_1.to_idf() new_mat_1 = EnergyMaterialNoMass.from_idf(idf_str) assert idf_str == new_mat_1.to_idf()
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 test_material_nomass_defaults(): """Test the EnergyMaterialNoMass default properties.""" insul_r2 = EnergyMaterialNoMass('Insulation [R-2]', 2) assert insul_r2.identifier == 'Insulation [R-2]' assert insul_r2.roughness == 'MediumRough' assert insul_r2.thermal_absorptance == 0.9 assert insul_r2.solar_absorptance == insul_r2.visible_absorptance == 0.7
def test_material_nomass_init(): """Test the initialization of EnergyMaterialNoMass and basic properties.""" insul_r2 = EnergyMaterialNoMass('Insulation R-2', 2, 'MediumSmooth', 0.95, 0.75, 0.8) str(insul_r2) # test the string representation of the material insul_r2_dup = insul_r2.duplicate() assert insul_r2.identifier == insul_r2_dup.identifier == 'Insulation R-2' assert insul_r2.r_value == insul_r2_dup.r_value == 2 assert insul_r2.roughness == insul_r2_dup.roughness == 'MediumSmooth' assert insul_r2.thermal_absorptance == insul_r2_dup.thermal_absorptance == 0.95 assert insul_r2.solar_absorptance == insul_r2_dup.solar_absorptance == 0.75 assert insul_r2.visible_absorptance == insul_r2_dup.visible_absorptance == 0.8 assert insul_r2.u_value == pytest.approx(0.5, rel=1e-2) assert insul_r2.r_value == pytest.approx(2, rel=1e-2) insul_r2.r_value = 3 assert insul_r2.r_value == 3
def create_HB_material_no_mass(_material_name, _material_r_value): """ Creates an HB Style "No-Mass" Material """ try: # set the default material properties name = _material_name r_value = _material_r_value roughness = 'MediumRough' therm_absp = 0.9 sol_absp = 0.7 vis_absp = 0.7 # create the NoMass material mat = EnergyMaterialNoMass(clean_and_id_ep_string(name), r_value, 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_material_nomass_invalid(): """Test the initialization of EnergyMaterial objects with invalid properties.""" insul_r2 = EnergyMaterialNoMass('Insulation [R-2]', 2) with pytest.raises(TypeError): insul_r2.identifier = ['test_identifier'] with pytest.raises(AssertionError): insul_r2.r_value = -1 with pytest.raises(AssertionError): insul_r2.roughness = 'Medium' with pytest.raises(AssertionError): insul_r2.thermal_absorptance = 2 with pytest.raises(AssertionError): insul_r2.solar_absorptance = 2 with pytest.raises(AssertionError): insul_r2.visible_absorptance = 2 with pytest.raises(AssertionError): insul_r2.u_value = -1
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_opaque_construction_init(): """Test the initalization of OpaqueConstruction objects and basic properties.""" 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]) str(wall_constr) # test the string representation of the construction constr_dup = wall_constr.duplicate() assert wall_constr.name == constr_dup.name == 'Generic Wall Construction' assert len(wall_constr.materials) == len(constr_dup.materials) == 4 assert wall_constr.r_value == constr_dup.r_value == \ pytest.approx(3.29356, rel=1e-2) assert wall_constr.u_value == constr_dup.u_value == \ pytest.approx(0.30362, rel=1e-2) assert wall_constr.u_factor == constr_dup.u_factor == \ pytest.approx(0.2894284, rel=1e-2) assert wall_constr.r_factor == constr_dup.r_factor == \ pytest.approx(3.4550859, rel=1e-2) assert wall_constr.mass_area_density == constr_dup.mass_area_density == \ pytest.approx(358.397, rel=1e-2) assert wall_constr.area_heat_capacity == constr_dup.area_heat_capacity == \ pytest.approx(298189.26, rel=1e-2) assert wall_constr.inside_emissivity == constr_dup.inside_emissivity == 0.93 assert wall_constr.inside_solar_reflectance == \ constr_dup.inside_solar_reflectance == 0.4 assert wall_constr.inside_visible_reflectance == \ constr_dup.inside_visible_reflectance == 0.35 assert wall_constr.outside_emissivity == \ constr_dup.outside_emissivity == 0.95 assert wall_constr.outside_solar_reflectance == \ constr_dup.outside_solar_reflectance == 0.25 assert wall_constr.outside_visible_reflectance == \ constr_dup.outside_visible_reflectance == pytest.approx(0.2, rel=1e-2)
def test_material_nomass_to_from_standards_dict(): """Test the initialization of EnergyMaterialNoMass objects from standards gem.""" standards_dict = { "name": "MAT-SHEATH", "material_type": "MasslessOpaqueMaterial", "roughness": None, "thickness": None, "conductivity": 6.24012461866438, "resistance": 0.160253209849203, "density": 0.0436995724033012, "specific_heat": 0.000167192127639247, "thermal_absorptance": 0.9, "solar_absorptance": 0.7, "visible_absorptance": 0.7 } mat_1 = EnergyMaterialNoMass.from_standards_dict(standards_dict) assert mat_1.name == 'MAT-SHEATH' assert mat_1.roughness == 'MediumRough' assert mat_1.r_value == pytest.approx(0.1602532098 / 5.678, rel=1e-2) assert mat_1.thermal_absorptance == 0.9 assert mat_1.solar_absorptance == 0.7 assert mat_1.visible_absorptance == 0.7
def test_material_nomass_dict_methods(): """Test the to/from dict methods.""" material = EnergyMaterialNoMass('Insulation R-2', 2) material_dict = material.to_dict() new_material = EnergyMaterialNoMass.from_dict(material_dict) assert material_dict == new_material.to_dict()
ghenv.Component.AdditionalHelpFromDocStrings = "5" try: # import the core honeybee dependencies from honeybee.typing import clean_and_id_ep_string, clean_ep_string except ImportError as e: raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e)) try: # import the honeybee-energy dependencies from honeybee_energy.material.opaque import EnergyMaterialNoMass except ImportError as e: raise ImportError('\nFailed to import honeybee_energy:\n\t{}'.format(e)) try: # import ladybug_rhino dependencies from ladybug_rhino.grasshopper import all_required_inputs except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component): # set the default material properties _roughness_ = 'MediumRough' if _roughness_ is None else _roughness_ _therm_absp_ = 0.9 if _therm_absp_ is None else _therm_absp_ _sol_absp_ = 0.7 if _sol_absp_ is None else _sol_absp_ name = clean_and_id_ep_string('OpaqueNoMassMaterial') if _name_ is None else \ clean_ep_string(_name_) # create the material mat = EnergyMaterialNoMass(name, _r_value, _roughness_, _therm_absp_, _sol_absp_, _vis_absp_) if _name_ is not None: mat.display_name = _name_
ghenv.Component.Category = 'HB-Energy' ghenv.Component.SubCategory = "1 :: Constructions" ghenv.Component.AdditionalHelpFromDocStrings = "5" try: # import the core honeybee dependencies from honeybee.typing import clean_and_id_ep_string except ImportError as e: raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e)) try: # import the honeybee-energy dependencies from honeybee_energy.material.opaque import EnergyMaterialNoMass except ImportError as e: raise ImportError('\nFailed to import honeybee_energy:\n\t{}'.format(e)) try: # import ladybug_rhino dependencies from ladybug_rhino.grasshopper import all_required_inputs except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component): # set the default material properties _roughness_ = 'MediumRough' if _roughness_ is None else _roughness_ _therm_absp_ = 0.9 if _therm_absp_ is None else _therm_absp_ _sol_absp_ = 0.7 if _sol_absp_ is None else _sol_absp_ # create the material mat = EnergyMaterialNoMass(clean_and_id_ep_string(_name), _r_value, _roughness_, _therm_absp_, _sol_absp_, _vis_absp_) mat.display_name = _name