Skip to content

feat: support mf6 binary output file conversion#2746

Open
wpbonelli wants to merge 10 commits intomodflowpy:developfrom
wpbonelli:nwt-to-mf6
Open

feat: support mf6 binary output file conversion#2746
wpbonelli wants to merge 10 commits intomodflowpy:developfrom
wpbonelli:nwt-to-mf6

Conversation

@wpbonelli
Copy link
Copy Markdown
Member

@wpbonelli wpbonelli commented Apr 14, 2026

Classic MODFLOW programs (NWT, MF2005, MF2000) produce binary output files that MF6 post-processors (e.g. PRT) cannot directly consume, because the budget format is fundamentally different and MF6 requires a binary grid file that classic programs do not write. Add conversion capability so classic program output can be converted to MF6 format and used with MF6 transport or particle-tracking models.

Introduce ClassicMfToMf6Converter that reads a classic compact head/budget file pair and writes three files

  • .hds — copies verbatim
  • .bud — converts FLOW RIGHT/FRONT/LOWER FACE → FLOW-JA-FACE + DATA-SAT
  • .grb — creates binary grid file from DIS geometry

This builds on #2722 and required a few more utilities

  • get_icelltype_from_laytyp(): convert NWT LAYTYP to MF6 ICELLTYPE
  • get_icelltype_from_laycon(): convert BCF LAYCON to MF6 ICELLTYPE
  • get_saturation(): calculate saturation from head, cell geometry, cell type
  • get_structured_flowja(): inverse of get_structured_faceflows()
  • MfGrdFile.write_dis(): write grb file for structured grid

Usage

converter = ClassicMfToMf6Converter.from_model(mf, "model.hds", "model.cbc")  # from model
converter = ClassicMfToMf6Converter("model.hds", "model.cbc", nlay, nrow, ncol, ...)  # from files
converter.convert("mf6_output/")

Limitations

  • Requires compact budget output (COMPACT BUDGET in OC)
  • Structured grids only (DIS)
  • DATA-SPDIS not included yet

@wpbonelli wpbonelli added this to the 3.11 milestone Apr 14, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 78.71287% with 86 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.5%. Comparing base (556c088) to head (19cd49c).
⚠️ Report is 152 commits behind head on develop.

Files with missing lines Patch % Lines
flopy/utils/classic_to_mf6.py 73.5% 37 Missing ⚠️
flopy/mf6/utils/binarygrid_util.py 74.7% 27 Missing ⚠️
flopy/utils/postprocessing.py 80.9% 12 Missing ⚠️
flopy/mf6/utils/postprocessing.py 89.1% 10 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2746      +/-   ##
===========================================
+ Coverage     55.5%    72.5%   +16.9%     
===========================================
  Files          644      676      +32     
  Lines       124135   132800    +8665     
===========================================
+ Hits         68947    96312   +27365     
+ Misses       55188    36488   -18700     
Files with missing lines Coverage Δ
flopy/mf6/utils/__init__.py 100.0% <100.0%> (ø)
flopy/utils/__init__.py 100.0% <100.0%> (ø)
flopy/mf6/utils/postprocessing.py 92.5% <89.1%> (-4.3%) ⬇️
flopy/utils/postprocessing.py 80.2% <80.9%> (+2.6%) ⬆️
flopy/mf6/utils/binarygrid_util.py 86.5% <74.7%> (-4.3%) ⬇️
flopy/utils/classic_to_mf6.py 73.5% <73.5%> (ø)

... and 571 files with indirect coverage changes

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

@wpbonelli wpbonelli requested a review from jdhughes-dev April 14, 2026 11:22
@wpbonelli wpbonelli marked this pull request as ready for review April 14, 2026 11:44
@wpbonelli wpbonelli marked this pull request as draft April 15, 2026 16:59
@wpbonelli wpbonelli changed the title feat: support nwt to mf6 binary output file conversion feat: support mf6 binary output file conversion Apr 16, 2026
@wpbonelli wpbonelli marked this pull request as ready for review April 16, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant