yaeos__equilibria_critical Module

Critical points and critical lines

Description

Calculation of mixture critical points with critical_point and critical lines with critical_line. The criticality conditions are solved with Newton’s method, and the critical line is traced with the same numerical continuation method used for phase envelopes.

Examples

cp = critical_point(model, z0, zi, spec_CP%a, S=alpha, max_iters=1000)
line = critical_line(model, alpha, z0, zi, ns0, S0, dS0)

Uses

  • module~~yaeos__equilibria_critical~~UsesGraph module~yaeos__equilibria_critical yaeos__equilibria_critical module~yaeos__constants yaeos__constants module~yaeos__equilibria_critical->module~yaeos__constants module~yaeos__equilibria_equilibrium_state yaeos__equilibria_equilibrium_state module~yaeos__equilibria_critical->module~yaeos__equilibria_equilibrium_state module~yaeos__models_ar yaeos__models_ar module~yaeos__equilibria_critical->module~yaeos__models_ar iso_fortran_env iso_fortran_env module~yaeos__constants->iso_fortran_env module~yaeos__equilibria_equilibrium_state->module~yaeos__constants module~yaeos__models_ar->module~yaeos__constants module~yaeos__models_base yaeos__models_base module~yaeos__models_ar->module~yaeos__models_base module~yaeos__substance yaeos__substance module~yaeos__models_base->module~yaeos__substance module~yaeos__substance->module~yaeos__constants

Used by

  • module~~yaeos__equilibria_critical~~UsedByGraph module~yaeos__equilibria_critical yaeos__equilibria_critical module~yaeos__equilibria yaeos__equilibria module~yaeos__equilibria->module~yaeos__equilibria_critical proc~init_pcsaft init_pcsaft proc~init_pcsaft->module~yaeos__equilibria_critical module~yaeos yaeos module~yaeos->module~yaeos__equilibria

Variables

Type Visibility Attributes Name Initial
type(CPSpecs), public, parameter :: spec_CP = CPSpecs()

Specification variables for a critical point or critical line calculation.


Derived Types

type, public ::  CriticalLine

This derived type is used to store a critical line between two fluids. The critical line is calculated using the critical_line function. It uses the continuation method.

Read more…

Components

Type Visibility Attributes Name Initial
type(EquilibriumState), public :: CEP

Critical End Point

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

Pressure [bar]

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

Temperature [K]

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

Volume [L/mol]

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

Molar fraction of the second fluid

integer, public, allocatable :: iters(:)

Iterations needed for this point

integer, public, allocatable :: ns(:)

Specified variable

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

Molar fractions of the first fluid

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

Molar fractions of the second fluid

type, private ::  CPSpecs

Internal selector values for critical-point specifications.

Read more…

Components

Type Visibility Attributes Name Initial
integer, public :: P = 4

Specify

integer, public :: T = 3

Specify

integer, public :: V = 2

Specify

integer, public :: a = 1

Specify


Functions

public function F_critical(model, X, ns, S, z0, zi, u)

Function that is equal to zero at a critical point. The second criticality condition is calculated as a numerical derivative with eps=1e-4.

Read more…

Arguments

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

Equation of state model

real(kind=pr), intent(in) :: X(4)

Vector of variables

integer, intent(in) :: ns

Position of the specification variable

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

Specification variable value

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

Molar fractions of the first fluid

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

Molar fractions of the second fluid

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

Eigen-vector

Return Value real(kind=pr), (4)

public function critical_line(model, a0, z0, zi, ns0, S0, dS0, v0, t0, p0, max_points, maxP, first_point, stability_analysis)

Calculates the critical line between two mixtures using the continuation method. The two mixtures compositions are restricted to the relation between them, by a parameter , which represents the molar fraction of the second fluid with respect to the whole mixture. Iteration count. Avoid compositions with negative values

Read more…

Arguments

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

Equation of state model

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

Initial value

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

Molar fractions of the first fluid

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

Molar fractions of the second fluid

integer, intent(in) :: ns0

Position of the specification variable in (use spec_CP)

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

Specified value: itself for spec_CP%a, otherwise the logarithm of , or

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

Initial step size

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

Initial volume [L/mol], defaults to the vapor root at ,

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

Initial temperature [K], defaults to

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

Initial pressure [bar], defaults to

integer, intent(in), optional :: max_points

Maximum number of points, defaults to 1000

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

Maximum pressure [bar], defaults to 2500

type(EquilibriumState), intent(in), optional :: first_point

Optional initial point; overrides the initial guess with first_point%x(2), Vx, T, P.

