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
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
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)