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
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
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
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)