Skip to content

parsing for the keyword WELDRAW - #5305

Merged
bska merged 5 commits into
OPM:masterfrom
GitPaean:add-weldraw
Aug 27, 2026
Merged

bska merged 5 commits into
OPM:masterfrom
GitPaean:add-weldraw

Conversation

@GitPaean

@GitPaean GitPaean commented Aug 21, 2026 •

Copy link
Copy Markdown
Member

Adds the WELDRAW keyword, which sets a maximum allowable drawdown for production wells.

WELDRAW
  'PROD1' 50.0 2* AVG /
/

The record is parsed into a WELDRAW object on the Well: the maximum drawdown (a UDA), the target phase of item 3, and the mode of item 5. A defaulted target phase resolves to the well's preferred phase.

A well held back by its drawdown limit reports control mode 12 in WMCTL. The limit is stored in item 34 of SWEL and restored when a well is built from a restart file, so a restarted run applies the same limit as an uninterrupted one; the target phase is not stored and is resolved from the preferred phase.

The conversion of the limit into a rate is in OPM/opm-simulators#7346.
Test cases in OPM/opm-tests#1571.

@GitPaean GitPaean added the manual:new-feature This is a new feature and should be described in the manual label Aug 21, 2026
@GitPaean
GitPaean requested a balanced review from Copilot August 21, 2026 10:34

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 schedule parsing and state support for WELDRAW limits, including serialization and control-mode reporting.

Changes:

  • Introduces WELDRAW parsing, storage, UDA evaluation, and well integration.
  • Reports drawdown-limited producers through WMCTL.
  • Adds serialization and schedule parsing coverage plus restart warnings.

Reviewed changes

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

Show a summary per file
File Description
CMakeLists_files.cmake Registers WELDRAW sources and headers.
opm/input/eclipse/Schedule/ScheduleDeck.cpp Warns when restart processing skips WELDRAW.
opm/input/eclipse/Schedule/Well/WELDRAW.cpp Implements WELDRAW parsing and evaluation.
opm/input/eclipse/Schedule/Well/WELDRAW.hpp Defines the WELDRAW state API.
opm/input/eclipse/Schedule/Well/Well.cpp Stores and exposes WELDRAW state.
opm/input/eclipse/Schedule/Well/Well.hpp Declares WELDRAW integration.
opm/input/eclipse/Schedule/Well/WellPropertiesKeywordHandlers.cpp Handles WELDRAW schedule records.
opm/output/data/Wells.hpp Adds dynamic drawdown-control status.
opm/output/eclipse/Summary.cpp Reports drawdown as the active control mode.
opm/output/eclipse/VectorItems/well.hpp Defines the drawdown control code.
tests/parser/ScheduleSerializeTest.cpp Enables WELDRAW schedule serialization coverage.
tests/parser/ScheduleTests.cpp Tests parsed WELDRAW properties.
tests/test_Serialization.cpp Adds WELDRAW serialization coverage.

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

Comment thread opm/input/eclipse/Schedule/Well/WELDRAW.cpp Outdated
Comment thread opm/output/data/Wells.hpp Outdated
Comment thread opm/output/eclipse/Summary.cpp

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 16 out of 16 changed files in this pull request and generated no new comments.

Suppressed comments (1)

opm/input/eclipse/Schedule/eval_uda.cpp:71

  • If the UDQ is absent, output_value remains the undefined sentinel and is then pressure-converted. In non-SI unit systems this changes the sentinel, so callers can no longer recognize it with SummaryState::is_undefined_value(). Return udq_default directly when neither lookup succeeds, and convert only resolved UDQ values.
    return value.get_dim().convertRawToSi(output_value);

@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this please

@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this opm-simulators=7346 please

@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this opm-simulators=7346 please

1 similar comment
@bska

bska commented Aug 22, 2026

Copy link
Copy Markdown
Member

jenkins build this opm-simulators=7346 please

@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this opm-simulators=7346 failure_report please

@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this opm-simulators=7346 failure_report please

@GitPaean

Copy link
Copy Markdown
Member Author

I am marking this PR and also the downstream OPM/opm-simulators#7346 as ready for review to invite reviewers.

@GitPaean
GitPaean marked this pull request as ready for review August 24, 2026 19:10
@GitPaean
GitPaean requested review from akva2 and bska August 24, 2026 19:11

@akva2 akva2 left a comment

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.

Only some nitpickery found, plus confusing around missing cc.

