Metadata-Version: 2.4
Name: mf6adj
Version: 1.1.0
Summary: mf6adj is a Python package for adjoint-state sensitivity analysis with MODFLOW 6
Project-URL: Documentation, https://mf6adj.readthedocs.io
Project-URL: Bug Tracker, https://github.com/INTERA-Inc/mf6adj/issues
Project-URL: Source Code, https://github.com/INTERA-Inc/mf6adj
Author: INTERA Incorporated
Maintainer: INTERA Incorporated
License: CC0-1.0
Keywords: MODFLOW,adjoint,groundwater,hydrogeology
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Science/Research
Classifier: License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Hydrology
Requires-Python: >=3.10
Requires-Dist: flopy>=3.10.0
Requires-Dist: geopandas>=1.0.0
Requires-Dist: h5py>=3.0.0
Requires-Dist: matplotlib>=3.5.0
Requires-Dist: modflowapi>=0.2.0
Requires-Dist: numpy>=2.0
Requires-Dist: pandas>=2.0.0
Requires-Dist: pyemu>=1.4.0
Requires-Dist: scipy>=1.7.0
Provides-Extra: dev
Requires-Dist: boltons; extra == 'dev'
Requires-Dist: codespell[toml]>=2.2.2; extra == 'dev'
Requires-Dist: filelock; extra == 'dev'
Requires-Dist: flaky; extra == 'dev'
Requires-Dist: ipykernel; extra == 'dev'
Requires-Dist: jupyter; extra == 'dev'
Requires-Dist: jupyter-client>=8.4.0; extra == 'dev'
Requires-Dist: modflow-devtools>=1.9.1; extra == 'dev'
Requires-Dist: myst-parser; extra == 'dev'
Requires-Dist: nbconvert; extra == 'dev'
Requires-Dist: nbmake; extra == 'dev'
Requires-Dist: nbsphinx; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: pytest-dotenv; extra == 'dev'
Requires-Dist: pytest-order; extra == 'dev'
Requires-Dist: pytest-xdist; extra == 'dev'
Requires-Dist: pytest>=9.0.2; extra == 'dev'
Requires-Dist: pyyaml; extra == 'dev'
Requires-Dist: rtds-action; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Requires-Dist: shapely; extra == 'dev'
Requires-Dist: sphinx-rtd-theme>=1; extra == 'dev'
Requires-Dist: sphinx>=7.1.2; extra == 'dev'
Requires-Dist: tomli-w; extra == 'dev'
Provides-Extra: doc
Requires-Dist: boltons; extra == 'doc'
Requires-Dist: codespell[toml]>=2.2.2; extra == 'doc'
Requires-Dist: filelock; extra == 'doc'
Requires-Dist: flaky; extra == 'doc'
Requires-Dist: ipykernel; extra == 'doc'
Requires-Dist: jupyter; extra == 'doc'
Requires-Dist: jupyter-client>=8.4.0; extra == 'doc'
Requires-Dist: modflow-devtools>=1.9.1; extra == 'doc'
Requires-Dist: myst-parser; extra == 'doc'
Requires-Dist: nbconvert; extra == 'doc'
Requires-Dist: nbmake; extra == 'doc'
Requires-Dist: nbsphinx; extra == 'doc'
Requires-Dist: pytest-cov; extra == 'doc'
Requires-Dist: pytest-dotenv; extra == 'doc'
Requires-Dist: pytest-order; extra == 'doc'
Requires-Dist: pytest-xdist; extra == 'doc'
Requires-Dist: pytest>=9.0.2; extra == 'doc'
Requires-Dist: pyyaml; extra == 'doc'
Requires-Dist: rtds-action; extra == 'doc'
Requires-Dist: ruff; extra == 'doc'
Requires-Dist: shapely; extra == 'doc'
Requires-Dist: sphinx-rtd-theme>=1; extra == 'doc'
Requires-Dist: sphinx>=7.1.2; extra == 'doc'
Requires-Dist: tomli-w; extra == 'doc'
Provides-Extra: lint
Requires-Dist: codespell[toml]>=2.2.2; extra == 'lint'
Requires-Dist: ruff; extra == 'lint'
Provides-Extra: test
Requires-Dist: boltons; extra == 'test'
Requires-Dist: codespell[toml]>=2.2.2; extra == 'test'
Requires-Dist: filelock; extra == 'test'
Requires-Dist: flaky; extra == 'test'
Requires-Dist: ipykernel; extra == 'test'
Requires-Dist: jupyter; extra == 'test'
Requires-Dist: jupyter-client>=8.4.0; extra == 'test'
Requires-Dist: modflow-devtools>=1.9.1; extra == 'test'
Requires-Dist: nbmake; extra == 'test'
Requires-Dist: pytest-cov; extra == 'test'
Requires-Dist: pytest-dotenv; extra == 'test'
Requires-Dist: pytest-order; extra == 'test'
Requires-Dist: pytest-xdist; extra == 'test'
Requires-Dist: pytest>=9.0.2; extra == 'test'
Requires-Dist: ruff; extra == 'test'
Requires-Dist: shapely; extra == 'test'
Requires-Dist: tomli-w; extra == 'test'
Description-Content-Type: text/markdown

# mf6adj

![mf6adj](https://raw.githubusercontent.com/INTERA-Inc/mf6adj/master/.images/mf6adj.png)

**mf6adj** is a Python package for adjoint-state sensitivity analysis with
MODFLOW 6.  It uses the [MODFLOW 6 API](https://github.com/MODFLOW-USGS/modflowapi)
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**

```bash
pip install mf6adj
```

**conda-forge**

```bash
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`](https://github.com/modflowpy/flopy) helper:

```bash
get-modflow --subset mf6,libmf6 :python
```

## Quick start

```python
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](https://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](https://creativecommons.org/publicdomain/zero/1.0/)
