Example #1
0
def test_gas_mixture_dict_methods():
    """Test the to/from dict methods."""
    air_xenon = EnergyWindowMaterialGasMixture(
        'Air Xenon Gap', 0.0125, ('Air', 'Xenon'), (0.1, 0.9))
    material_dict = air_xenon.to_dict()
    new_material = EnergyWindowMaterialGasMixture.from_dict(material_dict)
    assert material_dict == new_material.to_dict()
Example #2
0
def test_gas_mixture_defaults():
    """Test the EnergyWindowMaterialGasMixture default properties."""
    air_argon = EnergyWindowMaterialGasMixture('Default Gap')

    assert air_argon.thickness == 0.0125
    assert air_argon.gas_types == ('Argon', 'Air')
    assert air_argon.gas_fractions == (0.9, 0.1)
Example #3
0
def test_gas_mixture_init():
    """Test the initialization of a gas mixture."""
    air_argon = EnergyWindowMaterialGasMixture(
        'Air Argon Gap', 0.0125, ('Air', 'Argon'), (0.1, 0.9))
    str(air_argon)  # test the string representation of the material
    aa_dup = air_argon.duplicate()

    assert air_argon.identifier == aa_dup.identifier == 'Air Argon Gap'
    assert air_argon.thickness == aa_dup.thickness == 0.0125
    assert air_argon.gas_types == aa_dup.gas_types == ('Air', 'Argon')
    assert air_argon.gas_fractions == aa_dup.gas_fractions == (0.1, 0.9)
    assert air_argon.conductivity == aa_dup.conductivity == pytest.approx(0.0171, rel=1e-2)
    assert air_argon.viscosity == aa_dup.viscosity == pytest.approx(1.953e-05, rel=1e-2)
    assert air_argon.specific_heat == aa_dup.specific_heat == pytest.approx(570.346, rel=1e-2)
    assert air_argon.density == aa_dup.density == pytest.approx(1.733399, rel=1e-2)
    assert air_argon.prandtl == aa_dup.prandtl == pytest.approx(0.65057, rel=1e-2)
Example #4
0
def test_gas_mixture_properties_at_temperature():
    """Test the initalization of gas material objects and basic properties."""
    air_argon = EnergyWindowMaterialGasMixture(
        'Air Argon Gap', 0.0125, ('Air', 'Argon'), (0.1, 0.9))

    assert air_argon.conductivity_at_temperature(223) == pytest.approx(0.0144, rel=1e-2)
    assert air_argon.viscosity_at_temperature(223) == pytest.approx(1.6571e-05, rel=1e-2)
    assert air_argon.specific_heat_at_temperature(223) == pytest.approx(570.284, rel=1e-2)
    assert air_argon.density_at_temperature(223) == pytest.approx(2.12321, rel=1e-2)
    assert air_argon.prandtl_at_temperature(223) == pytest.approx(0.6558, rel=1e-2)
Example #5
0
def test_window_construction_init_gas_mixture():
    """Test the initalization of WindowConstruction objects with a gas mixture."""
    lowe_glass = EnergyWindowMaterialGlazing('Low-e Glass', 0.00318, 0.4517,
                                             0.359, 0.714, 0.207, 0, 0.84,
                                             0.046578, 1.0)
    clear_glass = EnergyWindowMaterialGlazing('Clear Glass', 0.005715,
                                              0.770675, 0.07, 0.8836, 0.0804,
                                              0, 0.84, 0.84, 1.0)
    air_argon = EnergyWindowMaterialGasMixture('Air Argon Gap', 0.0125,
                                               ('Air', 'Argon'), (0.1, 0.9))
    double_low_e_argon = WindowConstruction(
        'Double Low-E with Argon', [lowe_glass, air_argon, clear_glass])

    assert double_low_e_argon.u_factor == pytest.approx(1.46319708, rel=1e-2)
