Continue a three-phase equilibrium boundary at fixed global composition.
The module solves the three-phase isofugacity and material-balance equations and advances along the boundary with numerical continuation. Results are collected in PTEnvel3.
envelope = pt_envelope_3ph(model, z, x0, y0, w0, beta0, P0, T0, ns0, dS0, points)
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=pr), | private, | parameter | :: | lnK_min | = | 2.0_pr |
Log-K threshold (currently unused in this module). |
Three-phase isopleth at constant global composition. Each array stores one value per envelope point.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=pr), | public, | allocatable | :: | P(:) |
Pressures [bar] |
||
| real(kind=pr), | public, | allocatable | :: | S(:) |
Value of specification |
||
| real(kind=pr), | public, | allocatable | :: | T(:) |
Temperatures [K] |
||
| real(kind=pr), | public, | allocatable | :: | beta(:) |
Mole fraction between phase x and phase y |
||
| integer, | public, | allocatable | :: | its(:) |
Number of needed iterations |
||
| integer, | public, | allocatable | :: | ns(:) |
Number of specified variable |
||
| real(kind=pr), | public, | allocatable | :: | w(:,:) |
Mole fraction of phase w |
||
| real(kind=pr), | public, | allocatable | :: | x(:,:) |
Mole fraction of phase x |
||
| real(kind=pr), | public, | allocatable | :: | y(:,:) |
Mole fraction of phase y |
Trace a three-phase pressure-temperature envelope at fixed feed z.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(ArModel), | intent(in) | :: | model |
Residual Helmholtz model. |
||
| real(kind=pr), | intent(in) | :: | z(:) |
Overall feed composition. |
||
| real(kind=pr), | intent(in) | :: | x0(:) |
Initial composition of phase x. |
||
| real(kind=pr), | intent(in) | :: | y0(:) |
Initial composition of phase y. |
||
| real(kind=pr), | intent(in) | :: | w0(:) |
Initial composition of phase w. |
||
| real(kind=pr), | intent(in) | :: | beta0 |
Initial phase-split parameter. |
||
| real(kind=pr), | intent(in) | :: | P0 |
Initial pressure [bar]. |
||
| real(kind=pr), | intent(in) | :: | T0 |
Initial temperature [K]. |
||
| integer, | intent(in) | :: | ns0 |
Index of the specified variable in , with , . |
||
| real(kind=pr), | intent(in) | :: | dS0 |
Initial signed continuation step. |
||
| integer, | intent(in) | :: | points |
Maximum number of envelope points requested. |
Critical point interpolation
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=pr), | intent(in) | :: | Xnew(:) |
New value of the variables |
||
| real(kind=pr), | intent(in) | :: | Xold(:) |
Old value of the variables |
||
| integer, | intent(in) | :: | idx(:) |
Index of the variables to interpolate |
Decode logarithmic equilibrium variables into phase states.
The unknown vector stores log(Kx), log(Ky), log(P), log(T),
and beta; phase compositions are reconstructed with the material
balance.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=pr), | intent(in) | :: | z(:) |
Overall feed composition. |
||
| real(kind=pr), | intent(in) | :: | Xvars(size(z)*2+3) |
Packed continuation unknowns. |
||
| real(kind=pr), | intent(out) | :: | x(size(z)) |
Reconstructed phase-x composition. |
||
| real(kind=pr), | intent(out) | :: | y(size(z)) |
Reconstructed phase-y composition. |
||
| real(kind=pr), | intent(out) | :: | w(size(z)) |
Reconstructed reference-phase composition. |
||
| real(kind=pr), | intent(out) | :: | P |
Pressure [bar]. |
||
| real(kind=pr), | intent(out) | :: | T |
Temperature [K]. |
||
| real(kind=pr), | intent(out) | :: | beta |
Phase-split parameter from the unknown vector. |
Correct one point on the three-phase envelope with Newton iteration.
Returns the residual, Jacobian, and iteration count at the corrected
state; reaching maxits signals that the continuation step failed.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(ArModel), | intent(in) | :: | model |
Thermodynamic model. |
||
| real(kind=pr), | intent(in) | :: | z(:) |
Overall feed composition. |
||
| integer, | intent(in) | :: | ns |
Index of the specified unknown. |
||
| real(kind=pr), | intent(in) | :: | S |
Value imposed on unknown |
||
| real(kind=pr), | intent(inout) | :: | X(:) |
Initial unknown vector; corrected in place. |
||
| real(kind=pr), | intent(out) | :: | F(:) |
Three-phase equilibrium residuals. |
||
| real(kind=pr), | intent(out) | :: | dF(:,:) |
Jacobian of the residual system. |
||
| integer, | intent(inout) | :: | its |
Iteration count/status from the point solver. |
||
| integer, | intent(in) | :: | maxits |
Maximum Newton iterations. |
Critical point detection
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=pr), | intent(inout) | :: | X(:) |
Vector of variables |
||
| real(kind=pr), | intent(inout) | :: | dXdS(:) |
Variation of variables wrt S |
||
| integer, | intent(inout) | :: | ns |
Number of specified variable |
||
| real(kind=pr), | intent(inout) | :: | S |
Specification value |
||
| real(kind=pr), | intent(inout) | :: | dS |
Step in specification |
Function to solve at each point of a three phase envelope.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(ArModel), | intent(in) | :: | model |
Thermodynamic model. |
||
| real(kind=pr), | intent(in) | :: | z(:) |
Overall mole fractions. |
||
| real(kind=pr), | intent(in) | :: | Xvars(:) |
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(Xvars)) |
Vector of functions valuated |
||
| real(kind=pr), | intent(out) | :: | df(size(Xvars),size(Xvars)) |
Jacobian matrix |
Select a well-conditioned continuation variable and update the step.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | its |
Corrector iteration count at the current point. |
||
| real(kind=pr), | intent(inout) | :: | X(:) |
Current packed equilibrium unknowns. |
||
| real(kind=pr), | intent(inout) | :: | dF(:,:) |
Current residual Jacobian. |
||
| real(kind=pr), | intent(inout) | :: | dXdS(:) |
Tangent vector, normalized for the selected variable on return. |
||
| integer, | intent(inout) | :: | ns |
Index of the selected specification variable. |
||
| real(kind=pr), | intent(inout) | :: | dS |
Signed step, updated for the next point. |