Skip to content

rgfrosh.thermo

ThermoInterface

Bases: Protocol

Class defining the required interface for calculating mixture thermodynamic properties.

TP: Tuple[float, float] abstractmethod property writable

Get/set temperature [K] and pressure [Pa].

mean_molecular_weight: float abstractmethod property

The mean molecular weight (molar mass) [kg/kmol].

density_mass: float abstractmethod property

(Mass) density [kg/m3].

cp_mass: float abstractmethod property

Specific heat capacity at constant pressure [J/kg/K].

enthalpy_mass: float abstractmethod property

Specific enthalpy [J/kg].

isothermal_compressibility: float abstractmethod property

Isothermal compressibility [1/Pa].

thermal_expansion_coeff: float abstractmethod property

Thermal expansion coefficient [1/K].

CPInterface

Bases: ThermoInterface

0.1.4

Note

Only available if CoolProp is installed.

Wrapper for CoolProp.AbstractState objects that accounts for differing property names and automatically adjusts units for mean_molecular_weight.

Source code in rgfrosh\thermo.py
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
class CPInterface(ThermoInterface):
    """
    :octicons-tag-24: 0.1.4

    !!! Note
        Only available if `CoolProp` is installed.

    Wrapper for `CoolProp.AbstractState` objects that accounts for
    differing property names and automatically adjusts units for
    `mean_molecular_weight`.
    """

    def __init__(self, state: CP.AbstractState):
        self.state = state

    @property
    def mean_molecular_weight(self):
        return self.state.molar_mass() * 1e3  # [kg/mol] to [kg/kmol]

    @property
    def TP(self):
        return self.state.T(), self.state.p()

    @TP.setter
    def TP(self, value):
        T, P = value
        self.state.update(CP.PT_INPUTS, P, T)

    @property
    def density_mass(self):
        return self.state.rhomass()

    @property
    def cp_mass(self):
        return self.state.cpmass()

    @property
    def enthalpy_mass(self):
        return self.state.hmass()

    @property
    def isothermal_compressibility(self):
        return self.state.isothermal_compressibility()

    @property
    def thermal_expansion_coeff(self):
        return self.state.isobaric_expansion_coefficient()