def window_material_by_name(material_name):
    """Get an window 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_window_materials[material_name]
    except KeyError:  # material likely needs to be loaded from standards data
        try:
            _mat_dict = _window_standards_dict[material_name]
        except KeyError:  # material is nowhere to be found; raise an error
            raise ValueError(
                '"{}" was not found in the window energy material library.'.
                format(material_name))

    # create the Python object from the standards gem dictionary
    if _mat_dict['material_type'] == 'StandardGlazing':
        _mat_obj = EnergyWindowMaterialGlazing.from_standards_dict(_mat_dict)
    elif _mat_dict['material_type'] == 'SimpleGlazing':
        _mat_obj = EnergyWindowMaterialSimpleGlazSys.from_standards_dict(
            _mat_dict)
    elif _mat_dict['material_type'] == 'Gas':
        _mat_obj = EnergyWindowMaterialGas.from_standards_dict(_mat_dict)
    else:
        raise ValueError(
            'Standards gem material type "{}" is not recognized.'.format(
                _mat_dict['material_type']))
    _mat_obj.lock()
    _idf_window_materials[
        material_name] = _mat_obj  # next time, it will be loaded faster
    return _mat_obj
Esempio n. 2
0
def test_simple_sys_to_from_standards_dict():
    """Test the initialization of EnergyMaterial objects from standards gem."""
    standards_dict = {
        "name": "U 0.52 SHGC 0.39 Simple Glazing",
        "material_type": "SimpleGlazing",
        "u_factor": 0.52,
        "solar_heat_gain_coefficient": 0.39,
        "visible_transmittance": 0.31
    }
    mat_1 = EnergyWindowMaterialSimpleGlazSys.from_standards_dict(
        standards_dict)

    assert mat_1.name == 'U 0.52 SHGC 0.39 Simple Glazing'
    assert mat_1.u_factor == pytest.approx(0.52 * 5.678, rel=1e-3)
    assert mat_1.shgc == pytest.approx(0.39, rel=1e-2)
    assert mat_1.vt == pytest.approx(0.31, rel=1e-2)