Comment thread opm/input/eclipse/Schedule/Well/WELDRAW.cpp Outdated
Comment thread opm/input/eclipse/Schedule/Well/WELDRAW.hpp Outdated
Comment thread opm/input/eclipse/Schedule/eval_uda.cpp Outdated
Comment thread opm/input/eclipse/Schedule/Well/WELDRAW.hpp
@GitPaean

Copy link
Copy Markdown
Member Author

making this to be draft to amend the PR for agreed behavoir when the default item 2 is used. We should not support it.

@GitPaean
GitPaean marked this pull request as draft August 25, 2026 08:11
Comment thread opm/input/eclipse/Schedule/Well/WellPropertiesKeywordHandlers.cpp
@GitPaean
GitPaean force-pushed the add-weldraw branch 2 times, most recently from b8c48a1 to 81beb6d Compare August 25, 2026 08:50
@GitPaean

Copy link
Copy Markdown
Member Author

the WELDRAW regression cases will not run before OPM/opm-tests#1573 getting merged.

@GitPaean

GitPaean commented Aug 25, 2026 •

Copy link
Copy Markdown
Member Author

As the expected the regression tests with the WELDRAW keywords emits the following error message,

https://ci.opm-project.org/job/opm-common-PR-builder/10203/

Error: Problem with keyword WELDRAW
In /build/deps/opm-tests/weldraw/WELDRAW-01.DATA line 441
Item 2 of WELDRAW is defaulted for D-1H.  The item has no default and the maximum allowable drawdown must be given explicitly.

Error: Unrecoverable errors while loading input:
Problem with keyword WELDRAW
In /build/deps/opm-tests/weldraw/WELDRAW-01.DATA line 441
Item 2 of WELDRAW is defaulted for D-1H.  The item has no default and the maximum allowable drawdown must be given explicitly.
Failed to create valid EclipseState object.
Problem with keyword WELDRAW
In /build/deps/opm-tests/weldraw/WELDRAW-01.DATA line 441
Item 2 of WELDRAW is defaulted for D-1H.  The item has no default and the maximum allowable drawdown must be given explicitly.
CUDA ERROR (code = 34, CUDA driver is a stub library) at /tmp/opm/hypre/src/utilities/general.c:330

@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this opm-simulators=7346 failure_report please

@bska

bska commented Aug 25, 2026

Copy link
Copy Markdown
Member

jenkins build this failure_report please

@GitPaean

Copy link
Copy Markdown
Member Author

To make the PR build standalone needs to add WELDRAW.hpp to Well.hpp. It is needed in the serializer() in FlowGenericVanguard.cpp.

@GitPaean

Copy link
Copy Markdown
Member Author

To make the PR build standalone needs to add WELDRAW.hpp to Well.hpp. It is needed in the serializer() in FlowGenericVanguard.cpp.

But it will break the forward declaration pattern in the file. Please let me know if it is wanted.

@bska bska left a comment

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.

I finally looked at the details here and I think it's fine for the most part. I do have a couple of reservations that should be addressed in some way before we merge this.

As for

To make the PR build standalone needs to add WELDRAW.hpp to Well.hpp. It is needed in the serializer() in FlowGenericVanguard.cpp.

Right. In the past we've "just" added the requisite headers, e.g., WDFAC.hpp, to FlowGenericVanguard.cpp and ParallelSerialization.cpp. I think I'd prefer that we continue to do that. I haven't looked at the details of the downstream changes yet. Maybe that's exactly what it does.

Comment thread opm/io/eclipse/rst/well.cpp Outdated
Comment thread opm/input/eclipse/Schedule/Well/WELDRAW.hpp Outdated
@GitPaean
GitPaean force-pushed the add-weldraw branch 2 times, most recently from 3ea2e29 to 3f0fa8b Compare August 26, 2026 13:26

@bska bska left a comment

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.

Thanks a lot for the updates. This is getting close to ready as far as I can tell. The only remaining issue is the first-time construction of WELDRAW within a Well object created from WELSPECS or similar, i.e., not from a restart file.

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.

There should probably be an explicit WELDRAW::WELDRAW(const Dimension&) constructor too which properly constructs the UDAValue data member. That way, the normal Well constructor can use its UnitSystem argument to properly define the WELDRAW dimension from the start. The current initialisation in terms of the default constructor will not have appropriate unit conversion support configured from the start.

The constructor used at simulation restart is fine.

@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this opm-simulators=7346 failure_report please

