Skip to content

feat(gridgen): build GNC package input from gridgen output - #2789

Open
jdhughes-dev wants to merge 2 commits into
modflowpy:developfrom
jdhughes-dev:feat-gridgen-gnc
Open

feat(gridgen): build GNC package input from gridgen output#2789
jdhughes-dev wants to merge 2 commits into
modflowpy:developfrom
jdhughes-dev:feat-gridgen-gnc

Conversation

@jdhughes-dev

@jdhughes-dev jdhughes-dev commented Aug 4, 2026

Copy link
Copy Markdown
Contributor
  • Added Gridgen.get_gnc to read the ghost node data gridgen writes to qtg.gnc.dat

  • Added Gridgen.get_gridprops_gnc6, Gridgen.get_gridprops_gnc5, and get_gridprops_gnc5 to convert it to MODFLOW 6 and MODFLOW-USG GNC Package input

  • Fixed MfUsgGnc.write_file, which truncated the contributing factors to three significant digits and wrote the options list with its Python repr

  • Fixed fmt_string, which joined the field formats with no separator regardless of the format of the list, so a value that filled its width ran into the next value

  • Closes bug: CLN package list output has no separator between fields #2788

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.7%. Comparing base (556c088) to head (959d731).
⚠️ Report is 183 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2789      +/-   ##
===========================================
+ Coverage     55.5%    72.7%   +17.2%     
===========================================
  Files          644      662      +18     
  Lines       124135   132705    +8570     
===========================================
+ Hits         68947    96542   +27595     
+ Misses       55188    36163   -19025     
Files with missing lines Coverage Δ
flopy/mfusg/mfusg.py 78.3% <100.0%> (+0.8%) ⬆️
flopy/mfusg/mfusggnc.py 83.0% <100.0%> (+1.9%) ⬆️
flopy/utils/__init__.py 100.0% <100.0%> (ø)
flopy/utils/gnc.py 100.0% <100.0%> (ø)
flopy/utils/gridgen.py 76.6% <100.0%> (-10.5%) ⬇️

... and 577 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Gridgen computes the ghost node data whenever it exports a grid and writes it
to qtg.gnc.dat, but the file was not read, so the data it already had was not
reaching the GNC Package.

Gridgen now reads the file with get_gnc and converts it to MODFLOW 6 and
MODFLOW-USG GNC Package input with get_gridprops_gnc6 and get_gridprops_gnc5.
Two notebooks show the workflow, and the MODFLOW 6 notebook compares the
corrected and uncorrected solutions against the exact solution for a confined
homogeneous problem with a linear head field.

Also corrects MfUsgGnc.write_file, which formatted the contributing factors
with %10.2e and truncated them to three significant digits, wrote the options
list with its Python repr, and wrote the record fields with no separator so
that a value filling its width ran into the next value.
fmt_string joined the field formats with no separator regardless of the format
of the list, so the fields of a free format list were held apart only by the
padding in each format. A value that filled its width ran into the next value
and the record could no longer be read with URWORD. Ten digit node numbers
were enough to merge four fields of a gnc record into one token, and a free
format CLN model was already writing output that only held together because of
the field widths.

The separator now follows the format of the list, the way MfList.fmt_string
already does it: a space for free format, which URWORD reads, and nothing for
fixed format, which is read by position. This replaces the sep argument added
earlier in this branch, which put the choice on the caller instead of taking
it from the format.

Closes modflowpy#2788
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.

bug: CLN package list output has no separator between fields

1 participant