Skip to content

feat(maw): activate and deactivate individual well connections - #2914

Merged
jdhughes-dev merged 11 commits into
MODFLOW-ORG:developfrom
jdhughes-dev:feat-maw-conn-status
Oct 1, 2026
Merged

jdhughes-dev merged 11 commits into
MODFLOW-ORG:developfrom
jdhughes-dev:feat-maw-conn-status

Conversation

@jdhughes-dev

@jdhughes-dev jdhughes-dev commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Adds a CONNECTION_STATUS setting to the MAW PERIOD block that activates or deactivates an individual well-aquifer connection during a simulation, so that a well that is backplugged or deepened can be represented; connection data is specified once for the maximum extent of the well and a connection that is sealed off, or not yet drilled, is given a status of INACTIVE. A connection is simulated only if both the well and the connection are active, so an INACTIVE well suspends all of its connections without changing their individual settings. At least one connection of a well must be ACTIVE; an error asks for STATUS INACTIVE when every connection is deactivated. MAW and CONDUCTANCE observations of an inactive connection are reported as DNODATA, and a connection that is not simulated, because it or its well is inactive, has no wetted area, so MWE does not conduct heat through it; previously an inactive well continued to conduct heat through its connections. A BOTTOM setting is also added, which raises the bottom elevation of a well that has been filled so that it stops yielding water at the elevation of the fill.

Checklist of items for pull request

  • Replaced section above with description of pull request
  • Added new test or modified an existing test
  • Ran ruff on new and modified python scripts in .doc, autotests, doc, distribution, pymake, and utils subdirectories.
  • Formatted new and modified Fortran source files with fprettify
  • Updated definition files
  • Updated develop.toml with a plain-language description of the bug fix, change, feature; required for changes that may affect users
  • Updated input and output guide
  • Removed checklist items not relevant to this pull request

For additional information see instructions for contributing and instructions for developing.

@jdhughes-dev jdhughes-dev added this to the 6.9.0 milestone Aug 10, 2026
@jdhughes-dev jdhughes-dev mentioned this pull request Sep 8, 2026
9 tasks done
@mjreno

mjreno commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

@jdhughes-dev this can be rebased on #2748 anytime- let me know if you have any issues or feedback.

@jdhughes-dev

Copy link
Copy Markdown
Contributor Author

Example: well 1 has three connections, specified in the CONNECTIONDATA block for the full depth of the well. The deepest connection is sealed off in period 2, as for a backplugged well, and reopened in period 4.

BEGIN period 1
  1  rate  -100.0
END period 1

BEGIN period 2
  1  connection_status  3  inactive
END period 2

BEGIN period 3
  1  status  inactive
END period 3

BEGIN period 4
  1  status  active
  1  connection_status  3  active
END period 4
  • A connection keeps its setting until it is changed, so connection 3 stays inactive in later periods.
  • STATUS INACTIVE in period 3 suspends every connection. In period 4, STATUS ACTIVE (or CONSTANT) restores the connection settings in effect before period 3, so connection 3 would still be inactive if it were not also reactivated.
  • Deactivating every connection of a well is an error; STATUS INACTIVE is used instead.

With flopy, the same settings are period data rows (well and connection numbers are zero-based):

perioddata = {
    0: [[0, "rate", -100.0]],
    1: [[0, "connection_status", 2, "inactive"]],
    2: [[0, "status", "inactive"]],
    3: [[0, "status", "active"], [0, "connection_status", 2, "active"]],
}

@jdhughes-dev
jdhughes-dev marked this pull request as ready for review September 30, 2026 14:23
Connection data for a multi-aquifer well applied to the whole simulation,
so a well that is backplugged or deepened while a simulation is running
could not be represented.

A new CONNECTION_STATUS setting in the PERIOD block activates or
deactivates an individual well-aquifer connection. Connection data is
specified once for the maximum extent of the well, and a connection that
is sealed off, or that represents a part of the well that has not been
drilled, is given a status of INACTIVE. An inactive connection does not
exchange water with its groundwater cell and is written to the budget
file with its cell number and a flow rate of zero.

A connection is simulated only if both the well and the connection are
active, so an INACTIVE well suspends all of its connections without
changing their individual settings and the previous settings are used
again when the well is made ACTIVE.

