Skip to content

[test] compositional equilibration combination - #5325

Draft
GitPaean wants to merge 12 commits into
OPM:masterfrom
GitPaean:comp_equil_integration
Draft

[test] compositional equilibration combination#5325
GitPaean wants to merge 12 commits into
OPM:masterfrom
GitPaean:comp_equil_integration

Conversation

@GitPaean

Copy link
Copy Markdown
Member

This is the combination of the PRs #5283, #5321, and #5322, in combination, it generate very good results combined with the development in opm-simulators.

This PR is not intended to get merged, while it is possible some results will be shared here.

@GitPaean GitPaean added the manual:irrelevant This PR is a minor fix and should not appear in the manual label Aug 28, 2026
@GitPaean
GitPaean force-pushed the comp_equil_integration branch from d653000 to 3b9259e Compare August 31, 2026 11:49
The upper and lower dew searches were chained with ||, so a plain
convergence failure on the upper branch silently fell through to the
lower one, which can return the wrong dew point of a mixture that has
both. The branch search now reports whether it converged, established
that the branch has no genuine root, or merely ran out of iterations,
and the lower branch is only tried in the second case.
EQUIL item 11 set to 1 was never exercised; the trivial-solution test
could pass without running any assertion when both mixtures are simply
refused.
A pressure was recorded as two-phase bracket evidence before the
converged point was classified, so the disguised-trivial rejection
bisected between two copies of the same pressure and froze, and an
exhausted substitution could certify a pressure it proved nothing
about. Both labels now require a converged substitution and follow the
classification.

The root-distinctness test accepted the 1e-7 m3/mol clamp the cubic
EOS substitutes for an unphysical root as if it were a real phase,
inventing a 42 kbar bubble point for supercritical methane; a volume at
the clamp no longer counts. Found by the new supercritical test, which
now expects a refusal with the pressure output untouched.

Also bound the lower-branch dew test away from the retrograde region,
align the Outcome enumerators with the neighbouring enum, and document
the failure contract of the public solvers.
A scan point whose fixed-pressure substitution runs out of iterations
classifies nothing. Two places still treated such a point as evidence:
the single-phase test, whose trivial threshold of 1e-5 an unconverged K
can meet while it is still moving, and the final verdict, which reported
no root when the scan had merely failed.

Both now require a converged substitution, as the pressure criterion
already did. A search that met an exhausted point returns GaveUp, so the
upper dew search no longer hands a mixture that has both branches to the
lower one.
A row summing to 0.999968 is rejected by flow but accepted by other
simulators, so decks that run elsewhere stop here. ZMFVD and COMPVD
rejected anything past 1e-5, and WELLSTRE anything past one machine
epsilon, which is below the noise of adding the values up.

They now share one tolerance: a composition is accepted when the
deviation is small, scaled to sum to one, and reported in a warning, as
the other simulators do. A deviation too large to be rounding is still
an error.
NaN is an acceptable floating-point token to the parser, and a NaN
fraction makes the sum NaN. Every comparison against a NaN is false, so
both the tolerance check and the exact-sum check passed and the row was
then divided through by the NaN and stored as a composition of NaNs.

Any non-finite fraction makes the sum non-finite, so testing the sum
covers them all.
SSHIFT was parsed and stored but never reached the equation of state.
Against a reference run of the same deck, the gas density was 3.7
percent high and the liquid 10 percent low.

The shift now sits on the component parameters, and the density
subtracts it from the molar volume.

The parameter cache keeps the unshifted volume, because the fugacity
coefficients are computed from it. A volume shift cancels out of the
equilibrium ratios, so it must leave the phase split untouched.
Subtracting it there would change the coefficients and move the split.
SSHIFT is unconstrained deck input. A shift larger than the molar volume
turns the corrected volume zero or negative, and the density was divided
through it regardless, so an overlarge shift bought a negative or
infinite density instead of an error.

The tests grew with it. The fugacity check compared a fluid system with
itself and proved nothing; it now compares against a separate system
holding the same components with zero shifts. The liquid phase, where
the correction matters most, was untested, and the shift it uses is now
rebuilt in the test from SSHIFT and b_c = Omega_b R Tc / pc rather than
read back from the parameter cache. A deck-backed case covers the
parsing path, which no test reached before.
The shift reached the density and stopped there. Everything else built
on the molar volume kept the unshifted one, so an SSHIFT deck got
corrected densities alongside phase volumes and mobilities that did not
match them.

correctedMolarVolume() now returns the volume the fluid occupies, and
the density is one of its callers rather than the only place the shift
exists. The cached molarVolume() stays unshifted for the fugacity
coefficients, which need the root the two-parameter expression was
derived for.

The guard against a shift larger than the volume moves into the
accessor, so it covers every caller.

The equilibrium-ratio test replaces the one comparing coefficients
directly. Peneloux scales each fugacity by exp(-c p / (R T)), so the
coefficients themselves are only equal because this implementation
leaves them untranslated; the ratio is what has to hold either way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:irrelevant This PR is a minor fix and should not appear in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant