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_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