Calculate the multiphase isobar of a mixture.
This function calculates the multiphase isobar of a mixture. It uses the Newton-Raphson method to solve the system of equations for each point of the envelope. Each point is estimated using the continuation method, where the sensitivity (vector of the derivatives of the variables with respect to the specified variable) vector of the previous point is used to estimate the next point. The specification is updated at each step.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(ArModel), | intent(in) | :: | model |
Model to use for the calculations. |
||
real(kind=pr), | intent(in) | :: | z0(:) |
Initial mixture composition. |
||
real(kind=pr), | intent(in) | :: | zi(:) |
Second mixture composition. |
||
integer, | intent(in) | :: | np |
Number of main phases. |
||
real(kind=pr), | intent(in) | :: | P |
Pressure [bar]. |
||
character(len=14), | intent(in) | :: | kinds_x(np) |
Kinds of the main phases. Can be “liquid”, “vapor”, “stable” |
||
character(len=14), | intent(in) | :: | kind_w |
Kind of the reference phase. Can be “liquid”, “vapor”, “stable” |
||
real(kind=pr), | intent(in) | :: | x_l0(np,size(z0)) |
Mole fractions matrix of the main phases at the initial point. Each row corresponds to a phase, and each column corresponds to a component. |
||
real(kind=pr), | intent(in) | :: | w0(size(z0)) |
Mole fractions of the incipient/reference phase at the initial point. |
||
real(kind=pr), | intent(in) | :: | betas0(np) |
Mole fractions of each main phases at the initial point. |
||
real(kind=pr), | intent(in) | :: | T0 |
Initial Temperature [K]. |
||
real(kind=pr), | intent(in) | :: | alpha0 |
Initial value of the variable. |
||
integer, | intent(in) | :: | ns0 |
Number of the specified variable. This is the variable that will be used to specify the next point. the first variables corresponds to the of each phase, sorted by phases ([\ln K_1^1, \ln K_2^1, \dots, \ln K_{nc}^1, \dots, \ln K_{nc}^{np}]). The next variables are the mole fractions of each main phase. The last two variables are the temperature and the variable. Respectively |
||
real(kind=pr), | intent(in) | :: | dS0 |
Step size of the specification for the next point. |
||
real(kind=pr), | intent(in) | :: | beta_w |
Fraction of the reference (incipient) phase. |
||
integer, | intent(in), | optional | :: | points |
Number of points to calculate in the envelope. If not specified, the default value is 1000. |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
real(kind=pr), | private | :: | F(size(z0)*np+np+2) |
Vector of functions valuated at the current point. |
|||
real(kind=pr), | private | :: | S |
Specified value |
|||
real(kind=pr), | private | :: | T | ||||
real(kind=pr), | private | :: | Tc | ||||
real(kind=pr), | private | :: | X(size(z0)*np+np+2) |
Vector of variables. It contains the of each phase, the mole fractions of each main phase, the temperature and the variable. |
|||
real(kind=pr), | private | :: | X0(size(X)) |
Initial guess for the point |
|||
real(kind=pr), | private | :: | X_last_converged(size(X)) |
Last converged point |
|||
real(kind=pr), | private | :: | Xc(size(X)) |
Vector of variables at the critical point. |
|||
real(kind=pr), | private | :: | ac | ||||
real(kind=pr), | private | :: | alpha | ||||
real(kind=pr), | private, | allocatable | :: | alphas(:) |
Array of values for each point in the envelope. |
||
real(kind=pr), | private | :: | betas(np) | ||||
real(kind=pr), | private | :: | dF(size(z0)*np+np+2,size(z0)*np+np+2) |
Jacobian matrix of the functions at the current point. |
|||
real(kind=pr), | private | :: | dS |
Step size of the specification for the next point |
|||
real(kind=pr), | private | :: | dX(size(z0)*np+np+2) |
Vector of variables. It contains the of each phase, the mole fractions of each main phase, the temperature and the variable. |
|||
real(kind=pr), | private | :: | dXdS(size(z0)*np+np+2) |
Sensitivity of the variables with respect to the specification. |
|||
type(MPPoint), | private, | allocatable | :: | env_points(:) |
Array of converged points in the envelope. |
||
logical, | private | :: | found_critical |
If true, a critical point was found during the calculation. |
|||
integer, | private | :: | i |
Point calculation index |
|||
integer, | private | :: | iT |
Index of the temperature variable in the vector X |
|||
integer, | private | :: | ia |
Index of the variable in the vector X |
|||
integer, | private | :: | inner |
Number of times a failed point is retried to converge |
|||
integer, | private | :: | its |
Number of iterations needed to converge the point. |
|||
integer, | private | :: | lb |
Lower bound, index of the first component of a phase |
|||
integer, | private | :: | max_iterations | = | 100 |
Maximum number of iterations to solve each point. |
|
integer, | private | :: | nc |
Number of components in the mixture. |
|||
integer, | private | :: | ns |
Number of the specified variable |
|||
integer, | private | :: | number_of_points |
Number of points to calculate in the envelope. |
|||
type(MPPoint), | private | :: | point |
Point to store the information of the current point. |
|||
integer, | private | :: | ub |
Upper bound, index of the last component of a phase |
|||
real(kind=pr), | private | :: | w(size(z0)) | ||||
character(len=14), | private | :: | w_kind |
Kind of the reference phase |
|||
character(len=14), | private | :: | x_kinds(np) |
Kinds of the main phases |
|||
real(kind=pr), | private | :: | x_l(np,size(z0)) | ||||
real(kind=pr), | private | :: | z(size(z0)) |