Multiphase PT envelope calculation module.
This module contains the functions to calculate the PT envelope of a mixture with multiple phases.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| type(NearCritical), | private | :: | near_critical_state |
Singleton to follow the near critical status. |
Multiphase PT envelope.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=pr), | public, | allocatable | :: | Pc(:) |
Critical pressures. |
||
| real(kind=pr), | public, | allocatable | :: | Tc(:) |
Critical temperatures. |
||
| type(MPPoint), | public, | allocatable | :: | points(:) |
Array of converged points. |
| procedure, public, nopass :: get_values_from_X | |
| procedure, public, nopass :: solve_point | |
| procedure, public :: write => write_envelope_PT_MP |
Multiphase equilibria point.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=pr), | public | :: | P |
Pressure [bar] |
|||
| real(kind=pr), | public | :: | S |
Specified variable value. |
|||
| 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. |
||
| real(kind=pr), | public | :: | dS |
Step size of the specification to reach this point. |
|||
| integer, | public | :: | iters |
Number of iterations needed to converge the point. |
|||
| character(len=14), | public | :: | kind_w |
Kind of the reference phase. |
|||
| character(len=14), | public, | allocatable | :: | kinds_x(:) |
Kinds of the main phases. |
||
| 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. |
Near critical point information.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| logical, | public | :: | entering | = | .false. |
Entering a critical region. This attribute is used to ensure that the correct indexes are used since they should not be updated while inside the region, just on the first point. |
|
| integer, | public | :: | i |
Index of the component with the max |
|||
| integer, | public | :: | j |
Index of the component with the minimum |
|||
| integer, | public | :: | l |
Index of the phase that is becoming critical with the reference phase. |
|||
| logical, | public | :: | near_critical | = | .false. |
If we are satisfying the condition of being near a critical point. |
Calculation of a multiphase PT envelope.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(ArModel), | intent(in) | :: | model | |||
| real(kind=pr), | intent(in) | :: | z(:) |
Mixture global composition. |
||
| integer, | intent(in) | :: | np |
Number of main phases. |
||
| character(len=14), | intent(in) | :: | kinds_x(np) |
Kind of the main phases. |
||
| character(len=14), | intent(in) | :: | kind_w |
Kind of the reference phase. |
||
| real(kind=pr), | intent(in) | :: | x_l0(np,size(z)) |
Initial guess for the mole fractions of each phase. arranged as
an array of size |
||
| real(kind=pr), | intent(in) | :: | w0(size(z)) |
Initial guess for the mole fractions of the reference/incipient phase. |
||
| real(kind=pr), | intent(in) | :: | betas0(np) |
Initial guess for the fractions of the main phases. arranged as
an array of size |
||
| real(kind=pr), | intent(in) | :: | P0 |
Initial guess for the pressure [bar]. |
||
| real(kind=pr), | intent(in) | :: | T0 |
Initial guess for the temperature [K]. |
||
| integer, | intent(in) | :: | ns0 |
Number of the specified variable. The variable to be specified. This is the variable that will be used to calculate the first point of the envelope. The variable can be any of the variables in the vector X, but it is recommended to use the temperature or pressure. The variables are aranged as follows: |
||
| real(kind=pr), | intent(in) | :: | dS0 |
Step size of the specification for the next point. This is the step size that will be used to calculate the next point. Inside the algorithm this value is modified to adapt the step size to facilitate the convergence of each point. |
||
| real(kind=pr), | intent(in) | :: | beta_w |
Fraction of the reference (incipient) phase. |
||
| integer, | intent(in), | optional | :: | points |
Number of points to calculate. |
|
| real(kind=pr), | intent(in), | optional | :: | max_pressure |
Maximum pressure [bar] to calculate. If the pressure of the point is greater than this value, the calculation is stopped. This is useful to avoid calculating envelopes that go to infinite values of pressure. |
|
| logical, | intent(in), | optional | :: | allow_negative_betas |
Do not stop calculating when there are negative values of beta. |
Function to solve at each point of a multi-phase envelope.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(ArModel), | intent(in) | :: | model |
Model to use. |
||
| real(kind=pr), | intent(in) | :: | z(:) |
Mixture global composition. |
||
| integer, | intent(in) | :: | np |
Number of main phases. |
||
| real(kind=pr), | intent(in) | :: | beta_w |
Fraction of the reference (incipient) phase. |
||
| character(len=14), | intent(in) | :: | kinds_x(np) |
Kind of the main phases. |
||
| character(len=14), | intent(in) | :: | kind_w |
Kind of the reference 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. |
||
| real(kind=pr), | intent(out) | :: | Vl(np) | |||
| real(kind=pr), | intent(out) | :: | Vw |
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) | :: | z(:) |
Mixture composition. |
||
| real(kind=pr), | intent(in) | :: | beta_w |
Fraction of the reference phase. |
||
| real(kind=pr), | intent(out) | :: | x_l(np,size(z)) |
Mole fractions of the main phases. |
||
| real(kind=pr), | intent(out) | :: | w(size(z)) |
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) | :: | T |
Temperature [K]. |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(ArModel), | intent(in) | :: | model |
Model to use. |
||
| real(kind=pr), | intent(in) | :: | z(:) |
Mixture global composition. |
||
| integer, | intent(in) | :: | np |
Number of main phases |
||
| real(kind=pr), | intent(in) | :: | beta_w |
Fraction of the reference (incipient) phase |
||
| character(len=14), | intent(in) | :: | kinds_x(np) |
Kind of the main phases |
||
| character(len=14), | intent(in) | :: | kind_w |
Kind of the reference 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)) | |||
| real(kind=pr), | intent(out) | :: | F(size(X)) |
Vector of functions valuated |
||
| real(kind=pr), | intent(out) | :: | df(size(X),size(X)) |
Jacobian matrix |
||
| real(kind=pr), | intent(out) | :: | Vl(np) |
Main phases volumes |
||
| real(kind=pr), | intent(out) | :: | Vw |
Reference phase volume |
||
| integer, | intent(out) | :: | iters |
Number of iterations to solve the current 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) | :: | S |
Specified value. |
||
| real(kind=pr), | intent(inout) | :: | dS |
Step size of the specification for the next point. |
||
| logical, | intent(out) | :: | near_crit |
If true, the point is near a critical point. |
||
| integer, | intent(out) | :: | l_nc |
Index of the phase near a critical point. |
||
| integer, | intent(out) | :: | i_nc |
Index of the component with the maximum lnK if near a critical point. |
||
| integer, | intent(out) | :: | j_nc |
Index of the component with the minimum lnK if near a critical point. |
||
| real(kind=pr), | intent(in) | :: | Vl(:) |
Molar volumes of the main phases [L/mol]. |
||
| real(kind=pr), | intent(in) | :: | Vw |
Molar volume of the reference phase [L/mol]. |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(PTEnvelMP), | intent(in) | :: | env | |||
| integer, | intent(in) | :: | unit |