yaeos__equilibria_critical Module



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
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

Enumerator to handle the possible specifications for a critical point.

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 should be equal to zero at a critical point is found. The second criticality condition is calculated as a numerical derivative with eps=1e-10.

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(in) :: u(:)

Eigen-vector

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

public function critical_line(model, a0, z0, zi, ns, S, dS0, max_points, maxP, first_point)

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.

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) :: ns

Position of the specification variable

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

Specified value

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

Initial step size

integer, intent(in), optional :: max_points

Maximum number of points

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

Maximum pressure

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

Return Value type(CriticalLine)

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

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:"z", 2:"V", 3:"T", 4:"P"]

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

Specification value

integer, intent(in) :: max_iters

Maxiumum number of iterations

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

Initial eigen-vector

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

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(in) :: 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
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)