Skip to content

Compositional well water support - #7442

Draft
GitPaean wants to merge 25 commits into
OPM:masterfrom
GitPaean:comp-well-water-support
Draft

GitPaean wants to merge 25 commits into
OPM:masterfrom
GitPaean:comp-well-water-support

Conversation

@GitPaean

Copy link
Copy Markdown
Member

No description provided.

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

Copy link
Copy Markdown
Member Author

jenkins build this please

@GitPaean

GitPaean commented Sep 23, 2026 •

Copy link
Copy Markdown
Member Author

jenkins build this failure_report please

https://ci.opm-project.org/job/opm-simulators-PR-builder/10733/

@GitPaean
GitPaean force-pushed the comp-well-water-support branch from e88cb4d to 7f932b0 Compare September 24, 2026 08:15
Size the mobility and surface-rate data for every active phase. Allow water-enabled reservoirs with gas wells or producers, while rejecting unsupported water injectors until the wellbore equations support them.
Add a wellbore water volume fraction and a water mass-balance row. Include water in connection rates and surface-volume splitting so mobile water production and WRAT control work while the hydrocarbon flash remains unchanged.
Form the Schur-complement contribution to the reservoir matrix, scale it to the volume-specific residual, and apply the residual correction using local connection indices. Extend the equation test to cover nonzero cell indices.
Use the DENSITY surface reference for water, report the final phase split after each accepted time step, and carry wellbore water inventory and pressure across report steps for producers and injectors.
Keep the well equations solvable when the hydrocarbon share vanishes. Initialize water injectors with a full water wellbore and a flash-valid hydrocarbon composition from the connected cell.
Limit composition and pressure changes in each Newton step. If a trial wellbore state cannot be assembled, back off toward the last state that assembled successfully.
Constrain the sum of surface oil and water rates and switch to LRAT when the liquid-rate limit is exceeded under another control.
@GitPaean
GitPaean force-pushed the comp-well-water-support branch from 613aca6 to 3be4912 Compare September 24, 2026 09:39
GitPaean added a commit to GitPaean/opm-tests that referenced this pull request Sep 24, 2026
Add six development decks for OPM/opm-simulators#7442, with shared grid, properties, summary, and reporting includes. Keep the case-specific initial states and schedules in the DATA files. CI will generate reference results.
@GitPaean

GitPaean commented Sep 24, 2026 •

Copy link
Copy Markdown
Member Author

jenkins build this opm-tests=7442 failure_report please

I put the 7442 wrongly by mistake.

@GitPaean

GitPaean commented Sep 24, 2026 •

Copy link
Copy Markdown
Member Author

jenkins build this opm-tests=1621 failure_report please

the results look expected.

https://ci.opm-project.org/job/opm-simulators-PR-builder/10739/

GitPaean added a commit to GitPaean/opm-tests that referenced this pull request Sep 24, 2026
Add six development decks for OPM/opm-simulators#7442, with shared grid, properties, summary, and reporting includes. Keep the case-specific initial states and schedules in the DATA files. CI will generate reference results.
GitPaean added a commit to GitPaean/opm-tests that referenced this pull request Sep 24, 2026
Add six development decks for OPM/opm-simulators#7442, with shared grid, properties, summary, and reporting includes. Keep the case-specific initial states and schedules in the DATA files. CI will generate reference results.
@GitPaean
GitPaean requested a balanced review from Copilot September 24, 2026 11:44

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.

Copilot review overview

🟡 Changes recommended

Injector validation and empty-perforation initialization contain unresolved crash or invalid-state paths.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity

Open (2)
What changed in this PR

Adds water-phase support to the experimental compositional well model, including water inventory, controls, rates, and coupling.

Changes:

  • Adds water wellbore state, conservation equations, and WRAT/LRAT controls.
  • Adds Schur-complement matrix contributions and Newton stabilization.
  • Adds unit and regression coverage for water wells and injector switching.
File Description
tests/​test_compwell_equations.cpp Tests water-filled well equation handling.
regressionTests.cmake Registers compositional water regressions.
flowexperimental/​comp/​wells/​SingleCompWellState.hpp Stores wellbore water fraction.
flowexperimental/​comp/​wells/​SingleCompWellState_impl.hpp Initializes and preserves water state.
flowexperimental/​comp/​wells/​CompWellState.hpp Extends injector initialization inputs.
flowexperimental/​comp/​wells/​CompWellState_impl.hpp Supplies reservoir composition to injectors.
flowexperimental/​comp/​wells/​CompWellPrimaryVariables.hpp Adds water primary variable and equation.
flowexperimental/​comp/​wells/​CompWellPrimaryVariables_impl.hpp Handles water fraction and damped updates.
flowexperimental/​comp/​wells/​CompWellModel.hpp Enables matrix contributions.
flowexperimental/​comp/​wells/​CompWellModel_impl.hpp Preserves water inventory and refreshes rates.
flowexperimental/​comp/​wells/​CompWellInterface.hpp Exposes surface-rate updates.
flowexperimental/​comp/​wells/​CompWellInterface_impl.hpp Validates supported injector configurations.
flowexperimental/​comp/​wells/​CompWellEquations.hpp Adds scaling, pinning, and extraction APIs.
flowexperimental/​comp/​wells/​CompWellEquations_impl.hpp Implements scaled Schur-complement operations.
flowexperimental/​comp/​wells/​CompWell.hpp Declares water-related well quantities.
flowexperimental/​comp/​wells/​CompWell_impl.hpp Implements water flow, inventory, controls, and reporting.

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

