Skip to content

Compositional equilibration with EQUIL and ZMFVD - #7306

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

Compositional equilibration with EQUIL and ZMFVD#7306
GitPaean wants to merge 5 commits into
OPM:masterfrom
GitPaean:comp_equil_july_6th

Conversation

@GitPaean

@GitPaean GitPaean commented Aug 10, 2026

Copy link
Copy Markdown
Member

Adds hydrostatic compositional initialization from EQUIL and ZMFVD, with temperature from RTEMP or RTEMPVD.

  • Type 1 uses ZMFVD as total composition and integrates pressure with one EOS root selected from the datum side of the gas-oil contact. The subsequent flash determines the phase split.
  • Type 3 uses ZMFVD as liquid composition below the contact and its equilibrium vapour above it. When saturation-pressure adjustment is enabled, the supplied pressure is replaced by the bubble-point pressure if they differ by at least one atmosphere; item 11 = 1 preserves it.
  • EQLNUM regions are equilibrated independently.

Type 2, COMPVD, and water zones remain unsupported. The black-oil RK4 integrator and pressure function move to a shared header and are reused by both equilibration paths.

Unit tests cover types 1 and 3, item 11, independent EQLNUM regions, constant and graded RTEMPVD, and missing ZMFVD. The two reference decks are registered as serial regression tests.

Depends on OPM/opm-common#5283. Parallel flow_comp runs additionally require #7387; the serial regression tests in this PR do not.

@GitPaean GitPaean added the manual:enhancement This is an enhancement/improvent that needs to be documented in the manual label Aug 10, 2026
@GitPaean GitPaean changed the title compositional equilibration compositional equilibration with ZMFVD Aug 10, 2026
@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this opm-common=5283 please

@GitPaean
GitPaean requested a balanced review from Copilot August 10, 2026 13:24
Copilot stopped reviewing on behalf of GitPaean due to an error August 10, 2026 13:25

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

Note

Copilot was unable to run its full agentic suite in this review.

This PR adds compositional hydrostatic equilibration support (EQUIL + ZMFVD) and aligns compositional restart/output behavior with expected Eclipse-style arrays, while also improving parallel correctness for data exchange and residual metrics.

Changes:

  • Add shared hydrostatic ODE integrator + pressure function, and implement compositional equilibration (InitStateEquilComp).
  • Extend distributed field-property handling to support multi-values-per-cell double keywords (e.g., ZMF).
  • Improve compositional restart/output (renamed arrays, new POIL/PGAS/PSAT/VMF) and fix parallel solution syncing / residual evaluation.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
opm/simulators/utils/UnsupportedFlowKeywords.cpp Removes ZMFVD from the “unsupported” list.
opm/simulators/utils/PropsDataHandle.hpp Supports multi-valued double fields per cell during broadcast/packing/unpacking.
opm/simulators/utils/PartiallySupportedFlowKeywords.cpp Tightens allowed EQUIL item 10/11 values for compositional initialization.
opm/simulators/flow/equil/PressureFunction.hpp Introduces reusable RK4 IVP integrator + depth→pressure function.
opm/simulators/flow/equil/InitStateEquil_impl.hpp Removes local integrator/pressure-function implementations now moved to shared header.
opm/simulators/flow/equil/InitStateEquilComp.hpp Adds compositional equilibration implementation based on EQUIL + ZMFVD (+ RTEMPVD).
opm/simulators/flow/equil/InitStateEquil.hpp Switches black-oil equilibration to shared PressureFunction implementation.
opm/simulators/flow/OutputCompositionalModule.hpp Adds compositional restart alignment (renames) + new outputs (phase pressures, PSAT, VMF).
opm/simulators/flow/NonlinearSystemCompositional_impl.hpp Adds updateSolution with overlap sync; residual metrics now ignore ghost cells.
opm/simulators/flow/NonlinearSystemCompositional.hpp Declares updateSolution().
opm/simulators/flow/FlowProblemComp.hpp Enables compositional equilibration; fixes parallel transmissibility export approach.
opm/simulators/flow/CompositionalContainer.hpp Adds buffers/APIs for POIL/PGAS/PSAT/VMF and allocation checks.
opm/simulators/flow/CompositionalContainer.cpp Allocates and writes new restart arrays; fixes moleFractions_ allocation check.
CMakeLists_files.cmake Installs new public headers for compositional equilibration and PressureFunction.

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

Comment thread opm/simulators/flow/FlowProblemComp.hpp
Comment thread opm/simulators/flow/CompositionalContainer.cpp
Comment thread opm/simulators/flow/equil/PressureFunction.hpp
Comment thread opm/simulators/flow/OutputCompositionalModule.hpp Outdated
@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this opm-common=5283 failure_report please

@GitPaean
GitPaean force-pushed the comp_equil_july_6th branch from 0cb16eb to f06fea8 Compare August 10, 2026 15:17
@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this opm-common=5283 failure_report please

@GitPaean
GitPaean force-pushed the comp_equil_july_6th branch from f06fea8 to 53bf2f2 Compare August 11, 2026 08:54
@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this opm-common=5283 failure_report please

@GitPaean
GitPaean force-pushed the comp_equil_july_6th branch from 53bf2f2 to 98e5a87 Compare August 12, 2026 11:53
@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this opm-common=5283 please

@GitPaean
GitPaean force-pushed the comp_equil_july_6th branch from 98e5a87 to d0e7ce4 Compare August 18, 2026 21:23
@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this opm-common=5283 please

@GitPaean
GitPaean force-pushed the comp_equil_july_6th branch 2 times, most recently from d1f4b11 to 4b581c0 Compare August 22, 2026 21:48
@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 11 out of 11 changed files in this pull request and generated 3 comments.