logical, optional :: stability_analysis

If .true., check the stability of each traced critical state (default .false.).

Return Value type(CriticalLine)

public function critical_point(model, z0, zi, spec, S, max_iters, V0, T0, a0, P0)

Calculates a single critical point of a mixture using a Newton-Raphson method. It is possible to specify different variables to be fixed with the spec argument, the spec_CP variable helps when selecting the specified variable.

Read more…

Arguments

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

Equation of state model

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

Molar fractions of the first fluid

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

Molar fractions of the second fluid

integer, intent(in) :: spec

Specification [1:"a", 2:"V", 3:"T", 4:"P"] (use spec_CP)

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

Specification value: for spec_CP%a, otherwise , or

integer, intent(in) :: max_iters

Maximum number of iterations

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

Initial volume [L/mol].

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

Initial temperature [K].

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

Initial value

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

Initial Pressure [bar]

Return Value type(EquilibriumState)

public function df_critical(model, X, ns, S, z0, zi, u)

Calculates the Jacobian of the critical point function F_critical.

Read more…

Arguments

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

Equation of state model

real(kind=pr), intent(in) :: X(4)

Vector of variables

integer, intent(in) :: ns

Position of the specification variable

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

Specification variable value

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

Molar fractions of the first fluid

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

Molar fractions of the second fluid

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

Eigen-vector

Return Value real(kind=pr), (4,4)

Jacobian of the critical point function

public function lambda1(model, X, s, z0, zi, u, u_new, P)

Calculation of the first restriction of a critical point.

Read more…

Arguments

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

EOS used to evaluate the stability matrix.

real(kind=pr), intent(in) :: X(4)

Vector of variables

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

Distance between the two fluids compositions to the main composition

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

Molar fractions of the first fluid

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

Molar fractions of the second fluid

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

Eigen-vector that defines the direction between the two compositions

real(kind=pr), intent(out), optional :: u_new(:)

Eigen-vector corresponding to the smallest eigenvalue of the matrix

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

Pressure of the system [bar]

Return Value real(kind=pr)

private function F_cep(model, nc, X, z0, zi, u)

Arguments

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

Equation of state model

integer, intent(in) :: nc

Number of components.

real(kind=pr), intent(in) :: X(nc+4)

Vector of variables

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

Molar fractions of the first fluid

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

Molar fractions of the second fluid

real(kind=pr), intent(inout) :: u(nc)

Eigen-vector

Return Value real(kind=pr), (nc+4)

private function df_cep(model, nc, X, z0, zi, u)

Calculates the Jacobian of the critical point function F_critical.

Read more…

Arguments

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

Equation of state model

integer, intent(in) :: nc

Number of components.

real(kind=pr), intent(in) :: X(nc+4)

Vector of variables

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

Molar fractions of the first fluid

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

Molar fractions of the second fluid

real(kind=pr), intent(inout) :: u(nc)

Eigen-vector

Return Value real(kind=pr), (nc+4,nc+4)

Jacobian of the critical point function

private function get_a(nc, X)

Arguments

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

Number of components.

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

Solver variable for the composition parameter: if nc == 2, else .

Return Value real(kind=pr)

private function set_a(nc, a)

Arguments

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

Number of components.

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

Composition parameter in .

Return Value real(kind=pr)


Subroutines

public subroutine get_critical_constants(model)

Calculate the critical constants for each pure component.

Read more…

Arguments

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

Thermodynamic model.

private subroutine look_for_cep(model, z0, zi, Pc, Vc, Tc, a, u, found, CEP)

Arguments

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

Equation of state model

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

Molar fractions of the first fluid

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

Molar fractions of the second fluid

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

Pressure [bar]

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

Volume [L/mol]

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

Temperature [K]

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

Molar fraction of the second fluid

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

Eigen-vector

logical, intent(out) :: found

Found a Critical End Point

type(EquilibriumState), intent(out) :: CEP

Critical End Point

private subroutine stability_check(model, z0, zi, Pc, Vc, Tc, a, unstable, y_other, V_other)

Check the stability of a point in the critical line. The stability is determined by a tpd scan over trial compositions (binary mixtures only).

Read more…

Arguments

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

Equation of state model

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

Molar fractions of the first fluid

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

Molar fractions of the second fluid

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

Pressure [bar]

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

Volume [L/mol]

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

Temperature [K]

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

Molar fraction of the second fluid

logical, intent(out) :: unstable

.true. if a trial composition has

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

First trial composition found with negative (set only when unstable)

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

Volume of the last trial phase evaluated [L/mol]