Example #6
0
def test_gas_mixture_init_from_idf():
    """Test the initialization of gas mixture objects from strings."""
    ep_str_1 = "WindowMaterial:GasMixture,\n" \
        "Argon Mixture,            !- Name\n" \
        "0.01,                     !- Thickness {m}\n" \
        "2,                        !- Number of Gases\n" \
        "Argon,                    !- Gas 1 Type\n" \
        "0.8,                      !- Gas 1 Fraction\n" \
        "Air,                      !- Gas 2 Type\n" \
        "0.2;                      !- Gas 2 Fraction"
    gas_mix = EnergyWindowMaterialGasMixture.from_idf(ep_str_1)

    assert gas_mix.identifier == 'Argon Mixture'
    assert gas_mix.thickness == 0.01
    assert gas_mix.gas_types == ('Argon', 'Air')
    assert gas_mix.gas_fractions == (0.8, 0.2)
Example #7
0
def test_gas_mixture_invalid():
    """Test EnergyWindowMaterialGlazing objects with invalid properties."""
    air_argon = EnergyWindowMaterialGasMixture(
        'Air Argon Gap', 0.0125, ('Air', 'Argon'), (0.1, 0.9))

    with pytest.raises(TypeError):
        air_argon.identifier = ['test_identifier']
    with pytest.raises(AssertionError):
        air_argon.thickness = -1
    with pytest.raises(AssertionError):
        air_argon.gas_types = ('Helium', 'Nitrogen')
    with pytest.raises(AssertionError):
        air_argon.gas_fractions = (0.5, 0.7)
try:  # import the honeybee-energy dependencies
    from honeybee_energy.material.gas import EnergyWindowMaterialGas, \
        EnergyWindowMaterialGasMixture
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
    _thickness_ = 0.0125 if _thickness_ is None else _thickness_
    _gas_types_ = ['Air'] if len(_gas_types_) == 0 else _gas_types_
    _gas_ratios_ = [1 / len(_gas_types_)] * len(_gas_types_) if \
        len(_gas_ratios_) == 0 else _gas_ratios_
    assert len(_gas_types_) == len(_gas_ratios_), \
        'Length of _gas_types_ does not equal length of _gas_ratios_.'

    # create the material
    if len(_gas_types_) == 1:
        mat = EnergyWindowMaterialGas(
            clean_and_id_ep_string(_name), _thickness_, _gas_types_[0])
    else:
        mat = EnergyWindowMaterialGasMixture(
            clean_and_id_ep_string(_name), _thickness_, _gas_types_, _gas_ratios_)
    mat.display_name = _name
def material_window_gas_mixture(directory):
    argon_mix = EnergyWindowMaterialGasMixture('Argon Air Mixture', 0.0125,
                                               ['Argon', 'Air'], [0.9, 0.1])
    dest_file = os.path.join(directory, 'material_window_gas_mixture.json')
    with open(dest_file, 'w') as fp:
        json.dump(argon_mix.to_dict(), fp, indent=4)
try:  # import the honeybee-energy dependencies
    from honeybee_energy.material.gas import EnergyWindowMaterialGas, \
        EnergyWindowMaterialGasMixture
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
    _thickness_ = 0.0125 if _thickness_ is None else _thickness_
    _gas_types_ = ['Air'] if len(_gas_types_) == 0 else _gas_types_
    _gas_ratios_ = [1 / len(_gas_types_)] * len(_gas_types_) if \
        len(_gas_ratios_) == 0 else _gas_ratios_
    assert len(_gas_types_) == len(_gas_ratios_), \
        'Length of _gas_types_ does not equal length of _gas_ratios_.'
    name = clean_and_id_ep_string('GapMaterial') if _name_ is None else \
        clean_ep_string(_name_)

    # create the material
    if len(_gas_types_) == 1:
        mat = EnergyWindowMaterialGas(name, _thickness_, _gas_types_[0])
    else:
        mat = EnergyWindowMaterialGasMixture(name, _thickness_, _gas_types_,
                                             _gas_ratios_)
    if _name_ is not None:
        mat.display_name = _name_