Skip to content

polykin.thermo.eos¤

IdealGas ¤

Ideal gas equation of state.

This EOS is based on the following \(P(v,T)\) relationship:

\[ P = \frac{R T}{v} \]

where \(P\) is the pressure, \(T\) is the temperature, and \(v\) is the molar volume.

Important

The ideal gas model is very convenient, but its validity is limited to low pressures and high temperatures.

Source code in src/polykin/thermo/eos/idealgas.py
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
class IdealGas(GasEoS):
    r"""Ideal gas equation of state.

    This EOS is based on the following $P(v,T)$ relationship:

    $$ P = \frac{R T}{v} $$

    where $P$ is the pressure, $T$ is the temperature, and $v$ is the molar
    volume.

    !!! important

        The ideal gas model is very convenient, but its validity is limited to
        low pressures and high temperatures.
    """

    def Z(self,
          T=None,
          P=None,
          y=None):
        r"""Calculate the compressibility factor of the fluid.

        Returns
        -------
        float
            Compressibility factor of the vapor.
        """
        return 1.

    def P(self,
          T: Union[float, FloatArray],
          v: Union[float, FloatArray],
          y=None
          ) -> Union[float, FloatArray]:
        r"""Calculate the pressure of the fluid.

        Parameters
        ----------
        T : float | FloatArray
            Temperature. Unit = K.
        v : float | FloatArray
            Molar volume. Unit = m³/mol.

        Returns
        -------
        float | FloatArray
             Pressure. Unit = Pa.
        """
        return R*T/v

    def phiV(self,
             T=None,
             P=None,
             y=None
             ) -> FloatVector:
        r"""Calculate the fugacity coefficients of all components in the vapor
        phase.

        Returns
        -------
        FloatVector
            Fugacity coefficients of all components.
        """
        if y is None:
            return np.array([1.])
        else:
            return np.ones_like(y)

    def DA(self, T, V, n, v0):
        nT = n.sum()
        return -nT*R*T*log(V/(nT*v0))

DA ¤

DA(T, V, n, v0)

Calculate the departure of Helmholtz energy.

\[ A(T,V,n) - A^{\circ}(T,V,n)\]
PARAMETER DESCRIPTION
T

Temperature. Unit = K.

TYPE: float

V

Volume. Unit = m³.

TYPE: float

n

Mole amounts of all components. Unit = mol.

TYPE: FloatVector

v0

Molar volume in reference state. Unit = m³/mol.

TYPE: float

RETURNS DESCRIPTION
FloatVector

Helmholtz energy departure, \(A - A^{\circ}\). Unit = J.

Source code in src/polykin/thermo/eos/idealgas.py
86
87
88
def DA(self, T, V, n, v0):
    nT = n.sum()
    return -nT*R*T*log(V/(nT*v0))

P ¤

P(
    T: Union[float, FloatArray],
    v: Union[float, FloatArray],
    y=None,
) -> Union[float, FloatArray]

Calculate the pressure of the fluid.

PARAMETER DESCRIPTION
T

Temperature. Unit = K.

TYPE: float | FloatArray

v

Molar volume. Unit = m³/mol.

TYPE: float | FloatArray

RETURNS DESCRIPTION
float | FloatArray

Pressure. Unit = Pa.

Source code in src/polykin/thermo/eos/idealgas.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
def P(self,
      T: Union[float, FloatArray],
      v: Union[float, FloatArray],
      y=None
      ) -> Union[float, FloatArray]:
    r"""Calculate the pressure of the fluid.

    Parameters
    ----------
    T : float | FloatArray
        Temperature. Unit = K.
    v : float | FloatArray
        Molar volume. Unit = m³/mol.

    Returns
    -------
    float | FloatArray
         Pressure. Unit = Pa.
    """
    return R*T/v

Z ¤

Z(T=None, P=None, y=None)

Calculate the compressibility factor of the fluid.

RETURNS DESCRIPTION
float

Compressibility factor of the vapor.

Source code in src/polykin/thermo/eos/idealgas.py
34
35
36
37
38
39
40
41
42
43
44
45
def Z(self,
      T=None,
      P=None,
      y=None):
    r"""Calculate the compressibility factor of the fluid.

    Returns
    -------
    float
        Compressibility factor of the vapor.
    """
    return 1.

fV ¤

fV(T: float, P: float, y: FloatVector) -> FloatVector

Calculate the fugacity of all components in the vapor phase.

\[ \hat{f}_i = \hat{\phi}_i y_i P \]

\(\hat{f}_i\) is the fugacity in the vapor phase, \(\hat{\phi}_i(T,P,y)\) is the fugacity coefficient, \(P\) is the pressure, and \(y_i\) is the mole fraction in the vapor phase.

PARAMETER DESCRIPTION
T

Temperature. Unit = K.

TYPE: float

P

Pressure. Unit = Pa.

TYPE: float

y

Mole fractions of all components. Unit = mol/mol.

TYPE: FloatVector

RETURNS DESCRIPTION
FloatVector

Fugacity coefficients of all components.

Source code in src/polykin/thermo/eos/base.py
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
def fV(self,
        T: float,
        P: float,
        y: FloatVector
       ) -> FloatVector:
    r"""Calculate the fugacity of all components in the vapor phase.

    $$ \hat{f}_i = \hat{\phi}_i y_i P $$

    $\hat{f}_i$ is the fugacity in the vapor phase, $\hat{\phi}_i(T,P,y)$
    is the fugacity coefficient, $P$ is the pressure, and $y_i$ is the mole
    fraction in the vapor phase.

    Parameters
    ----------
    T : float
        Temperature. Unit = K.
    P : float
        Pressure. Unit = Pa.
    y : FloatVector
        Mole fractions of all components. Unit = mol/mol.

    Returns
    -------
    FloatVector
        Fugacity coefficients of all components.
    """
    return self.phiV(T, P, y)*y*P

phiV ¤

phiV(T=None, P=None, y=None) -> FloatVector

Calculate the fugacity coefficients of all components in the vapor phase.

RETURNS DESCRIPTION
FloatVector

Fugacity coefficients of all components.

Source code in src/polykin/thermo/eos/idealgas.py
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
def phiV(self,
         T=None,
         P=None,
         y=None
         ) -> FloatVector:
    r"""Calculate the fugacity coefficients of all components in the vapor
    phase.

    Returns
    -------
    FloatVector
        Fugacity coefficients of all components.
    """
    if y is None:
        return np.array([1.])
    else:
        return np.ones_like(y)

v ¤

v(T: float, P: float, y: FloatVector) -> float

Calculate the molar volume the fluid.

\[ v = \frac{Z R T}{P} \]

where \(v\) is the molar volue, \(Z\) is the compressibility factor, \(T\) is the temperature, \(P\) is the pressure, and \(y\) is the mole fraction vector.

PARAMETER DESCRIPTION
T

Temperature. Unit = K.

TYPE: float

P

Pressure. Unit = Pa.

TYPE: float

y

Mole fractions of all components. Unit = mol/mol.

TYPE: FloatVector

RETURNS DESCRIPTION
float

Molar volume of the fluid. Unit = m³/mol.

Source code in src/polykin/thermo/eos/base.py
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
def v(self,
      T: float,
      P: float,
      y: FloatVector
      ) -> float:
    r"""Calculate the molar volume the fluid.

    $$ v = \frac{Z R T}{P} $$

    where $v$ is the molar volue, $Z$ is the compressibility factor,
    $T$ is the temperature, $P$ is the pressure, and $y$ is the mole
    fraction vector.

    Parameters
    ----------
    T : float
        Temperature. Unit = K.
    P : float
        Pressure. Unit = Pa.
    y : FloatVector
        Mole fractions of all components. Unit = mol/mol.

    Returns
    -------
    float
        Molar volume of the fluid. Unit = m³/mol.
    """
    return self.Z(T, P, y)*R*T/P

Examples¤

Estimate the molar volume of a gas at 0°C and 1 atm.

from polykin.thermo.eos import IdealGas

eos = IdealGas()
v = eos.v(T=273.15, P=1.01325e5, y=None)

print(f"{v:.2e} m³/mol")
2.24e-02 m³/mol