Comment thread flowexperimental/comp/wells/SingleCompWellState_impl.hpp Outdated
Comment thread flowexperimental/comp/wells/CompWellInterface_impl.hpp Outdated
@GitPaean

Copy link
Copy Markdown
Member Author

Fixed both Copilot findings in b11d758: guard empty water-injector connections and reject OIL/MULTI injection; the flow_comp build and targeted checks passed.

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.

Copilot review overview

🔵 Needs a closer look

The change substantially affects nonlinear well conservation, state persistence, and reservoir Jacobian coupling, warranting final human validation.

Review effort: Balanced
Findings: None

Resolved since last review (2)

Reject water injection before indexing the water phase in a model that
has no active water phase. This gives an input error instead of an
assertion failure or an out-of-bounds write.

Reject singular well matrices rather than using an identity inverse in
the Schur complement. Refresh the well state after each successful
assembly, including a backoff retry, so control switching and reported
rates use the current surface split. The end-of-timestep flash is no
longer needed.

Exercise Schur extraction with nonzero cell indices and residual scales,
and check that singular matrices are rejected. Format the changed lines.
@GitPaean
GitPaean force-pushed the comp-well-water-support branch from 138433d to 415eebf Compare September 24, 2026 22:21
@GitPaean

GitPaean commented Sep 24, 2026 •

Copy link
Copy Markdown
Member Author

jenkins build this failure_report please

https://ci.opm-project.org/job/opm-simulators-PR-builder/10746/

With a zero total rate a rate control equation has no dependence on the
primary variables, so a producer that started a report step on WRAT, or on
ORAT/GRAT/LRAT without that phase in the stream, had a singular well matrix.
WELTARG can add a WRAT limit to a producer in a deck without water, and the
check then read past the end of the phase rates.
Before the well equations converge the rates come from the initial guess,
such as the -1000 m3/day seeded for BHP producers, or pair the latest total
rate with the previous surface split. Check the rate limits only once the
equations have converged and solve again after a switch. The bhp limits are
still checked every iteration.
After the halved steps keep failing, assemble at the last assembled state
and stop the well iteration instead of failing the time step. Also back off
on the Dune::FMatrixError the AD flash throws for a singular derivative
system, which previously aborted the run.
Replace the carry-over loop in initWellState with the existing
CompWellState::init(prev_well_state) path, and make copyRuntimeStateFrom
carry what the loop did: bhp, water fraction and composition.
A well without open connections at the previous report step never had its
composition set, so carrying it over replaced the cell composition with
zeros, which became a uniform composition once normalized.
Move the mixing of the flashed hydrocarbons with wellbore water into
wellboreContents() next to the other extracted flash helpers, use it for
both the explicit and the new wellbore masses, and check its derivatives,
including those with respect to the water fraction, against finite
differences.
A water injector's surface stream is water alone, so fill its surface split
directly instead of flashing the pinned hydrocarbon composition, whose
failure could not be escaped. With water alone in the wellbore every flash
derivative is multiplied by zero, so use the scalar wellbore flash there.
Only C carries the reservoir residual's 1/volume factor, so apply it when
filling C instead of keeping per-connection scales in CompWellEquations.
apply() and extract() go back to plain C^T D^-1.
flow_comp registers --dwell-fraction-max and --dbhp-max-rel with the
black-oil model parameters, but the compositional wells used hardcoded
copies of their defaults. flowexp_comp does not register them, so it keeps
the defaults.
update_injector_targets() rejects unsupported injectors before any well is
created, so the checks in the CompWellInterface constructor never fire.
Dispatch on the injector type once there, and update comments that no
longer match the primary variable layout or the singular matrix handling.
@GitPaean

GitPaean commented Sep 25, 2026 •

Copy link
Copy Markdown
Member Author

jenkins build this failure_report please

https://ci.opm-project.org/job/opm-simulators-PR-builder/10752/

Before this PR an OIL injector took its stream from WINJGAS like a gas
injector. Keep that instead of rejecting it, and report the injected rate
as oil rather than gas.

This branch has not been deployed

No deployments
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