yaeos__equilibria_boundaries_phase_envelopes_px3 Module

Three-phase PX envelopes

Continue a three-phase boundary at fixed temperature while pressure and feed composition vary.

Description

The overall feed is interpolated between two limiting compositions. A continuation solve follows the three-phase equilibrium equations and returns states in PXEnvel3.

Examples

envelope = px_envelope_3ph(model, z0, zi, T, x0, y0, w0, beta0, P0, a0, ns0, dS0, points)

Uses

  • module~~yaeos__equilibria_boundaries_phase_envelopes_px3~~UsesGraph module~yaeos__equilibria_boundaries_phase_envelopes_px3 yaeos__equilibria_boundaries_phase_envelopes_px3 module~yaeos__constants yaeos__constants module~yaeos__equilibria_boundaries_phase_envelopes_px3->module~yaeos__constants module~yaeos__equilibria_boundaries_auxiliar yaeos__equilibria_boundaries_auxiliar module~yaeos__equilibria_boundaries_phase_envelopes_px3->module~yaeos__equilibria_boundaries_auxiliar module~yaeos__equilibria_equilibrium_state yaeos__equilibria_equilibrium_state module~yaeos__equilibria_boundaries_phase_envelopes_px3->module~yaeos__equilibria_equilibrium_state module~yaeos__math yaeos__math module~yaeos__equilibria_boundaries_phase_envelopes_px3->module~yaeos__math module~yaeos__models_ar yaeos__models_ar module~yaeos__equilibria_boundaries_phase_envelopes_px3->module~yaeos__models_ar iso_fortran_env iso_fortran_env module~yaeos__constants->iso_fortran_env module~yaeos__equilibria_boundaries_auxiliar->module~yaeos__constants module~yaeos__equilibria_boundaries_auxiliar->module~yaeos__math module~yaeos__equilibria_equilibrium_state->module~yaeos__constants module~yaeos__math->module~yaeos__constants module~yaeos__math_continuation yaeos__math_continuation module~yaeos__math->module~yaeos__math_continuation module~yaeos__math_linalg yaeos__math_linalg module~yaeos__math->module~yaeos__math_linalg module~yaeos__models_ar->module~yaeos__constants module~yaeos__models_base yaeos__models_base module~yaeos__models_ar->module~yaeos__models_base module~yaeos__math_continuation->module~yaeos__constants module~yaeos__math_continuation->module~yaeos__math_linalg module~yaeos__math_linalg->module~yaeos__constants module~yaeos__substance yaeos__substance module~yaeos__models_base->module~yaeos__substance module~yaeos__substance->module~yaeos__constants

Used by

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

Variables

Type Visibility Attributes Name Initial
real(kind=pr), private, parameter :: lnK_min = 2.0_pr

Log-K threshold (currently unused in this module).


Derived Types

type, public ::  PXEnvel3

Three-phase envelope at constant temperature. Each array stores one value per envelope point.

Read more…

Components

Type Visibility Attributes Name Initial
real(kind=pr), public, allocatable :: P(:)

Pressure [bar]

real(kind=pr), public, allocatable :: S(:)

Specified value to solve point i

real(kind=pr), public :: T

Temperature [K]

real(kind=pr), public, allocatable :: alpha(:)

Mole fraction of other fluid

real(kind=pr), public, allocatable :: beta(:)

Mole fraction between phase x and phase y

integer, public, allocatable :: ns(:)

Specified variable to solve point i

real(kind=pr), public, allocatable :: w(:,:)

Mole fraction of phase w

real(kind=pr), public, allocatable :: x(:,:)

Mole fraction of phase x

real(kind=pr), public, allocatable :: y(:,:)

Mole fraction of phase y


Functions

public function px_envelope_3ph(model, z0, zi, T, x0, y0, w0, beta0, P0, a0, ns0, dS0, points) result(envelope)

Trace a three-phase pressure-composition envelope at fixed temperature. The overall mixture varies as ; the initial phase states and continuation step define the branch. Points are stored only after the equilibrium equations converge.