Suppressed comments (1)

opm/simulators/flow/equil/InitStateEquilComp.hpp:420

  • For a datum depth different from the contact, pDatum below is nevertheless used directly as the pressure at reg.zgoc. The warning therefore silently shifts the entire hydrostatic pressure profile instead of honoring the EQUIL datum. Either reject this input or integrate the datum pressure to the contact before constructing the two pressure functions.
        if (std::abs(record.datumDepth() - reg.zgoc) > 0.0) {
            OpmLog::warning(fmt::format("Equilibration region {}: the datum depth {} m "
                                        "must be at the gas-oil contact when EQUIL "
                                        "item 10 is 3; using the contact depth {} m.",
                                        regionIdx + 1, record.datumDepth(), reg.zgoc));

Comment thread opm/simulators/utils/PropsDataHandle.hpp Outdated
Comment thread opm/simulators/flow/equil/InitStateEquilComp.hpp
Comment thread opm/simulators/flow/equil/InitStateEquilComp.hpp
@GitPaean
GitPaean force-pushed the comp_equil_july_6th branch 3 times, most recently from e4d0219 to 6df9482 Compare September 6, 2026 21:43
@GitPaean
GitPaean force-pushed the comp_equil_july_6th branch from 6df9482 to c8b817b Compare September 7, 2026 07:12
@GitPaean GitPaean changed the title compositional equilibration with ZMFVD Compositional equilibration with EQUIL and ZMFVD Sep 7, 2026
Comment thread opm/simulators/flow/equil/PressureFunction.hpp Outdated
@GitPaean
GitPaean force-pushed the comp_equil_july_6th branch from c8b817b to d518fc3 Compare September 7, 2026 07:45
@GitPaean
GitPaean force-pushed the comp_equil_july_6th branch 2 times, most recently from ecab1ef to caa4fd3 Compare September 7, 2026 09:54
EQUIL type 1 uses ZMFVD as total composition and integrates pressure
with one EOS root selected from the datum side of the gas-oil contact.
The subsequent flash determines the phase split. Type 3 uses ZMFVD as
liquid composition below the contact and the equilibrium vapour above
it. When saturation-pressure adjustment is enabled, replace the
supplied pressure only when it differs from the bubble point by at
least one atmosphere; item 11 = 1 preserves it.

Use RTEMPVD when present and RTEMP otherwise. Equilibrate EQLNUM
regions independently, and reject type 2, COMPVD, and water zones.
Cover EQUIL types 1 and 3, item 11, independent EQLNUM regions,
constant and graded RTEMPVD, and missing ZMFVD. Pressure checks use
values from the reference 1D case.
EQUIL_1D_ZMFVD uses type-1 initialization and integrates pressure with
the liquid EOS root. Flashing the resulting total composition produces
gas in the methane-rich upper cells, and the short initial time steps
begin resolving its segregation. EQUIL_1D_ZMFVD_OIL initializes a gas
cap over a liquid leg with the contact at the liquid bubble-point
pressure.

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.

🟡 Changes recommended

The critical LGR/EQLNUM mapping defect and type 3 datum-depth validation issue must be addressed.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread opm/simulators/flow/FlowProblemComp.hpp Outdated
Comment on lines +454 to +456
const auto& e = eclState.fieldProps().get_int("EQLNUM");
assert(e.size() == eqlnum.size());
std::ranges::transform(e, eqlnum.begin(), [](const int r) { return r - 1; });

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in b576975: the copy now goes through
LookUpData::assignFieldPropsIntOnLeaf, the same mapping the black-oil
initializer uses in InitStateEquil_impl.hpp, so a refined cell inherits its
parent's EQLNUM and the unrefined case reduces to the identity.

One correction to the description: it was not an overrun. With local refinement
the leaf has more cells than the input grid, so the transform under-filled --
refined cells kept region 1 while the coarse cells received input-ordered
values in leaf-ordered slots. Silently wrong initialization rather than a
crash, and the per-cell range check could not catch it because region 1 is
valid.

Both regression decks give bit-identical initial states before and after, and
compequil still passes.

Comment on lines +433 to +438
if (std::abs(record.datumDepth() - reg.zgoc) > 0.0) {
OpmLog::warning(fmt::format("Equilibration region {}: the datum depth {} m "
"must be at the gas-oil contact when EQUIL "
"item 10 is 3; using the contact depth {} m.",
regionIdx + 1, record.datumDepth(), reg.zgoc));
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The datum depth and the contact routinely differ in practice -- every
compositional equilibration deck in our reference collection does so, including
the two shipped with this PR -- and the reference simulator accepts them.
EQUIL_1D_ZMFVD_OIL has a datum at 2010 m against a contact at 2050 m, and a
datum pressure of 150 bar against a saturation pressure of 160.56 bar at the
contact. Both warnings fire, the datum pressure is replaced, and the resulting
column matches the reference simulator to 6.5e-7 relative in pressure.
Rejecting that input would refuse a deck the reference accepts.

With item 11 = 1 the given datum pressure is deliberately kept and used at the
contact -- that is what item 11 asks for -- and GasCapKeepingDatumPressure in
tests/test_compequil.cpp pins it. That particular combination is not yet
validated against the reference simulator. If it turns out to apply a
hydrostatic correction from the datum depth instead, that is the thing to
change, rather than the acceptance of the input.

EQLNUM is given on the unrefined input grid while the equilibration works
on the leaf grid. Copying the array straight across left refined cells at
region 1 and the coarse cells with input-ordered values in leaf-ordered
slots. Use the same LookUpData mapping the black-oil initializer uses; it
reduces to the identity without local refinement.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:enhancement This is an enhancement/improvent that needs to be documented in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants