modflowpy / flopy

A Python package to create, run, and post-process MODFLOW-based models.
https://flopy.readthedocs.io
Other
507 stars 307 forks source link

FloPy MODFLOW-USG support (with .bas file example) #1476

Open martinvonk opened 2 years ago

martinvonk commented 2 years ago

Hi y'all,

I am using MODFLOW-USG (version 1.10) and it is currently not fully compatible with FloPy. Are there plans to support newer MODFLOW-USG versions in the future? I can also contribute to this if you guys don't have the time but I don't know your philosophy on supporting MODFLOW-USG.

For instance, one of the issues I'm running into are the options in the BAS package. In MODFLOW-USG there are other options such as UNSTRUCTURED or RICHARDS that can be provided on the first line of the .bas file. The ModflowBas class (in flopy.modflow.mfbas.py) has the attribute options to which you can assign a custom list. However these options are not written to the eventual file (because of line 241: opts=[]). This example is one of the simpler things to fix. However, it can become a lot more difficult with the LPF and OC package for which MODFLOW-USG requires significantly different files.

Thank you in advance!

cnicol-gwlogic commented 2 years ago

Hi Martin,

That would be great to have someone else help with Flopy mfusg support. The below is from my email to you, for the record, but maybe USGS can add anything on it.

Flopy support for usg-transport is currently very limited as it seems you have encountered. The main reason is that to start incorporating USG-transport capabilities into Flopy (above the primary capabilities of the USGS version of mfusg), @langevin-usgs is open to the idea, but first we need to set up a USG-Transport Github repository patterned on the mf6 repository in terms of issuing tagged releases, so that we can start to incorporate Flopy autotests for USG-Transport (i.e. the Flopy CI framework downloads usg-transport from the new repo / latest release, then executes USG-Transport test scripts).

Sorab is also fine with the idea of me (or someone) making a new USG-Transport repository for this, but ideally we would do this in Sorab's usg-transport repo. I had planned on starting this late last year - but have been swamped with work since, so I've not progressed it. I'd be very happy if someone did though. Note that if we do make such changes, there will no doubt be calls for support with issues too, for which USGS will look to others to provide.

Current mfusg capability examples are here (CLN) and here (Gridgen). Unstructured grids are supported. There are also a bunch of examples in the autotest folder (you'd have to keyword search all files for "mfusg").

For Flopy support of USG_Transport's Richards equation, this would need some work in the mfusg LPF package, and the BAS as you say in your github issue (noting that I think you could possibly get away without richards BAS keyword using LPF LAYTYP = 5). My understanding is that USGS want autotests for any such changes - which means we need the above tagged release repository set up, and Flopy CI framework updated. This is the first barrier to any significant USG-Transport additions, as far as I have been told by @langevin-usgs.

Chris.

langevin-usgs commented 2 years ago

Hey guys, I think @cnicol-gwlogic did a nice job laying out the issues here. I think the flopy development team remains open to the idea of having MODFLOW-USG and USG-Transport supported by FloPy. Ideally, this will continue to happen in a systematic way in which we reduce or eliminate code duplication and pursue test-driven development. @cnicol-gwlogic has been doing a really nice job with the MODFLOW-USG refactoring thus far to get this right.

We've learned over the years that the CI procedures and testing are critical for maintaining robust software; however, CI requires a lot of tending to keep everything tested and up to date. You may have noticed that we recently revamped all the FloPy tests using pytest fixtures and procedures. Also, as @cnicol-gwlogic has found, once capabilities are released there will undoubtedly be questions and bugs and we'll be looking to you to help field them. Getting a USG-Transport repo up-to-date with CI and testing would be a really nice place to start.

martinvonk commented 1 year ago

I currently have a FloPy fork that supports some features of the latest MODFLOW-USG Transport version: https://github.com/martinvonk/flopy/tree/usg. However, this is not tested and a bit experimental.

martinvonk commented 10 months ago

I made a start with BCT package support (#1010) on the FloPy fork mentioned above for those who are interested.