Read more…

Arguments

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

Residual Helmholtz model.

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

First limiting composition.

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

Second limiting composition.

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

Fixed temperature [K].

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

Initial composition of phase x.

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

Initial composition of phase y.

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

Initial composition of phase w.

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

Initial phase-split parameter.

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

Initial pressure [bar].

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

Initial composition interpolation parameter.

integer, intent(in) :: ns0

Index of the specified variable in , with , .

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

Initial signed continuation step.

integer, intent(in) :: points

Maximum number of envelope points.

Return Value type(PXEnvel3)

private function critical_interpol(Xnew, Xold, idx) result(a)

Critical point interpolation

Read more…

Arguments

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

New value of the variables

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

Old value of the variables

integer, intent(in) :: idx(:)

Index of the variables to interpolate

Return Value real(kind=pr)


Subroutines

public subroutine get_values_from_X(z0, zi, Xvars, x, y, w, P, alpha, beta)

Decode logarithmic K-factors and state variables into phase compositions.

Read more…

Arguments

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

First limiting feed composition.

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

Second limiting feed composition.

real(kind=pr), intent(in) :: Xvars(size(z0)*2+3)

Packed log-K, log-pressure, alpha, and beta vector.

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

Reconstructed phase-x composition.

real(kind=pr), intent(out) :: y(size(z0))

Reconstructed phase-y composition.

real(kind=pr), intent(out) :: w(size(z0))

Reconstructed reference-phase composition.

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

Pressure [bar].

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

Feed interpolation parameter.

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

Phase-split parameter.

public subroutine solve_point(model, z0, zi, T, ns, S, X, F, dF, its, maxits)

Correct a predicted three-phase PX-envelope point with Newton iteration. Returns the equilibrium residual and Jacobian at the corrected state.

Read more…

Arguments

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

Thermodynamic model.

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

First limiting composition.

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

Second limiting composition.

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

Fixed temperature [K].

integer, intent(in) :: ns

Index of the specified unknown.

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

Value imposed on unknown ns.

real(kind=pr), intent(inout) :: X(:)

Initial unknown vector; corrected in place.

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

Three-phase equilibrium residuals.

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

Jacobian of the residual system.

integer, intent(inout) :: its

Iteration count from the point solver.

integer, intent(in) :: maxits

Maximum Newton iterations.

private subroutine detect_critical(X, dXdS, ns, S, dS)

Critical point detection

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=pr), intent(inout) :: X(:)

Vector of variables

real(kind=pr), intent(inout) :: dXdS(:)

Variation of variables wrt S

integer, intent(inout) :: ns

Number of specified variable

real(kind=pr), intent(inout) :: S

Specification value

real(kind=pr), intent(inout) :: dS

Step in specification

private subroutine px_F_three_phases(model, z0, zi, T, Xvars, ns, S, F, df)

Function to solve at each point of a three phase envelope.

Read more…

Arguments

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

Thermodynamic model.

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

First mixture composition (mole fractions).

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

Second mixture composition (mole fractions).

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

Temperature [K].

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

Vector of variables

integer, intent(in) :: ns

Number of specification

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

Specification value

real(kind=pr), intent(out) :: F(size(Xvars))

Vector of functions valuated

real(kind=pr), intent(out) :: df(size(Xvars),size(Xvars))

Jacobian matrix

private subroutine update_specification(its, X, dF, dXdS, ns, dS)

Select a continuation variable using the local tangent and update the step.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: its

Corrector iteration count at the current point.

real(kind=pr), intent(inout) :: X(:)

Current packed equilibrium unknowns.

real(kind=pr), intent(inout) :: dF(:,:)

Current residual Jacobian.

real(kind=pr), intent(inout) :: dXdS(:)

Tangent vector; normalized on return.

integer, intent(inout) :: ns

Index of the selected specification variable.

real(kind=pr), intent(inout) :: dS

Signed continuation step, updated in place.