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 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
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
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         |  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)