Skip to content

adding saturation pressure solver - #5283

Draft
GitPaean wants to merge 8 commits into
OPM:masterfrom
GitPaean:comp_equil_july_6th
Draft

adding saturation pressure solver#5283
GitPaean wants to merge 8 commits into
OPM:masterfrom
GitPaean:comp_equil_july_6th

Conversation

@GitPaean

Copy link
Copy Markdown
Member

This adds a saturation pressure solver for compositional mixtures, computing bubble-point and dew-point pressures by successive substitution on fugacity coefficient ratios; the dew-point search targets the retrograde branch first, to match the saturation pressure of a gas reported by the reference simulator.
It also fixes the handling of a defaulted item 11 of EQUIL in compositional mode, which previously threw because the item has no default value.
Both are needed by the compositional equilibration with EQUIL and ZMFVD in an upcoming opm-simulators PR; the unit tests are anchored to reference simulator results for a 1D vertical equilibration case.

@GitPaean GitPaean added the manual:irrelevant This PR is a minor fix and should not appear in the manual label Aug 10, 2026
@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this please

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds compositional bubble/dew saturation-pressure solving and fixes defaulted EQUIL item 11 handling.

Changes:

  • Adds a successive-substitution saturation-pressure solver.
  • Adds reference-based solver tests.
  • Handles omitted EQUIL item 11 as enabling saturation pressure.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
opm/material/constraintsolvers/SaturationPressure.hpp Implements bubble/dew pressure solving.
tests/material/test_saturation_pressure.cpp Tests reference saturation results.
opm/input/eclipse/EclipseState/InitConfig/Equil.cpp Handles defaulted EQUIL item 11.
tests/parser/InitConfigTest.cpp Tests defaulted item handling.
CMakeLists_files.cmake Registers the solver and tests.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread opm/material/constraintsolvers/SaturationPressure.hpp Outdated
Comment thread opm/material/constraintsolvers/SaturationPressure.hpp
Comment thread opm/material/constraintsolvers/SaturationPressure.hpp Outdated
@GitPaean
GitPaean force-pushed the comp_equil_july_6th branch from fb292b0 to 55677b0 Compare August 10, 2026 12:42
@GitPaean
GitPaean force-pushed the comp_equil_july_6th branch 2 times, most recently from 19ba79f to 8f92c0f Compare August 18, 2026 21:21
@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this please

@GitPaean
GitPaean force-pushed the comp_equil_july_6th branch 2 times, most recently from 01aafb6 to aa45c19 Compare August 22, 2026 21:47
@GitPaean
GitPaean requested a balanced review from Copilot August 22, 2026 21:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Suppressed comments (1)

opm/material/constraintsolvers/SaturationPressure.hpp:243

  • This marks the pressure as two-phase even when the fixed-pressure substitution exhausted maxInner without converging. The subsequent sum and pressure step then use an unconverged K, which can poison the bracket and make the outer loop miss or misidentify the saturation boundary. Handle !substitutionConverged before updating either bracket endpoint (by retrying with a fresh estimate or reporting failure).
            pTwo = p;
            haveTwo = true;

Comment thread opm/material/constraintsolvers/SaturationPressure.hpp Outdated
Comment thread opm/material/constraintsolvers/SaturationPressure.hpp Outdated
@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this opm-simulators=7306 please

@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this opm-simulators=7306 failure_report please

@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this failure_report please

@GitPaean
GitPaean force-pushed the comp_equil_july_6th branch from 1b9f827 to 01c6dc3 Compare August 28, 2026 19:24
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.
The previous commit refused the verdict whenever any scan point ended
with the substitution exhausted. That is too strict to be usable: on a
methane-rich mixture with no retrograde dew point, 194 of the 200 scan
points of the upper-dew search are exhausted, and the search still
correctly establishes that the branch has no root. Refusing there took
the lower-branch fallback away from a mixture that needs it, and
dewPressure() returned nothing at all.

The verdict now rests on haveSingle: at least one pressure classified
as single phase by a converged substitution. A scan that classified
nothing anywhere has not looked, and still gives up rather than
reporting no root.
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.

2 participants