yaeos__equilibria_flash_second_order Module

Second-order isothermal flash

Description

Two-phase flash at specified temperature and pressure by direct minimization of the reduced Gibbs energy, following the formulation of Michelsen (1982).

The minimization variables are the scaled heavy-phase mole numbers , so the light phase is and the admissible region is . The Gibbs energy is minimized with a Newton step based on a modified Cholesky decomposition (Murray), combined with a line search that first computes the largest step compatible with the bounds and then backtracks on the Gibbs energy.

For ArModel the heavy phase is always evaluated with the liquid root. The light phase uses the stable root by default, but it can be forced to the liquid root with light_root="liquid" (useful for liquid-liquid splits). For GeModel, both phases are described by activity coefficients and the initial split is obtained from stability analysis.

Examples

result = flash_second_order(model, z, T, P)

References

  1. M. L. Michelsen, “The isothermal flash problem. Part II. Phase-split calculation”, Fluid Phase Equilibria 9 (1982) 21-40.
  2. W. Murray (ed.), Numerical Methods for Unconstrained Optimization, Academic Press (1972).

Uses

  • module~~yaeos__equilibria_flash_second_order~~UsesGraph module~yaeos__equilibria_flash_second_order yaeos__equilibria_flash_second_order module~yaeos__constants yaeos__constants module~yaeos__equilibria_flash_second_order->module~yaeos__constants module~yaeos__equilibria_auxiliar yaeos__equilibria_auxiliar module~yaeos__equilibria_flash_second_order->module~yaeos__equilibria_auxiliar module~yaeos__equilibria_equilibrium_state yaeos__equilibria_equilibrium_state module~yaeos__equilibria_flash_second_order->module~yaeos__equilibria_equilibrium_state module~yaeos__equilibria_rachford_rice yaeos__equilibria_rachford_rice module~yaeos__equilibria_flash_second_order->module~yaeos__equilibria_rachford_rice module~yaeos__equilibria_stability yaeos__equilibria_stability module~yaeos__equilibria_flash_second_order->module~yaeos__equilibria_stability module~yaeos__models_ar yaeos__models_ar module~yaeos__equilibria_flash_second_order->module~yaeos__models_ar module~yaeos__models_base yaeos__models_base module~yaeos__equilibria_flash_second_order->module~yaeos__models_base module~yaeos__models_ge yaeos__models_ge module~yaeos__equilibria_flash_second_order->module~yaeos__models_ge iso_fortran_env iso_fortran_env module~yaeos__constants->iso_fortran_env module~yaeos__equilibria_auxiliar->module~yaeos__constants module~yaeos__equilibria_auxiliar->module~yaeos__models_ar module~yaeos__equilibria_auxiliar->module~yaeos__models_base module~yaeos__equilibria_equilibrium_state->module~yaeos__constants module~yaeos__equilibria_rachford_rice->module~yaeos__constants module~yaeos__equilibria_stability->module~yaeos__constants module~yaeos__equilibria_stability->module~yaeos__models_ar module~yaeos__equilibria_stability->module~yaeos__models_base module~yaeos__equilibria_stability->module~yaeos__models_ge module~yaeos__models_ar->module~yaeos__constants module~yaeos__models_ar->module~yaeos__models_base module~yaeos__substance yaeos__substance module~yaeos__models_base->module~yaeos__substance module~yaeos__models_ge->module~yaeos__constants module~yaeos__models_ge->module~yaeos__models_base module~yaeos__substance->module~yaeos__constants

Used by

  • module~~yaeos__equilibria_flash_second_order~~UsedByGraph module~yaeos__equilibria_flash_second_order yaeos__equilibria_flash_second_order module~yaeos__equilibria yaeos__equilibria module~yaeos__equilibria->module~yaeos__equilibria_flash_second_order module~yaeos yaeos module~yaeos->module~yaeos__equilibria

Functions

public function flash_second_order(model, z, T, P_spec, k0, light_root, iters, tol, max_iters) result(flash)

Find a two-phase split at fixed temperature and pressure by minimizing the reduced Gibbs energy with a second-order method.

Read more…

Arguments

Type IntentOptional Attributes Name
class(BaseModel), intent(in) :: model

Thermodynamic model

real(kind=pr), intent(in) :: z(:)

Global mole fractions

real(kind=pr), intent(in) :: T

Temperature [K]

real(kind=pr), intent(in) :: P_spec

Pressure [bar]

real(kind=pr), intent(in), optional :: k0(:)

Initial K-factors (y/x)

character(len=*), intent(in), optional :: light_root

Root of the light phase for ArModel ("stable" or "liquid")

integer, intent(out), optional :: iters

Iterations used

real(kind=pr), intent(in), optional :: tol

Convergence tolerance

integer, intent(in), optional :: max_iters

Maximum iterations

Return Value type(EquilibriumState)


Subroutines

private subroutine evaluate_gibbs(model, z, l, T, P, light_root, Gibbs, g, H)

Evaluate the reduced Gibbs energy, its gradient and its Hessian with respect to the heavy-phase mole numbers.

Read more…

Arguments

Type IntentOptional Attributes Name
class(BaseModel), intent(in) :: model

Thermodynamic model.

real(kind=pr), intent(in) :: z(:)

Global mole numbers (1 mol feed)

real(kind=pr), intent(in) :: l(:)

Heavy-phase mole numbers

real(kind=pr), intent(in) :: T

Temperature [K]

real(kind=pr), intent(in) :: P

Pressure [bar]

character(len=*), intent(in) :: light_root

Volume-root choice for the light phase.

real(kind=pr), intent(out) :: Gibbs

real(kind=pr), intent(out) :: g(:)

Gradient

real(kind=pr), intent(out) :: H(:,:)

Hessian

private subroutine solve_modified_cholesky(H, b, x)

Solve with a modified Cholesky factorisation after Murray (1972), Sec. 4.9, with the choice of from Gill and Murray (1974).

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=pr), intent(in) :: H(:,:)

Hessian

real(kind=pr), intent(in) :: b(:)

Right-hand side

real(kind=pr), intent(out) :: x(:)

Variable vector