Exemple #1
0
def test_gas_custom_init():
    """Test the initialization of a custom gas."""
    co2_gap = EnergyWindowMaterialGasCustom('CO2', 0.0125, 0.0146, 0.000014,
                                            827.73)
    co2_gap.specific_heat_ratio = 1.4
    co2_gap.molecular_weight = 44
    str(co2_gap)  # test the string representation of the material
    co2_dup = co2_gap.duplicate()

    assert co2_gap.name == co2_dup.name == 'CO2'
    assert co2_gap.thickness == co2_dup.thickness == 0.0125
    assert co2_gap.conductivity == co2_dup.conductivity == pytest.approx(
        0.0146, rel=1e-2)
    assert co2_gap.viscosity == co2_dup.viscosity == pytest.approx(0.000014,
                                                                   rel=1e-2)
    assert co2_gap.specific_heat == co2_dup.specific_heat == pytest.approx(
        827.73, rel=1e-2)
    assert co2_gap.density == co2_dup.density == pytest.approx(1.9631,
                                                               rel=1e-2)
    assert co2_gap.prandtl == co2_dup.prandtl == pytest.approx(0.7937,
                                                               rel=1e-2)

    assert co2_gap.conductivity_coeff_b == 0
    assert co2_gap.conductivity_coeff_c == 0
    assert co2_gap.viscosity_coeff_b == 0
    assert co2_gap.viscosity_coeff_c == 0
    assert co2_gap.specific_heat_coeff_b == 0
    assert co2_gap.specific_heat_coeff_c == 0
    assert co2_gap.specific_heat_ratio == 1.4
    assert co2_gap.molecular_weight == 44
Exemple #2
0
def test_gas_custom_dict_methods():
    """Test the to/from dict methods."""
    co2_gap = EnergyWindowMaterialGasCustom('CO2', 0.0125, 0.0146, 0.000014, 827.73)
    co2_gap.specific_heat_ratio = 1.4
    co2_gap.molecular_weight = 44
    material_dict = co2_gap.to_dict()
    new_material = EnergyWindowMaterialGasCustom.from_dict(material_dict)
    assert material_dict == new_material.to_dict()
def material_window_gas_custom(directory):
    co2_gap = EnergyWindowMaterialGasCustom('CO2', 0.0125, 0.0146, 0.000014,
                                            827.73)
    co2_gap.specific_heat_ratio = 1.4
    co2_gap.molecular_weight = 44
    dest_file = os.path.join(directory, 'material_window_gas_custom.json')
    with open(dest_file, 'w') as fp:
        json.dump(co2_gap.to_dict(), fp, indent=4)
Exemple #4
0
def test_gas_custom_properties_at_temperature():
    """Test the initalization of gas material objects and basic properties."""
    co2_gap = EnergyWindowMaterialGasCustom('CO2', 0.0125, 0.0146, 0.000014, 827.73)
    co2_gap.specific_heat_ratio = 1.4
    co2_gap.molecular_weight = 44

    assert co2_gap.conductivity_at_temperature(223) == pytest.approx(0.0146, rel=1e-2)
    assert co2_gap.viscosity_at_temperature(223) == pytest.approx(1.4e-05, rel=1e-2)
    assert co2_gap.specific_heat_at_temperature(223) == pytest.approx(827.73, rel=1e-2)
    assert co2_gap.density_at_temperature(223) == pytest.approx(2.40466, rel=1e-2)
    assert co2_gap.prandtl_at_temperature(223) == pytest.approx(0.7937, rel=1e-2)