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

Metadata

Release files for mf6adj 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mf6adj 1.4.0
File Size Uploaded Provenance Actions
mf6adj-1.4.0.tar.gz 408.1 kB Without provenance Details for mf6adj-1.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mf6adj 1.4.0
File Interpreter ABI Platform Actions
mf6adj-1.4.0-py3-none-any.whl Python 3 none any Details for mf6adj-1.4.0-py3-none-any.whl

Total release size: 503.7 kB

Release files / mf6adj-1.4.0.tar.gz

Download URL mf6adj-1.4.0.tar.gz
Size 408.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6b5d7b9a8a724f8ae57625e510f92586efad99367dd3166fcfc9380e19fd7247
BLAKE2b-256 checksum
How to use checksums
8b5aa9bd969b28e20946311636a93609554de32a122c08988d513a5588f8a582
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","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}

Release files / mf6adj-1.4.0-py3-none-any.whl

Download URL mf6adj-1.4.0-py3-none-any.whl
Size 95.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dae7bb04d5857595dc211b087332723bc0326fc98dbcb2fc1927afae519ad656
BLAKE2b-256 checksum
How to use checksums
e8d93ff582cc94a8901cffb050b760d7978aa6e58da699a26f665ea510f61ab1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","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}

Security for mf6adj 1.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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