Hydrology, applied

Rivers, aquifers and other wet things that can flood your house



MODFLOW

MODFLOW is the USGS’s modular hydrologic model. MODFLOW is considered an international standard for simulating and predicting groundwater conditions and groundwater/surface-water interactions. MODFLOW 6 is presently the core MODFLOW version distributed by the USGS. The previous core version, MODFLOW-2005, is actively maintained and supported as well.

flopy

The FloPy package consists of a set of Python scripts to run MODFLOW, MT3D, SEAWAT and other MODFLOW-related groundwater programs. FloPy enables you to run all these programs with Python scripts.

But how do you install MODFLOW? It’s one of those US government software packages which is perfectly respectable and functional but some versions use a “classic”, which is to say, antiquated, mode of development. (I mean, it does date to 1988.) There are various versions which are incompatible with each other to some unexplained extent. These have version numbers like NWT, 2005 and 6, and varying degrees of modern convenience.

For example, MODFLOW-2005, a version of a… distinguished vintage, has no source code repository (not for us punters anyway), just giant (like, 400MB) zip files full of compiled Windows binaries with big chunks of fortran code embedded in there like chunky choco for compilation by the adventurous.

Thankfully, the community have made modflow pymake. The documentation was a little confusing (it seems to suggest I should use certain scripts that are not installed per default), but they all turn out to be one-liners. Here is how to install MODFLOW-NWT:

pip install git+https://github.com/modflowpy/pymake.git
python

Then

import pymake
pymake.build_apps("mfnwt")

This gets you a version that runs on linux or macos.

Alternatively one can use docker files. Here are some miscellaneous docker files I am auditioning: lucasaugustomcc/modflow-nwt, flopymetascript, mintproject/modflow-2005 (the most popular one).

In the case of the more recent MODFLOW 6 it can be installed via conda:

conda install -c conda-forge modflow6

MODFLOW 6 has a source code repository and other trappings of modernity. It compiles and runs everywhere etc, but it does not implement all the features of historical MODFLOW versions, or so I am told.

References

Anderson, Mary P., William W. Woessner, and R. J. Hunt. 2015. Applied Groundwater Modeling: Simulation of Flow and Advective Transport. Second edition. London ; San Diego, CA: Academic Press.
Bakker, M., V. Post, C. D. Langevin, J. D. Hughes, J. T. White, J. J. Starn, and M. N. Fienen. 2016. Scripting MODFLOW Model Development Using Python and FloPy.” Groundwater 54 (5): 733–39.
Cui, Tao, Luk Peeters, Dan Pagendam, Trevor Pickett, Huidong Jin, Russell S. Crosbie, Matthias Raiber, David W. Rassam, and Mat Gilfedder. 2018. Emulator-Enabled Approximate Bayesian Computation (ABC) and Uncertainty Analysis for Computationally Expensive Groundwater Models.” Journal of Hydrology 564 (September): 191–207.
Tonkin, Matthew, and John Doherty. 2009. Calibration-Constrained Monte Carlo Analysis of Highly Parameterized Models Using Subspace Techniques.” Water Resources Research 45 (12).
White, Jeremy T., Michael N. Fienen, and John E. Doherty. 2016. A Python Framework for Environmental Model Uncertainty Analysis.” Environmental Modelling & Software 85 (November): 217–28.
Yu, Xiayang, Tao Cui, J. Sreekanth, Stephane Mangeon, Rebecca Doble, Pei Xin, David Rassam, and Mat Gilfedder. 2020. Deep Learning Emulators for Groundwater Contaminant Transport Modelling.” Journal of Hydrology, August, 125351.

No comments yet. Why not leave one?

GitHub-flavored Markdown & a sane subset of HTML is supported.