Skip to content

polykin.thermo.flash¤

residual_Rachford_Rice ¤

residual_Rachford_Rice(
    beta: float,
    K: FloatVector,
    z: FloatVector,
    derivative: bool = False,
) -> tuple[float, ...]

Rachford-Rice flash residual function and its derivative.

The residual function is defined as:

\[ F = \sum_i \frac{z_i(K_i - 1)}{1 + \beta(K_i - 1)} \]

and the derivative with respect to \(\beta\) is:

\[ \frac{\partial F}{\partial \beta} = -\sum_i \frac{z_i(K_i - 1)^2}{(1 + \beta(K_i - 1))^2} \]

where \(K\) is the vector of K-values, \(z\) is the vector of feed mole fractions, and \(\beta\) is the vapor phase fraction.

References

  • Rachford, H.H., and J.D. Rice. "Procedure for Use of Electronic Digital Computers in Calculating Flash Vaporization Hydrocarbon Equilibrium", J. Pet. Technol. 4 (1952): 19-3.
PARAMETER DESCRIPTION
beta

Vapor phase fraction [mol/mol].

TYPE: float

K

K-values.

TYPE: FloatVector(N)

z

Feed mole fractions [mol/mol].

TYPE: FloatVector(N)

derivative

Flag specifying if the derivative should be returned.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
tuple[float, ...]

Tuple with residual and derivative, (F, dF).

See Also
Source code in src/polykin/thermo/flash/vle.py
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
604
605
606
607
608
609
610
611
612
613
def residual_Rachford_Rice(
    beta: float,
    K: FloatVector,
    z: FloatVector,
    derivative: bool = False,
) -> tuple[float, ...]:
    r"""Rachford-Rice flash residual function and its derivative.

    The residual function is defined as:

    $$ F = \sum_i \frac{z_i(K_i - 1)}{1 + \beta(K_i - 1)} $$

    and the derivative with respect to $\beta$ is:

    $$ \frac{\partial F}{\partial \beta} =
       -\sum_i \frac{z_i(K_i - 1)^2}{(1 + \beta(K_i - 1))^2} $$

    where $K$ is the vector of K-values, $z$ is the vector of feed mole
    fractions, and $\beta$ is the vapor phase fraction.

    **References**

    *  Rachford, H.H., and J.D. Rice. "Procedure for Use of Electronic Digital
       Computers in Calculating Flash Vaporization Hydrocarbon Equilibrium",
       J. Pet. Technol. 4 (1952): 19-3.

    Parameters
    ----------
    beta : float
        Vapor phase fraction [mol/mol].
    K : FloatVector(N)
        K-values.
    z : FloatVector(N)
        Feed mole fractions [mol/mol].
    derivative : bool
        Flag specifying if the derivative should be returned.

    Returns
    -------
    tuple[float, ...]
        Tuple with residual and derivative, `(F, dF)`.

    See Also
    --------
    * [`solve_Rachford_Rice`](solve_Rachford_Rice.md): related method to solve
      the equation.
    """
    F = np.sum(z * (K - 1) / (1 + beta * (K - 1)))

    if not derivative:
        return (F,)
    else:
        dF = -np.sum(z * (K - 1) ** 2 / (1 + beta * (K - 1)) ** 2)
        return (F, dF)