A BOTTOM setting is also added, which changes the bottom elevation of a
well so that a well that has been filled stops yielding water at the
elevation of the fill. BOTTOM does not change the amount of water
released from well storage for a given change in head, which is set by
the well radius.
A well with every connection set INACTIVE through CONNECTION_STATUS has no
connection to the aquifer and is better expressed as an inactive well, so
the stress period data is now checked and an error asks for STATUS INACTIVE
instead. The input guide states the rule, and that connection settings are
kept when a well is made CONSTANT as well as ACTIVE.

Tests cover the error, and a connection that stays inactive when the well
is made INACTIVE and then CONSTANT.
A connection set ACTIVE while the well is INACTIVE stays without flow until
the well is made ACTIVE, and then flows again.
MAW and CONDUCTANCE observations of an inactive connection were reported as
zero, while every observation of an inactive well is DNODATA. They are now
DNODATA as well, so an observation distinguishes a connection that is not
simulated from one with no flow. The input guide describes the behavior and
corrects "LAK" to "MAW" in the MAW observation description.
The wetted area MAW reports with each connection's flow was computed from
the screen geometry whether or not the connection was simulated, so MWE
kept conducting heat through a connection that had been deactivated, and
through every connection of an inactive well. A connection that is not
simulated, because it or its well is inactive, now has no wetted area.

Add GWE/MWE and GWT/MWT tests that deactivate a connection and then the
well, checking that no heat is conducted and no mass exchanged through a
connection that is not simulated.

Copilot AI left a comment

Copy link
Copy Markdown

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

BOTTOM handling is order-dependent, one diagnostic still counts inactive connections, and BOTTOM lacks regression coverage.

Review effort: Balanced
Findings: 2 Medium severity · 2 Low severity

Open (4)
What changed in this PR

Adds per-connection activation controls and dynamic well-bottom updates to MAW.

Changes:

  • Adds CONNECTION_STATUS and BOTTOM period settings.
  • Propagates inactive connections through flow, observations, MWT, and MWE.
  • Adds flow, transport, and energy regression tests.
File Description
src/​Model/​GroundWaterFlow/​gwf-maw.f90 Implements connection status and bottom behavior.
src/​Idm/​gwf-mawidm.f90 Registers new MAW inputs.
doc/​ReleaseNotes/​develop.toml Documents the feature.
doc/​mf6io/​mf6ivar/​dfn/​gwf-maw.dfn Defines input syntax.
doc/​mf6io/​gwf/​maw.tex Expands MAW guidance.
autotest/​test_gwf_maw_conn_status.py Tests groundwater-flow behavior.
autotest/​test_gwt_mwt_conn_status.py Tests mass transport behavior.
autotest/​test_gwe_mwe_conn_status.py Tests energy transport behavior.

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

Comment thread src/Model/GroundWaterFlow/gwf-maw.f90 Resolved
Comment thread src/Model/GroundWaterFlow/gwf-maw.f90 Resolved
Comment thread doc/ReleaseNotes/develop.toml Resolved
Comment thread src/Model/GroundWaterFlow/gwf-maw.f90 Resolved
BOTTOM was checked when its row was read, against the head and the
connections active at that point, so raising the bottom while deactivating a
deeper connection in the same period succeeded or failed depending on the
order of the rows; WELL_HEAD was checked against the bottom in the same
way. Both are now checked once every setting for the period has been
applied. The connection status is read before ICON is validated, so the
echoed input does not show the previous row's value, and the release note
states that the well STATUS must be set to INACTIVE.

Tests cover BOTTOM with CONNECTION_STATUS in both orders, a BOTTOM above an
active connection, and a BOTTOM above the head in the well.

Copilot AI left a comment

Copy link
Copy Markdown

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

Reactivated connections can bypass the new bottom constraint, and related diagnostics do not consistently exclude inactive connections or reflect final period state.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
Resolved since last review (4)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Filter inactive connections from over-demand calculation

src/​Model/​GroundWaterFlow/​gwf-maw.f90:4738

The over-demand calculation in maw_cc still sums every connection (lines 3198–3214) and does not apply this inactive-connection guard. An inactive high-head/high-conductance connection can therefore inflate qmax and suppress the diagnostic that an active well is requesting more water than its simulated connections can supply. Apply the same iboundconn filter in that loop.

Comment thread src/Model/GroundWaterFlow/gwf-maw.f90 Resolved
Comment thread src/Model/GroundWaterFlow/gwf-maw.f90 Resolved
…period

