fairyfly_therm.material.gas module

Gas materials.

class fairyfly_therm.material.gas.Gas(pure_gases, gas_fractions, identifier=None)[source]

Bases: _ResourceObjectBase

Gas gap material defined by a mixture of gases.

Parameters:
  • pure_gases – A list of PureGas objects describing the types of gas in the gap.

  • gas_fractions – A list of fractional numbers describing the volumetric fractions of gas types in the mixture. This list must align with the pure_gases input list and must sum to 1.

  • identifier – Text string for a unique object ID. Must be a UUID in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. If None, a UUID will automatically be generated. (Default: None).

Properties:
  • identifier

  • display_name

  • pure_gases

  • gas_fractions

  • gas_count

  • protected

  • user_data

ToString()

Overwrite .NET ToString.

conductivity_at_temperature(t_kelvin)[source]

Get the conductivity of the gas [W/m-K] at a given Kelvin temperature.

density_at_temperature(t_kelvin, pressure=101325)[source]

Get the density of the gas [kg/m3] at a given temperature and pressure.

This method uses the ideal gas law to estimate the density.

Parameters:
  • t_kelvin – The average temperature of the gas cavity in Kelvin.

  • pressure – The average pressure of the gas cavity in Pa. Default is 101325 Pa for standard pressure at sea level.

duplicate()

Get a copy of this object.

static extract_all_from_xml_file(xml_file)[source]

Extract all Gas objects from a THERM XML file.

Parameters:

xml_file – A path to an XML file containing objects Gas objects and corresponding PureGas components.

Returns:

A tuple with two elements

  • gases: A list of all Gas objects in the XML file as fairyfly_therm Gas objects.

  • pure_gases: A list of all PureGas objects in the XML file as fairyfly_therm PureGas objects.

classmethod from_dict(data)[source]

Create a Gas from a dictionary.

Parameters:

data – A python dictionary in the following format

{
'type': 'Gas',
'identifier': 'e34f4b07-a012-4142-ae29-d7967c921c71',
'display_name': 'Argon Mixture',
'pure_gases': [{}, {}],  # list of PureGas objects
'gas_fractions': [0.95, 0.05]
}
classmethod from_dict_abridged(data, pure_gases)[source]

Create a Gas from an abridged dictionary.

Parameters:
  • data – An GasAbridged dictionary.

  • pure_gases – A dictionary with pure gas identifiers as keys and PureGas object instances as values. These will be used to reassign the pure gases that make up this gas gap.

{
'type': 'GasAbridged',
'identifier': 'e34f4b07-a012-4142-ae29-d7967c921c71',
'display_name': 'Argon Mixture',
'pure_gases': [
    'ca280a4b-aba9-416f-9443-484285d52227',
    'ba65b928-f766-4044-bc17-e53c42040bde'
],
'gas_fractions': [0.95, 0.05]
}
classmethod from_therm_xml(xml_element, pure_gases)[source]

Create Gas from an XML element of a THERM Gas material.

Parameters:
  • xml_element – An XML element of a THERM Gas material.

  • pure_gases – A dictionary with pure gas names as keys and PureGas object instances as values. These will be used to reassign the pure gases that make up this gas.

classmethod from_therm_xml_str(xml_str, pure_gases)[source]

Create a Gas from an XML text string of a THERM Gas.

Parameters:
  • xml_str – An XML text string of a THERM Gas.

  • pure_gases – A dictionary with pure gas names as keys and PureGas object instances as values. These will be used to reassign the pure gases that make up this gas gap.

lock()[source]

The lock() method will also lock the pure gases.

prandtl_at_temperature(t_kelvin)[source]

Get the Prandtl number of the gas at a given Kelvin temperature.

specific_heat_at_temperature(t_kelvin)[source]

Get the specific heat of the gas [J/kg-K] at a given Kelvin temperature.

to_dict(abridged=False)[source]

Gas dictionary representation.

to_therm_xml(gases_element=None)[source]

Get an THERM XML element of the gas.

Note that this method only outputs a single element for the gas and, to write the full gas into an XML, the gas’s pure gases must also be written.

Parameters:

gases_element – An optional XML Element for the Gases to which the generated objects will be added. If None, a new XML Element will be generated.

<Gas>
    <UUID>6c2409e9-5296-46c1-be11-9029b59a549b</UUID>
    <Name>Air</Name>
    <Protected>true</Protected>
    <Components>
        <Component>
            <Fraction>1</Fraction>
            <PureGas>Air</PureGas>
        </Component>
    </Components>
</Gas>
to_therm_xml_str()[source]

Get an THERM XML string of the gas.

unlock()[source]

The unlock() method will also unlock the pure gases.

viscosity_at_temperature(t_kelvin)[source]

Get the viscosity of the gas [kg/m-s] at a given Kelvin temperature.

property conductivity

Conductivity of the gas in the absence of convection at 0C [W/m-K].

property density

Density of the gas at 0C and sea-level pressure [J/kg-K].

property display_name

Get or set a string for the object name without any character restrictions.

If not set, this will be equal to the identifier.

property gas_count

An integer indicating the number of gases in the mixture.

property gas_fractions

Get or set a tuple of numbers the fractions of gases in the gas gap layer.

property identifier

Get or set a text string for the unique object identifier.

This must be a UUID in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and it remains constant as the object is mutated, copied, and serialized to different formats (eg. therm XML). As such, this property is used to reference the object across a Model.

property molecular_weight

Get the gas molecular weight.

property prandtl

Prandtl number of the gas at 0C.

property protected

Get or set a boolean for whether the material is protected in THERM.

property pure_gases

Get or set a tuple of text describing the gases in the gas gap layer.

property specific_heat

Specific heat of the gas at 0C [J/kg-K].

property user_data

Get or set an optional dictionary for additional meta data for this object.

This will be None until it has been set. All keys and values of this dictionary should be of a standard Python type to ensure correct serialization of the object to/from JSON (eg. str, float, int, list, dict)

property viscosity

Viscosity of the gas at 0C [kg/m-s].

class fairyfly_therm.material.gas.PureGas(conductivity_coeff_a, viscosity_coeff_a, specific_heat_coeff_a, conductivity_coeff_b=0, viscosity_coeff_b=0, specific_heat_coeff_b=0, conductivity_coeff_c=0, viscosity_coeff_c=0, specific_heat_coeff_c=0, specific_heat_ratio=1.0, molecular_weight=20.0, identifier=None)[source]

Bases: _ResourceObjectBase

Custom gas gap layer.

This object allows you to specify specific values for conductivity, viscosity and specific heat through the following formula:

property = A + (B * T) + (C * T ** 2)

where:

  • A, B, and C = regression coefficients for the gas

  • T = temperature [K]

Note that setting properties B and C to 0 will mean the property will be equal to the A coefficient.

Parameters:
  • conductivity_coeff_a – First conductivity coefficient. Or conductivity in [W/m-K] if b and c coefficients are 0.

  • viscosity_coeff_a – First viscosity coefficient. Or viscosity in [kg/m-s] if b and c coefficients are 0.

  • specific_heat_coeff_a – First specific heat coefficient. Or specific heat in [J/kg-K] if b and c coefficients are 0.

  • conductivity_coeff_b – Second conductivity coefficient. Default = 0.

  • viscosity_coeff_b – Second viscosity coefficient. Default = 0.

  • specific_heat_coeff_b – Second specific heat coefficient. Default = 0.

  • conductivity_coeff_c – Third conductivity coefficient. Default = 0.

  • viscosity_coeff_c – Third viscosity coefficient. Default = 0.

  • specific_heat_coeff_c – Third specific heat coefficient. Default = 0.

  • specific_heat_ratio – A number for the the ratio of the specific heat at constant pressure, to the specific heat at constant volume. Default is 1.0 for Air.

  • molecular_weight – Number between 20 and 200 for the mass of 1 mol of the substance in grams. Default is 20.0.

  • identifier – Text string for a unique object ID. Must be a UUID in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. If None, a UUID will automatically be generated. (Default: None).

Properties:
  • identifier

  • display_name

  • conductivity_coeff_a

  • viscosity_coeff_a

  • specific_heat_coeff_a

  • conductivity_coeff_b

  • viscosity_coeff_b

  • specific_heat_coeff_b

  • conductivity_coeff_c

  • viscosity_coeff_c

  • specific_heat_coeff_c

  • specific_heat_ratio

  • molecular_weight

  • protected

  • user_data

Usage:

co2_mat = PureGas(0.0146, 0.000014, 827.73)
co2_mat.display_name = 'CO2'
co2_gap.specific_heat_ratio = 1.4
co2_gap.molecular_weight = 44
print(co2_gap)
ToString()

Overwrite .NET ToString.

conductivity_at_temperature(t_kelvin)[source]

Get the conductivity of the gas [W/m-K] at a given Kelvin temperature.

density_at_temperature(t_kelvin, pressure=101325)[source]

Get the density of the gas [kg/m3] at a given temperature and pressure.

This method uses the ideal gas law to estimate the density.

Parameters:
  • t_kelvin – The average temperature of the gas cavity in Kelvin.

  • pressure – The average pressure of the gas cavity in Pa. Default is 101325 Pa for standard pressure at sea level.

duplicate()

Get a copy of this object.

classmethod from_dict(data)[source]

Create a PureGas from a dictionary.

Parameters:

data – A python dictionary in the following format

{
"type": 'PureGas',
"identifier": '7b4a5a47-ebec-4d95-b028-a78485130c34',
"display_name": 'CO2'
"conductivity_coeff_a": 0.0146,
"viscosity_coeff_a": 0.000014,
"specific_heat_coeff_a": 827.73,
"specific_heat_ratio": 1.4
"molecular_weight": 44
}
classmethod from_therm_xml(xml_element)[source]

Create PureGas from an XML element of a THERM PureGas material.

Parameters:

xml_element – An XML element of a THERM PureGas material.

classmethod from_therm_xml_str(xml_str)[source]

Create a PureGas from an XML text string of a THERM PureGas.

Parameters:

xml_str – An XML text string of a THERM PureGas.

lock()
prandtl_at_temperature(t_kelvin)[source]

Get the Prandtl number of the gas at a given Kelvin temperature.

specific_heat_at_temperature(t_kelvin)[source]

Get the specific heat of the gas [J/kg-K] at a given Kelvin temperature.

to_dict()[source]

PureGas dictionary representation.

to_therm_xml(gases_element=None)[source]

Get an THERM XML element of the gas.

Parameters:

gases_element – An optional XML Element for the Gases to which the generated objects will be added. If None, a new XML Element will be generated.

<PureGas>
    <UUID>8d33196f-f052-46e6-8353-bccb9a779f9c</UUID>
    <Name>Air</Name>
    <Protected>true</Protected>
    <Properties>
        <MolecularWeight>28.97</MolecularWeight>
        <SpecificHeatRatio>1.4</SpecificHeatRatio>
        <Conductivity>
            <A>0.002873</A>
            <B>7.76e-05</B>
            <C>0</C>
        </Conductivity>
        <Viscosity>
            <A>3.723e-06</A>
            <B>4.94e-08</B>
            <C>0</C>
        </Viscosity>
        <SpecificHeat>
            <A>1002.737</A>
            <B>0.012324</B>
            <C>0</C>
        </SpecificHeat>
    </Properties>
</PureGas>
to_therm_xml_str()[source]

Get an THERM XML string of the gas.

unlock()
viscosity_at_temperature(t_kelvin)[source]

Get the viscosity of the gas [kg/m-s] at a given Kelvin temperature.

property conductivity

Conductivity of the gas in the absence of convection at 0C [W/m-K].

property conductivity_coeff_a

Get or set the first conductivity coefficient.

property conductivity_coeff_b

Get or set the second conductivity coefficient.

property conductivity_coeff_c

Get or set the third conductivity coefficient.

property density

Density of the gas at 0C and sea-level pressure [J/kg-K].

property display_name

Get or set a string for the object name without any character restrictions.

If not set, this will be equal to the identifier.

property identifier

Get or set a text string for the unique object identifier.

This must be a UUID in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and it remains constant as the object is mutated, copied, and serialized to different formats (eg. therm XML). As such, this property is used to reference the object across a Model.

property molecular_weight

Get or set the molecular weight.

property prandtl

Prandtl number of the gas at 0C.

property protected

Get or set a boolean for whether the material is protected in THERM.

property specific_heat

Specific heat of the gas at 0C [J/kg-K].

property specific_heat_coeff_a

Get or set the first specific heat coefficient.

property specific_heat_coeff_b

Get or set the second specific heat coefficient.

property specific_heat_coeff_c

Get or set the third specific heat coefficient.

property specific_heat_ratio

Get or set the specific heat ratio.

property user_data

Get or set an optional dictionary for additional meta data for this object.

This will be None until it has been set. All keys and values of this dictionary should be of a standard Python type to ensure correct serialization of the object to/from JSON (eg. str, float, int, list, dict)

property viscosity

Viscosity of the gas at 0C [kg/m-s].

property viscosity_coeff_a

Get or set the first viscosity coefficient.

property viscosity_coeff_b

Get or set the second viscosity coefficient.

property viscosity_coeff_c

Get or set the third viscosity coefficient.