Hydrology, applied

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

September 7, 2020 — June 30, 2022

geometry
machine learning
physics
statmech
straya
Figure 1

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 has 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.

1 References

Anderson, Woessner, and Hunt. 2015. Applied Groundwater Modeling: Simulation of Flow and Advective Transport.
Bakker, Post, Langevin, et al. 2016. Scripting MODFLOW Model Development Using Python and FloPy.” Groundwater.
Cui, Peeters, Pagendam, et al. 2018. Emulator-Enabled Approximate Bayesian Computation (ABC) and Uncertainty Analysis for Computationally Expensive Groundwater Models.” Journal of Hydrology.
Tonkin, and Doherty. 2009. Calibration-Constrained Monte Carlo Analysis of Highly Parameterized Models Using Subspace Techniques.” Water Resources Research.
White, Fienen, and Doherty. 2016. A Python Framework for Environmental Model Uncertainty Analysis.” Environmental Modelling & Software.
Yu, Cui, Sreekanth, et al. 2020. Deep Learning Emulators for Groundwater Contaminant Transport Modelling.” Journal of Hydrology.