The screen-bottom check ran only for wells whose BOTTOM was set that period,
so a connection reactivated after the bottom was raised above its screen
bottom was accepted. Every active connection is now checked after each
period's settings are applied. The HEAD_LIMIT warning is evaluated at the
same point when BOTTOM or HEAD_LIMIT changes, so raising BOTTOM above an
existing head limit warns regardless of the order of the settings, and the
over-demand check in maw_cc skips inactive connections.

Tests cover reactivating a connection below a raised bottom and raising
BOTTOM above an existing HEAD_LIMIT.

Copilot AI left a comment

Copy link
Copy Markdown

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

CONSTANT wells can bypass the new BOTTOM-versus-head validation when no period WELL_HEAD is provided.

Review effort: Balanced
Findings: None

Resolved since last review (2)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Validate well head when switching to CONSTANT status

src/​Model/​GroundWaterFlow/​gwf-maw.f90:2351

When a period sets STATUS CONSTANT without WELL_HEAD, this check still uses the previous simulated xnewpak. maw_ad subsequently resets the constant head to the PACKAGEDATA STRT/stored well_head (lines 2606–2610), so a BOTTOM can be accepted even though the actual constant head is below it. The same gap occurs when BOTTOM was raised earlier and a later period switches the well to CONSTANT. Validate well_head whenever the final status is CONSTANT, and add a regression case using CONSTANT without an explicit WELL_HEAD.

A CONSTANT well holds its head at the stored WELL_HEAD, or at STRT when none
was given, but a raised BOTTOM was compared with the last simulated head, so
a well made CONSTANT without a WELL_HEAD could be accepted with its constant
head below the bottom. The well head of every CONSTANT well is now checked
against the bottom after each period's settings, and only wells that are not
CONSTANT are checked against the simulated head.

A test makes a well CONSTANT without a WELL_HEAD after raising BOTTOM above
its stored well head.
@jdhughes-dev
jdhughes-dev merged commit 022ac72 into MODFLOW-ORG:develop Oct 1, 2026
22 checks passed
@jdhughes-dev
jdhughes-dev deleted the feat-maw-conn-status branch October 1, 2026 14:32
@jdhughes-dev

Copy link
Copy Markdown
Contributor Author

Removed from develop for the 6.8.2 release by #3089 and restored by #3090, which is to be merged after 6.8.2.

jdhughes-dev added a commit that referenced this pull request Oct 28, 2026
)

This reverts commit 022ac72 (#2914), so the CONNECTION_STATUS and
BOTTOM options of the MAW PERIOD block are not in the 6.8.2 release. The
MAW, MWT, and MWE connection status tests and the release note go with
them.

The MWE case of the advanced transport API test from #3079 used the MWE
connection status model, so it now uses the MWE conduction model.
jdhughes-dev added a commit to jdhughes-dev/modflow6 that referenced this pull request Oct 28, 2026
…well

The wetted area of each connection that MAW writes to the budget for MWE
was calculated whatever the well status, so a well made INACTIVE kept
conducting heat with the aquifer. The wetted area of an inactive well is
now zero.

This is the part of MODFLOW-ORG#2914 that fixes existing behavior; MODFLOW-ORG#3089 removes
MODFLOW-ORG#2914 from 6.8.2.
jdhughes-dev added a commit that referenced this pull request Oct 28, 2026
…well (#3091)

The wetted area of each connection that MAW writes to the budget for MWE
was calculated whatever the well status, so a well made INACTIVE kept
conducting heat with the aquifer. The wetted area of an inactive well is
now zero.

This is the part of #2914 that fixes existing behavior; #3089 removes
#2914 from 6.8.2.
jdhughes-dev added a commit to jdhughes-dev/modflow6 that referenced this pull request Oct 31, 2026
Restores MODFLOW-ORG#2914, which was removed from develop for the 6.8.2 release.

Connection data for a multi-aquifer well applied to the whole simulation,
so a well that is backplugged or deepened while a simulation is running
could not be represented. A new CONNECTION_STATUS setting in the PERIOD
block activates or deactivates an individual well-aquifer connection, and
a new BOTTOM setting changes the bottom elevation of the well.
jdhughes-dev added a commit to jdhughes-dev/modflow6 that referenced this pull request Nov 16, 2026
Restores MODFLOW-ORG#2914, which was removed from develop for the 6.8.2 release.

Connection data for a multi-aquifer well applied to the whole simulation,
so a well that is backplugged or deepened while a simulation is running
could not be represented. A new CONNECTION_STATUS setting in the PERIOD
block activates or deactivates an individual well-aquifer connection, and
a new BOTTOM setting changes the bottom elevation of the well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants