Skip to content

polykin.thermo.eos¤

Z_cubic_roots ¤

Z_cubic_roots(
    u: float, w: float, A: float, B: float
) -> FloatVector

Find the compressibility factor roots of a cubic EOS.

\[\begin{gathered} Z^3 + c_2 Z^2 + c_1 Z + c_0 = 0 \\ c_2 = -(1 + B - u B) \\ c_1 = A + w B^2 - u B - u B^2 \\ c_0 = -(A B + w B^2 + w B^3) \\ A = \frac{a_m P}{R^2 T^2} \\ B = \frac{b_m P}{R T} \end{gathered}\]
Equation \(u\) \(w\)
Redlich-Kwong 1 0
Soave-Redlich-Kwong 1 0
Peng-Robinson 2 -1

References

  • RC Reid, JM Prausniz, and BE Poling. The properties of gases & liquids 4th edition, 1986, p. 42.
PARAMETER DESCRIPTION
u

Parameter of polynomial equation.

TYPE: float

w

Parameter of polynomial equation.

TYPE: float

A

Parameter of polynomial equation.

TYPE: float

B

Parameter of polynomial equation.

TYPE: float

RETURNS DESCRIPTION
FloatVector

Compressibility factor(s) of the coexisting phases. If there are two phases, the first result is the lowest value (liquid).

Source code in src/polykin/thermo/eos/cubic.py
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
def Z_cubic_roots(
    u: float,
    w: float,
    A: float,
    B: float
) -> FloatVector:
    r"""Find the compressibility factor roots of a cubic EOS.

    \begin{gathered}
        Z^3 + c_2 Z^2 + c_1 Z + c_0 = 0 \\
        c_2 = -(1 + B - u B) \\
        c_1 = A + w B^2 - u B - u B^2 \\
        c_0 = -(A B + w B^2 + w B^3) \\
        A = \frac{a_m P}{R^2 T^2} \\
        B = \frac{b_m P}{R T}
    \end{gathered}

    | Equation            | $u$ | $w$ |
    |---------------------|:---:|:---:|
    | Redlich-Kwong       |  1  |  0  |
    | Soave-Redlich-Kwong |  1  |  0  |
    | Peng-Robinson       |  2  | -1  |

    **References**

    *   RC Reid, JM Prausniz, and BE Poling. The properties of gases &
        liquids 4th edition, 1986, p. 42.

    Parameters
    ----------
    u : float
        Parameter of polynomial equation.
    w : float
        Parameter of polynomial equation.
    A : float
        Parameter of polynomial equation.
    B : float
        Parameter of polynomial equation.

    Returns
    -------
    FloatVector
        Compressibility factor(s) of the coexisting phases. If there are two
        phases, the first result is the lowest value (liquid).
    """
    c3 = 1.0
    c2 = -(1 + B - u*B)
    c1 = (A + w*B**2 - u*B - u*B**2)
    c0 = -(A*B + w*B**2 + w*B**3)

    roots = np.roots((c3, c2, c1, c0))
    roots = [x.real for x in roots if (abs(x.imag) < eps and x.real > B)]

    Z = [min(roots)]
    if len(roots) > 1:
        Z.append(max(roots))

    return np.array(Z)