Skip to main content

Python Wrapper for MODFLOW 6

Project description


Python Wrapper for MODFLOW 6


Currently, the simplest way to install is to use the provided conda package. You need to install Anaconda or Miniconda. Once installed, add two channels to your config:

conda config --add channels msys2
conda config --add channels hydrocomputing

and install pymf6 with:

conda install pymf6


pymf6 support interactive use in Jupyter Notebook sees this example for Notebook session. The documentation of MODFLOW6 packages is very useful to understand the meaning of the available data.

You need to provide a callback, i.e. a Python callable that will be call by MODLFOW 6 for each time step. A class with a special method __call__ allows to keep state between calls.

This is a simple example:

#!/usr/bin/env python

# Change to directory `examples/ex16-mfnwt2` before running this script.

"""Example program that shows some temporal information from MF6.

from pymf6.callback import Func
from pymf6 import mf6

class MyFunc(Func):
    """Class whose instances act like a function, i.e. are callables

    def __init__(self):
        # First model. There is only one.
        self.model = self.simulation.models[0]
        # First simulation. There is only one.
        self.sim = self.simulation.solution_groups[0]

    def __call__(self):
        Override the `__call__´ from `Func`.

        :return: None
        # If the in stress period 3
        if self.simulation.TDIS.KPER.value == 3:
            # set all constant head boundary conditions to 10
            self.model.CHD_1.BOUND[:] = 10
            # Change ths values to see how the calculated water level changes.
            # other set them to 25.
            self.model.CHD_1.BOUND[:] = 25
        # Show the mean water level to see changes of modifying CHD_1.

if __name__ == '__main__':

Depending on the number of the stress period, the values of all constant head boundary conditions are set to 10 or 25.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pymf6, version 0.4.2
Filename, size File type Python version Upload date Hashes
Filename, size pymf6-0.4.2-py3-none-any.whl (2.1 MB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page