Skip to content

Use the same MSW acceleration term for injection and production - #7642

Draft
hnil wants to merge 3 commits into
OPM:masterfrom
hnil:fix-msw-injector-acceleration-sign
Draft

hnil wants to merge 3 commits into
OPM:masterfrom
hnil:fix-msw-injector-acceleration-sign

Conversation

@hnil

@hnil hnil commented Nov 2, 2026

Copy link
Copy Markdown
Member

The velocity head was multiplied by a sign that depended on the flow direction, so an injector got the opposite pressure change to a producer. Momentum flux is even in velocity: p + rho v^2 is conserved along a pipe in either direction, so the closed end of a segment sits rho v^2 above its outlet for both. Friction keeps its sign, since it opposes the flow.

The flip came with e9d040a, whose message asks whether it is correct and says the reference simulator seems to do this. That comparison is not recorded and has not been repeated here, so injecting MSW wells using HFA may now differ from the reference.

tests/msw_acceleration.DATA has an injector and a producer with identical horizontal pipes at 10000 sm3/d, where acceleration dominates. Pressure change along the segments against the momentum balance, bar (closed-end pair):
injector producer
before fix -0.555 vs +0.525 +0.555 vs +0.555
after fix +0.531 vs +0.531 +0.555 vs +0.555

Results change for wells using HFA, the WELSEGS default, with flow towards the toe in a segment: injectors, and producers with reversed segment flow. In opm-tests, with the flags the tests use (--enable-tuning=true), WINJMULT_MSW (final FOPT +0.02 %, injector BHP up to 0.7 % against 0.08 % from halving the time step) and WINJDAM_MSW (FOPT +0.06 %) need new reference data. MSW-2D-VERT-02, an HFA producer, keeps its summary output within tolerance but two XGRP entries exceed it, so it may need an update too. SPE1CASE2_MSW uses H-- and is identical.

The velocity head was multiplied by a sign that depended on the flow
direction, so an injector got the opposite pressure change to a producer.
Momentum flux is even in velocity: p + rho v^2 is conserved along a pipe in
either direction, so the closed end of a segment sits rho v^2 above its outlet
for both. Friction keeps its sign, since it opposes the flow.

The flip came with e9d040a, whose message asks whether it is correct and
says the reference simulator seems to do this. That comparison is not recorded
and has not been repeated here, so injecting MSW wells using HFA may now
differ from the reference.

tests/msw_acceleration.DATA has an injector and a producer with identical
horizontal pipes at 10000 sm3/d, where acceleration dominates. Pressure change
along the segments against the momentum balance, bar (closed-end pair):
                  injector          producer
  before fix  -0.555 vs +0.525  +0.555 vs +0.555
  after fix   +0.531 vs +0.531  +0.555 vs +0.555

Results change for wells using HFA, the WELSEGS default, with flow towards
the toe in a segment: injectors, and producers with reversed segment flow.
In opm-tests, with the flags the tests use (--enable-tuning=true),
WINJMULT_MSW (final FOPT +0.02 %, injector BHP up to 0.7 % against 0.08 % from
halving the time step) and WINJDAM_MSW (FOPT +0.06 %) need new reference data.
MSW-2D-VERT-02, an HFA producer, keeps its summary output within tolerance but
two XGRP entries exceed it, so it may need an update too. SPE1CASE2_MSW uses
H-- and is identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hnil
hnil requested review from ElyesAhmed and GitPaean and removed request for ElyesAhmed November 2, 2026 16:30
@GitPaean GitPaean added the manual:bugfix This PR is a bug fix and should be noted in the manual label Nov 2, 2026
@GitPaean

GitPaean commented Nov 2, 2026

Copy link
Copy Markdown
Member

Jenkins build this please

Comment thread tests/check_msw_acceleration.py Outdated
if abs(measured - expected) > TOLERANCE:
failed = True
# Keeps the check sensitive to the acceleration term.
if seg != 2 and abs(flux) < 10 * abs(friction):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A shut well has zero flux, friction and pressure differences, so every balance holds, and this check passes too because 0 < 0 is false. Since Flow can shut a well it cannot solve and still finish successfully, the test can pass without checking either flow direction. Checking that both wells deliver their target rate, e.g. SWFR of segment 2 at 10000 sm3/d, would close that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It does not say that the PR uses SHUT wells, but the script will have problems if the script is used for SHUT wells.

@GitPaean

GitPaean commented Nov 2, 2026

Copy link
Copy Markdown
Member

e9d040a also removed the 1/2 factor, which needs a reference results to justify.

@GitPaean

GitPaean commented Nov 2, 2026

Copy link
Copy Markdown
Member

From what I can understand, the PR is correct. However, I would like to invite @totto82 to have a look, both the sign issue and also the 0.5 factor issue. Maybe some reference results need to be checked.

@GitPaean
GitPaean requested a review from totto82 November 2, 2026 22:26
@totto82

totto82 commented Nov 3, 2026

Copy link
Copy Markdown
Member

This was 6 years ago, so my memory is a bit blurred. I don't even remember which case I was working on at that time. I think removing 2 was correct, but the suggested sign change might be wrong. I will do some more testing and digging and report back.

Velocity changes along a segment because fluid crosses the wall, so the
momentum balance depends on the axial speed u of that fluid:

  A dp = -m dv - (v - u) dm

Fluid leaving already moves with the pipe (u = v), so p + rho v^2 / 2 is
conserved. Fluid entering has none (u = 0) and is accelerated by mixing, so
p + rho v^2 is conserved. The previous commit used the second form in both
directions, which raises the injector's total pressure along the flow.

Use a coefficient of 1/2 at a perforated segment with net outflow through
the wall and where flow divides into several inlets, with the inlet heads
entering as their flow-weighted mean. Everything else keeps coefficient 1,
which is also exact when only the density changes along a pipe.

tests/msw_acceleration.DATA gains an injector and a producer that branch.
From segment 1 to the closed end the injector's p + rho v^2 / 2 changes by
-0.121 bar, equal to the reported friction. The check now also requires
each well to deliver its target rate, since a shut well satisfies every
balance.

No reference run has been compared. In opm-tests, with the flags the tests
use, WINJMULT_MSW (final FOPT +0.011 %) and WINJDAM_MSW (+0.042 %) change, as
do MSW_MODEL_1, FAULTS_MODEL_1 and MSW_MODEL_1_SHORT, whose producers have
perforated segments with net outflow (FOPT at most 1.4e-3), so they need new
reference data. MSW-2D-VERT-02 and MSW-3D-TWO-PRODUCERS differ only in a few
restart entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@GitPaean GitPaean added manual:irrelevant This PR is a minor fix and should not appear in the manual and removed manual:irrelevant This PR is a minor fix and should not appear in the manual labels Nov 3, 2026
A producer segment that loses fluid through the wall takes coefficient 1/2,
but no test well covered it. PRODX has two isolated cells with a pressure
contrast, so segment 3 loses about 3900 sm3/d to the low-pressure cell.
Master and the sign change alone give -1.97 bar there against -0.96 from the
balance. The numbers of the other wells do not change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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:bugfix This PR is a bug fix and should be noted in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants