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
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)
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)
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()
raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e)) try: # import the honeybee-energy dependencies from honeybee_energy.material.gas import EnergyWindowMaterialGasCustom 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 _conductivity_b_ = 0 if _conductivity_b_ is None else _conductivity_b_ _viscosity_b_ = 0 if _viscosity_b_ is None else _viscosity_b_ _specific_heat_b_ = 0 if _specific_heat_b_ is None else _specific_heat_b_ _spec_heat_ratio_ = 1.0 if _spec_heat_ratio_ is None else _spec_heat_ratio_ _mol_weight_ = 20.0 if _mol_weight_ is None else _mol_weight_ # set the non-exposed inputs _conductivity_c_, _viscosity_c_, _specific_heat_c_ = 0, 0, 0 # create the material mat = EnergyWindowMaterialGasCustom( clean_and_id_ep_string(_name), _thickness, _conductivity_a, _viscosity_a, _specific_heat_a, _conductivity_b_, _viscosity_b_, _specific_heat_b_, _conductivity_c_, _viscosity_c_, _specific_heat_c_, _spec_heat_ratio_, _mol_weight_) mat.display_name = _name
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 _conductivity_b_ = 0 if _conductivity_b_ is None else _conductivity_b_ _viscosity_b_ = 0 if _viscosity_b_ is None else _viscosity_b_ _specific_heat_b_ = 0 if _specific_heat_b_ is None else _specific_heat_b_ _spec_heat_ratio_ = 1.0 if _spec_heat_ratio_ is None else _spec_heat_ratio_ _mol_weight_ = 20.0 if _mol_weight_ is None else _mol_weight_ name = clean_and_id_ep_string('GapMaterial') if _name_ is None else \ clean_ep_string(_name_) # set the non-exposed inputs _conductivity_c_, _viscosity_c_, _specific_heat_c_ = 0, 0, 0 # create the material mat = EnergyWindowMaterialGasCustom(name, _thickness, _conductivity_a, _viscosity_a, _specific_heat_a, _conductivity_b_, _viscosity_b_, _specific_heat_b_, _conductivity_c_, _viscosity_c_, _specific_heat_c_, _spec_heat_ratio_, _mol_weight_) if _name_ is not None: mat.display_name = _name_