pt_envelope
Calculation of a multiphase PT envelope.
Calculates a PT envelope is calculated using the continuation method. The envelope is calculated by solving the system of equations for each point of the envelope. The system of equations is solved using the Newton-Raphson method.
This function requires the system specification conditions, which are
the fluid composition (\z), the number of phases that are not
incipient; defined as , proper intialization values, the
variables that end with 0
are the initial guess; the mole fraction
of the reference phase beta_w
which when it is equal to 0 means that
we are calculating a phase boundary.
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. |
||
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. |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
real(kind=pr), | private | :: | F(size(z)*np+np+2) |
Vector of functions valuated. |
|||
real(kind=pr), | private | :: | P |
Pressure [bar]. |
|||
real(kind=pr), | private | :: | S |
Specified value |
|||
real(kind=pr), | private | :: | T |
Temperature [K]. |
|||
real(kind=pr), | private | :: | X(size(z)*np+np+2) |
Vector of variables. |
|||
real(kind=pr), | private | :: | X0(size(X)) |
Initial guess for the point |
|||
real(kind=pr), | private | :: | betas(np) |
Fractions of the main phases. |
|||
real(kind=pr), | private | :: | dF(size(z)*np+np+2,size(z)*np+np+2) |
Jacobian matrix. |
|||
real(kind=pr), | private | :: | dS |
Step size of the specification for the next point |
|||
real(kind=pr), | private | :: | dX(size(z)*np+np+2) |
Step for next point estimation. |
|||
real(kind=pr), | private | :: | dXdS(size(z)*np+np+2) |
Sensitivity of the variables wrt the specification. |
|||
type(MPPoint), | private, | allocatable | :: | env_points(:) |
Array of converged points. |
||
integer, | private | :: | i |
Point calculation index |
|||
integer, | private | :: | iP |
Index of the pressure variable. |
|||
integer, | private | :: | iT |
Index of the temperature variable. |
|||
integer, | private | :: | inner |
Number of times a failed point is retried to converge |
|||
integer, | private | :: | its |
Number of iterations to solve the current point. |
|||
integer, | private | :: | lb |
Lower bound, index of the first component of a phase |
|||
real(kind=pr), | private | :: | max_P |
Maximum pressure [bar] to calculate. |
|||
integer, | private | :: | max_iterations | = | 10 |
Maximum number of iterations to solve the point. |
|
integer, | private | :: | nc |
Number of components. |
|||
integer, | private | :: | ns |
Number of the specified variable |
|||
integer, | private | :: | number_of_points |
Number of points to calculate. |
|||
type(MPPoint), | private | :: | point |
Converged point. |
|||
integer, | private | :: | ub |
Upper bound, index of the last component of a phase |
|||
real(kind=pr), | private | :: | w(size(z)) |
Mole fractions of the incipient phase. |
|||
real(kind=pr), | private | :: | x_l(np,size(z)) |
Mole fractions of the main phases. |