Beyond Model Use – Enabling Model Users to Add New Algorithms to Groundwater Models

Mike Müller1, Christian Engelmann2, Martin Binder3
1 hydrocomputing GmbH & Co. KG
2 Technische Universität Dresden, Institute of Groundwater Management, Department Environmental Informatics, Helmholtz-Centre for Environmental Research – UFZ
3 Department Environmental Informatics, Helmholtz-Centre for Environmental Research – UFZ, Technische Universität Dresden, Institute of Groundwater Management

2.2 in Wasserquantitäts- und qualitätsmodellierung auf regionaler Skale - Herausforderungen und neue Ansätze

27.03.2020, 14:15-14:30, Weißer Saal

Applied numerical groundwater modeling usually implies using an existing software such as MODFLOW [1]. Such programs can be powerful for solving many objectives related to groundwater use. Nevertheless, some problems can be hard to solve, as they may require repeated model runs and modifications of model input data for a next run based on results of a prior model run. This is often the case if boundary conditions, which are defined by the modeler, change with respect to model results (i.e., dynamic boundary conditions). Some of these scenarios may considerably increase modeling work load, or may be nearly impossible to be represented with reasonable effort.

One possibility to simplify the implementation of dynamic boundary conditions can be the automated generation of input data based on model results of previous runs. While this approach can significantly reduce the manual work of the modeler, it may not be suitable for certain types of problems. Furthermore, it may lead to long model run times due to large amounts of automated model runs. Another approach would be to modify the source code of MODFLOW. However, this requires sound programming skills in Fortran [2] as well as in-depth knowledge of MODFLOW´s source code.


The new software library pymf6 [3] provides a different solution. It converts MODFLOW 6 [1] into a Python [4] extension module. This allows accessing all MODFLOW variables at model run time from Python. At each time step, the modeler can read from and write to these variables. In addition to this low-level interface, pymf6 provides a high-level way of modifying boundary condition values at run time without the need to write and compile any Fortran code. By using a rather simple Python script (i.e., plug-in), the modeler can get full control of the model at each model time step. In addition, the modeler can work interactively with MODFLOW, inspecting variables in a Jupyter Notebook [5] or at the interactive Python prompt.

Here, we present an exemplary application of the aforementioned approach. An extraction well and an injection well can be coupled. The modeler can define an upper and a lower limit of the water level at the extraction well. At each time step, the Python script checks if the water level is still within limits and increases or decreases the pumping rate accordingly. Hereby, the injection rate is always set to the negative value of the pumping rate. This leads to a dynamic coupling of both wells, where the pumping well´s water level stays within the desired range.
Many more scenarios are possible, especially for the coupling with other models. Simple scenarios can be implemented with a few lines of Python code. More sophisticated applications such as the coupling with surface water models, models of the unsaturated zone, geochemical models, or detailed technical models of pumps may further increase plug-in complexity.



[1] Langevin, C.D.; Hughes, J.D.; Banta, E.R.; Provost, A.M.; Niswonger, R.G.; Panday, S. (2018). MODFLOW 6 Modular Hydrologic Model version 6.0.3: U.S. Geological Survey Software Release, 9 August 2018, https://doi.org/10.5066/F76Q1VQV
[2] ISO/IEC 1539-1:2010: Fortran 2008  Available under https://www.iso.org/standard/50459.html
[3] Müller, M.; Engelmann, C.; Binder, M.; Händel, Falk (2019). Pymf6 - Python wrapper for MODFLOW 6. Available under https://github.com/hydrocomputing/pymf6
[4] PSF (2019) Python Software Foundation. Python Language Reference, Version 3.7. Available under http://www.python.org
[5] Project Jupyter. Jupyter homepage. Available under https://jupyter.org/



Export as iCal: Export iCal