Multiphase Px envelope calculation module.
This module contains the functions to calculate the PT envelope of a mixture with multiple phases.
Multiphase PX envelope.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
real(kind=pr), | public, | allocatable | :: | alpha(:) |
Molar relation between two mixtures. |
||
type(MPPoint), | public, | allocatable | :: | points(:) |
Array of converged points. |
||
real(kind=pr), | public, | allocatable | :: | z0(:) |
Original mixture mole fractions. |
||
real(kind=pr), | public, | allocatable | :: | zi(:) |
Other mixture mole fractions |
procedure, public, nopass :: get_values_from_X | |
procedure, public, nopass :: solve_point | |
procedure, public :: write => write_envelope_PX_MP |
Multiphase equilibria point.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
real(kind=pr), | public | :: | P |
Pressure [bar] |
|||
real(kind=pr), | public | :: | T |
Temperature [K] |
|||
real(kind=pr), | public | :: | beta_w |
Fraction of the reference (incipient) phase. |
|||
real(kind=pr), | public, | allocatable | :: | betas(:) |
Fractions of the main phases. |
||
integer, | public | :: | iters |
Number of iterations needed to converge the point. |
|||
integer, | public | :: | nc |
Number of components |
|||
integer, | public | :: | np |
Number of phases |
|||
integer, | public | :: | ns |
Number of the specified variable. |
|||
real(kind=pr), | public, | allocatable | :: | w(:) |
Mole fractions of the incipient phase. |
||
real(kind=pr), | public, | allocatable | :: | x_l(:,:) |
Mole fractions of the main phases. |
Calculation of a multiphase Px envelope.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(ArModel), | intent(in) | :: | model |
Model to use. |
||
real(kind=pr), | intent(in) | :: | z0(:) |
Original fluid composition. |
||
real(kind=pr), | intent(in) | :: | zi(:) |
Other fluid compostion. |
||
integer, | intent(in) | :: | np |
Number of phases, without including the reference phaes |
||
real(kind=pr), | intent(in) | :: | T |
Temperature [K] |
||
real(kind=pr), | intent(in) | :: | x_l0(np,size(z0)) |
Initial guess for composition of phases. |
||
real(kind=pr), | intent(in) | :: | w0(size(z0)) |
Initial guess for composition of reference phase. |
||
real(kind=pr), | intent(in) | :: | betas0(np) |
Mole fractions of each phase. Excluding the reference phase. |
||
real(kind=pr), | intent(in) | :: | P0 |
Initial guess for pressure [bar] |
||
real(kind=pr), | intent(in) | :: | alpha0 |
Initial guess for relation between two fluids |
||
integer, | intent(in) | :: | ns0 |
First specified variable. |
||
real(kind=pr), | intent(in) | :: | dS0 |
First step to extrapolate for next point calculation. After that It will use an adaptive algorithm. |
||
real(kind=pr), | intent(in) | :: | beta_w |
Fraction of the reference (incipient) phase. |
||
integer, | intent(in), | optional | :: | points |
Maximum number of points to calculate. |
System of equations to solve a multiphase-point at constant temperature.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(ArModel), | intent(in) | :: | model |
Model to use. |
||
real(kind=pr), | intent(in) | :: | z0(:) |
First mixture composition. |
||
real(kind=pr), | intent(in) | :: | zi(:) |
Second mixture composition. |
||
integer, | intent(in) | :: | np |
Number of main phases. |
||
real(kind=pr), | intent(in) | :: | T |
Temperature [K]. |
||
real(kind=pr), | intent(in) | :: | beta_w |
Fraction of the reference (incipient) phase. |
||
real(kind=pr), | intent(in) | :: | X(:) |
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(X)) |
Vector of functions valuated. |
||
real(kind=pr), | intent(out) | :: | df(size(X),size(X)) |
Jacobian matrix. |
Detect if the system is close to a critical point.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | nc |
Number of components in the mixture. |
||
integer, | intent(in) | :: | np |
Number of main phases. |
||
real(kind=pr), | intent(inout) | :: | X(:) |
Vector of variables. |
||
real(kind=pr), | intent(inout) | :: | dXdS(:) |
Sensitivity of the variables wrt the specification. |
||
integer, | intent(inout) | :: | ns |
Number of the specified variable. |
||
real(kind=pr), | intent(inout) | :: | dS |
Step size of the specification for the next point. |
||
real(kind=pr), | intent(inout) | :: | S |
Specification value. |
Extract the values of the variables from the vector X.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=pr), | intent(in) | :: | X(:) |
Vector of variables. |
||
integer, | intent(in) | :: | np |
Number of main phases. |
||
real(kind=pr), | intent(in) | :: | z0(:) |
Initial mixture composition. |
||
real(kind=pr), | intent(in) | :: | zi(:) |
Second mixture composition. |
||
real(kind=pr), | intent(in) | :: | beta_w |
Reference phase beta. |
||
real(kind=pr), | intent(out) | :: | x_l(np,size(z0)) |
Mole fractions of the main phases. |
||
real(kind=pr), | intent(out) | :: | w(size(z0)) |
Mole fractions of the incipient phase. |
||
real(kind=pr), | intent(out) | :: | betas(np) |
Fractions of the main phases. |
||
real(kind=pr), | intent(out) | :: | P |
Pressure [bar]. |
||
real(kind=pr), | intent(out) | :: | alpha |
. |
Solve the system of equations for a multiphase point.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(ArModel), | intent(in) | :: | model |
Model to use. |
||
real(kind=pr), | intent(in) | :: | z0(:) |
First mixture composition. |
||
real(kind=pr), | intent(in) | :: | zi(:) |
Second mixture composition. |
||
integer, | intent(in) | :: | np |
Number of main phases |
||
real(kind=pr), | intent(in) | :: | T |
Temperature [K] |
||
real(kind=pr), | intent(in) | :: | beta_w |
Fraction of the reference (incipient) phase |
||
real(kind=pr), | intent(inout) | :: | X(:) |
Vector of variables |
||
integer, | intent(in) | :: | ns |
Number of specification |
||
real(kind=pr), | intent(in) | :: | S |
Specification value |
||
real(kind=pr), | intent(in) | :: | dXdS(size(X)) |
Sensitivity of the variables wrt the specification |
||
real(kind=pr), | intent(out) | :: | F(size(X)) |
Vector of functions valuated |
||
real(kind=pr), | intent(out) | :: | df(size(X),size(X)) |
Jacobian matrix |
||
integer, | intent(out) | :: | iters |
Number of iterations needed to converge the point |
||
integer, | intent(in) | :: | max_iterations |
Maximum number of iterations to solve the point |
Change the specified variable for the next step.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | its |
Iterations to solve the current point. |
||
integer, | intent(in) | :: | nc |
Number of components in the mixture. |
||
integer, | intent(in) | :: | np |
Number of main phases. |
||
real(kind=pr), | intent(inout) | :: | X(:) |
Vector of variables. |
||
real(kind=pr), | intent(inout) | :: | dF(:,:) |
Jacobian matrix. |
||
real(kind=pr), | intent(inout) | :: | dXdS(:) |
Sensitivity of the variables wrt the specification. |
||
integer, | intent(inout) | :: | ns |
Number of the specified variable. |
||
real(kind=pr), | intent(inout) | :: | dS |
Step size of the specification for the next point. |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(PXEnvelMP), | intent(in) | :: | env | |||
integer, | intent(in) | :: | unit |