Skip to main content

mf6adj

mf6adj

mf6adj is a Python package for adjoint-state sensitivity analysis with MODFLOW 6. It uses the MODFLOW 6 API to access the internal solution components at run time — no modifications to MODFLOW 6 are required. Given one or more user-defined performance measures (heads, boundary fluxes, or composite objectives), mf6adj computes the sensitivity of each measure to model parameters across the full model domain.

Installation

pip

pip install mf6adj

conda-forge

conda install -c conda-forge mf6adj

mf6adj drives MODFLOW 6 through its shared library (libmf6). The easiest way to get both is through the flopy helper:

get-modflow --subset mf6,libmf6 :python

Quick start

import flopy
import mf6adj

# locate the MF6 binary and shared library in the active conda environment
mf6_bin, lib_name = mf6adj.get_conda_mf6_paths()

# run the baseline forward model
flopy.run_model(exe_name=mf6_bin, namefile=None, model_ws="path/to/model")

# write a performance-measure file
with open("path/to/model/model.adj", "w") as f:
    f.write("begin performance_measure head_obs\n")
    f.write("1 1 1 5 5 head direct 1.0 -1.0e+30\n")
    f.write("end performance_measure\n")

# solve forward and adjoint
adj = mf6adj.Mf6Adj("model.adj", str(lib_name), working_directory="path/to/model")
adj.solve_forward_model()
sensitivity_dfs = adj.solve_adjoint()
adj.finalize()

print(sensitivity_dfs["head_obs"])

Documentation

Full documentation, including API reference and example notebooks, is available at mf6adj.readthedocs.io.

How to cite

If you use mf6adj in your work, please cite:

Hayek, M., White, J. T., Markovich, K. H., Hughes, J. D., & Lavenue, M. (2025). MF6-ADJ: A Non-Intrusive Adjoint Sensitivity Capability for MODFLOW 6. Groundwater, 63(6), 874–888. https://doi.org/10.1111/gwat.70025

License

CC0 1.0 Universal

Download files

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

Source Distribution

mf6adj-1.3.0.tar.gz (395.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mf6adj-1.3.0-py3-none-any.whl (81.9 kB view details)

Uploaded Python 3

File details

Details for the file mf6adj-1.3.0.tar.gz.

File metadata

  • Download URL: mf6adj-1.3.0.tar.gz
  • Upload date:
  • Size: 395.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mf6adj-1.3.0.tar.gz
Algorithm Hash digest
SHA256 8274628b2e25eb630ec8de9f0100fb3dfdd6e4058642c57ddbb7e33cf28b8f38
MD5 eeddf5bb93487b3ed9ec64a404e6dd9e
BLAKE2b-256 634eeadfcfe1e18ffac70f66786d80e1e8b09e0f44922dac127756203c5943e5

See more details on using hashes here.

File details

Details for the file mf6adj-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: mf6adj-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 81.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mf6adj-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d56969bc88923b6aafac14655fbf15711e8e25d0428d3b44d61b508ed8d286a5
MD5 aeb042c67580eb14ef3d33fbbc10c18b
BLAKE2b-256 5224c91fcbb8836d5137d596ffc9fad8035b481fcbe60b3553885bfd298f9e4f

See more details on using hashes here.

Release history Release notifications | RSS feed

1.4.0

2 files

This release

1.3.0 This release

2 files

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page