GEOS-DEV / GEOS

GEOS Simulation Framework
GNU Lesser General Public License v2.1
203 stars 80 forks source link

Implement stability test #3136

Closed dkachuma closed 1 week ago

dkachuma commented 1 month ago

Implements stability test for compositional mixtures. Given a fluid mixture at a prescribed pressure and temperature, this tests if the mixture is thermodynamically stable as a single phase.

The solution starts with the 2 compositions determined by the Wilson k-values. For each composition, successive substitution is used to converge to a stationary point. The procedure then outputs the minimum tangent plane distance from the 2 trial compositions. Success is determined when both trial compositions converge to stationary points.

Michelson showed that a mixture will be stable if and only if the tangent-plane-distance (TPD) denoted by $g(y)$ in CompositionalMultiphaseFluid is non-negative for all trial compositions $y$. For a 2 component system, we can enumerate this since the composition is essentially one dimensional. I have done this for a 20%-80% mix of $CH_4$ and $C3H{10}$ in the image below. tpd The x-axis is the trial composition expressed by the molar fraction of $CH4$ in the trial composition. To determine if this is non-negative for all $y$, we need to find the stationary points where $g'(y)=0$ because these will include the minima. If the function is non-negative at all these stationary points, then we conclude that the mixture is stable. The feed composition $z$ (in this case $z{CH4}=0.2$) is itself a (trivial) stationary point and the value of $g$ at this point is zero. To get other stationary points we start with the values of $z$ perturbed by the Wilson k-values. For this example we get extreme values with the first having $y{CH4}\approx 0$ and the other $y{CH_4}\approx 1$. Then we do successive substitution to converge to the stationary points. These are shown on the diagram as squares. One of the initial guesses almost invariably converges to the trivial stationary point. For pressures of 10bar and 200bar, we get extra stationary points but the value of $g$ at these points is positive - so we conclude that the mixture is stable as a single phase. For 50bar one of the stationary points gives a negative value of $g$ indicating instability.

This will next be linked to the negative flash. The point is to avoid going into the negative flash if the mixture is stable as a single phase. This will save some flops but more importantly will avoid inconsistent phase labelling that results from relying on the solution of the flash when the mixture is single phase.

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 55.77%. Comparing base (bfcfe81) to head (bb1ccfa).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #3136 +/- ## =========================================== + Coverage 55.69% 55.77% +0.08% =========================================== Files 1032 1035 +3 Lines 87750 87914 +164 =========================================== + Hits 48871 49035 +164 Misses 38879 38879 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

dkachuma commented 1 week ago

I do not remember the details of this. I would suggest to write a documentation ( if possible with an image that explains what happens for a binary system) as part of this PR.

I have added a description of the stability test based on Michelson. CompositionalMultiphaseFluid