Store the per-well maximum drawdown (value, target phase, AVG/MAX mode)
on the Well object.  A defaulted phase resolves from the preferred phase.
The mode and use-in-potentials properties are retained for input round
tripping even though OPM Flow rejects their non-default values at deck
load.
A producer held back by its maximum allowable drawdown is under drawdown
control, which is control mode 12, and not under the rate control which
carries the converted limit.  Add that mode to the well control mode values
and a flag on the dynamic control record for the simulator to raise, and
report it from WMCTL.
eval_well_uda() raises a symbolic value to at least the epsilon limit before
converting it, because a zero rate target means no limit and a negative one
is meaningless.  Neither applies to the maximum allowable drawdown, which is
a pressure, and where a non-positive value is how the caller is told that no
limit applies.  Evaluated through eval_well_uda(), a UDQ drawdown limit of
zero became 1e-20 Pascal instead and all but shut the well.

Add an evaluation which keeps the value as it is and use it for WELDRAW.

Also make the CurrentControl serialization test object a producer, so that
the round trip of the drawdown limited flag is covered rather than skipped
by the injector branch of the comparison, and check the reported control
mode of a drawdown limited well in the summary tests.
A restarted run discards the SCHEDULE keywords preceding the restart date
and builds its wells from the restart file, so a WELDRAW limit set before
that date was lost and the well produced at a higher rate than in an
uninterrupted run until the next WELDRAW keyword.

Write the maximum allowable drawdown to item 34 of SWEL and restore it when
a well is built from the restart file.  Zero records that no limit applies,
which is also how a limit removed by defaulting item 2 is stored.  The
target phase is not part of the restart file and is resolved from the well's
preferred phase, as a defaulted item 3 is, so a phase given explicitly is
not recovered.
Item 2 has no default, so a record which leaves it out has no maximum
allowable drawdown to apply.  Reject it rather than guessing at what was
meant.
@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this opm-simulators=7346 failure_report please

@bska bska left a comment

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.

Thanks a lot for the updates. This looks good to me now. I'll review the downstream companion PR before deciding how to proceed.

@bska

bska commented Aug 27, 2026

Copy link
Copy Markdown
Member

I'll review the downstream companion PR before deciding how to proceed.

The downstream looks good so I'll create reference solutions for the new regression test cases and then I'll merge this and its companion PR.

@bska

bska commented Aug 27, 2026

Copy link
Copy Markdown
Member

jenkins build this opm-simulators=7346 update_data please

@bska

bska commented Aug 27, 2026

Copy link
Copy Markdown
Member

jenkins build this opm-simulators=7346 opm-tests=1577 please

bska pushed a commit to OPM/opm-tests that referenced this pull request Aug 27, 2026
        PR OPM/opm-simulators#7346

Reason: PR OPM/opm-common#5305
        PR OPM/opm-simulators#7346

opm-common     = d673cf5d0a5f7cee3008860ebcd1f929503ef3c9
opm-grid       = 0f95d633d61058184576a2d795cd76482ef96daa
opm-simulators = 8a20b18fa72b9198220b3027e5059d84c094d55f

### Changed Tests ###

  * weldraw_02_gas
  * weldraw_01
  * weldraw_01_msw
bska added a commit to OPM/opm-tests that referenced this pull request Aug 27, 2026
…simulators_7346

Automatic Reference Data Update for PR OPM/opm-common#5305
@bska

bska commented Aug 27, 2026

Copy link
Copy Markdown
Member

Reference solutions for the new regression test cases have been installed on the CI system. I'll merge this and its downstream companion PR into the master branch.

@bska
bska merged commit 14f7a78 into OPM:master Aug 27, 2026
2 checks passed
@GitPaean
GitPaean deleted the add-weldraw branch August 27, 2026 09:05
@GitPaean

Copy link
Copy Markdown
Member Author

Some comments for the manual. @gdfldm

WELDRAW is now supported in Flow. The behaviour, item by item:

  1. Item 2 (maximum drawdown) has no default and must be given explicitly.
    A record that leaves it defaulted is rejected with an error pointing at
    the offending record. A non-positive value means no limit, so the limit
    can be removed by giving a negative value. The item accepts a UDA (restarting
    not supported yet).

  2. Item 3 (target phase) accepts LIQ or GAS. When defaulted it is taken
    from the well's preferred phase in WELSPECS: GAS for a gas well, LIQ
    otherwise.

  3. Item 4 (use in well potentials) must be NO, which is the default. YES is
    not supported and will be rejected at load.

  4. Item 5 (grid blocks) must be AVG, which is the default. MAX is not supported
    and will be rejected at load.

The limit is converted at each time step into a maximum production rate
for the target phase. A well held on its drawdown limit reports WMCTL =
12. The limit is preserved across a restart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:new-feature This is a new feature and should be described in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants