Skip to content

coolprop_interface

Fluid property setup

FluidProperties

Fluid properties setup

Source code in process/core/coolprop_interface.py
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
class FluidProperties:
    """Fluid properties setup"""

    def __init__(self, coolprop_inputs: list[str | float]):
        self._coolprop_inputs = tuple(coolprop_inputs)

    @property
    def temperature(self):
        """Fluid temperature [K]"""
        return _temperature(self._coolprop_inputs)

    @property
    def pressure(self):
        """Fluid pressure [Pa]"""
        return _pressure(self._coolprop_inputs)

    @property
    def density(self):
        """Fluid density [kg/m3]"""
        return _density(self._coolprop_inputs)

    @property
    def enthalpy(self):
        """Fluid specific enthalpy [J/kg]"""
        return _enthalpy(self._coolprop_inputs)

    @property
    def entropy(self):
        """Fluid entropy [J/kg/K]"""
        return _entropy(self._coolprop_inputs)

    @property
    def specific_heat_const_p(self):
        """Fluid specific heat capacity at constant pressure [J/kg/K]"""
        return _specific_heat_const_p(self._coolprop_inputs)

    @property
    def specific_heat_const_v(self):
        """Fluid specific heat capacity at constant volume [J/kg/K]"""
        return _specific_heat_const_v(self._coolprop_inputs)

    @property
    def viscosity(self):
        """Fluid viscosity [Pa.s]"""
        return _viscosity(self._coolprop_inputs)

    @property
    def thermal_conductivity(self):
        """Fluid thermal conductivity [W/m/K]"""
        return _thermal_conductivity(self._coolprop_inputs)

    @classmethod
    def of(
        cls,
        fluid_name: str,
        *,
        temperature: float | None = None,
        pressure: float | None = None,
        entropy: float | None = None,
        vapor_quality: float | None = None,
    ):
        """Calculates the fluid properties of a fluid given its temperature and pressure.

        Parameters
        ----------
        fluid_name :
            the name of the fluid to calculate properties for, e.g. 'Helium' or 'Water'.
        temperature :
            the current temperature [K] of the fluid to calculate the properties.
        pressure :
            the current pressure [Pa] of the fluid to calculate the properties.
        entropy :
            the current entropy [J/kg/K] of the fluid to calculate the properties.
        vapor_quality :
            the molar vapor quality [mol/mol] of the fluid to calculate the properties.
            `[0, 1]`, where `0` is a saturated liquid and `1` is a saturated vapor.
        """
        coolprop_inputs = []

        if temperature is not None:
            coolprop_inputs += ["T", temperature]

        if pressure is not None:
            coolprop_inputs += ["P", pressure]

        if entropy is not None:
            coolprop_inputs += ["S", entropy]

        if vapor_quality is not None:
            coolprop_inputs += ["Q", vapor_quality]

        coolprop_inputs.append(fluid_name.title())

        return cls(coolprop_inputs)

temperature property

Fluid temperature [K]

pressure property

Fluid pressure [Pa]

density property

Fluid density [kg/m3]

enthalpy property

Fluid specific enthalpy [J/kg]

entropy property

Fluid entropy [J/kg/K]

specific_heat_const_p property

Fluid specific heat capacity at constant pressure [J/kg/K]

specific_heat_const_v property

Fluid specific heat capacity at constant volume [J/kg/K]

viscosity property

Fluid viscosity [Pa.s]

thermal_conductivity property

Fluid thermal conductivity [W/m/K]

of(fluid_name, *, temperature=None, pressure=None, entropy=None, vapor_quality=None) classmethod

Calculates the fluid properties of a fluid given its temperature and pressure.

Parameters:

Name Type Description Default
fluid_name str

the name of the fluid to calculate properties for, e.g. 'Helium' or 'Water'.

required
temperature float | None

the current temperature [K] of the fluid to calculate the properties.

None
pressure float | None

the current pressure [Pa] of the fluid to calculate the properties.

None
entropy float | None

the current entropy [J/kg/K] of the fluid to calculate the properties.

None
vapor_quality float | None

the molar vapor quality [mol/mol] of the fluid to calculate the properties. [0, 1], where 0 is a saturated liquid and 1 is a saturated vapor.

None
Source code in process/core/coolprop_interface.py
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
@classmethod
def of(
    cls,
    fluid_name: str,
    *,
    temperature: float | None = None,
    pressure: float | None = None,
    entropy: float | None = None,
    vapor_quality: float | None = None,
):
    """Calculates the fluid properties of a fluid given its temperature and pressure.

    Parameters
    ----------
    fluid_name :
        the name of the fluid to calculate properties for, e.g. 'Helium' or 'Water'.
    temperature :
        the current temperature [K] of the fluid to calculate the properties.
    pressure :
        the current pressure [Pa] of the fluid to calculate the properties.
    entropy :
        the current entropy [J/kg/K] of the fluid to calculate the properties.
    vapor_quality :
        the molar vapor quality [mol/mol] of the fluid to calculate the properties.
        `[0, 1]`, where `0` is a saturated liquid and `1` is a saturated vapor.
    """
    coolprop_inputs = []

    if temperature is not None:
        coolprop_inputs += ["T", temperature]

    if pressure is not None:
        coolprop_inputs += ["P", pressure]

    if entropy is not None:
        coolprop_inputs += ["S", entropy]

    if vapor_quality is not None:
        coolprop_inputs += ["Q", vapor_quality]

    coolprop_inputs.append(fluid_name.title())

    return cls(coolprop_inputs)