Metadata-Version: 2.5
Name: swmod
Version: 0.0.1
Summary: Couple lumped surface water network models with MODFLOW 6 via modflowapi and FloPy.
Project-URL: Homepage, https://github.com/rubencalje/swmod
Project-URL: Repository, https://github.com/rubencalje/swmod
Author: Ruben Calje
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Hydrology
Requires-Python: >=3.12
Requires-Dist: flopy>=3.9.0
Requires-Dist: geopandas>=1.0.0
Requires-Dist: matplotlib>=3.8.0
Requires-Dist: modflowapi>=1.0.0
Requires-Dist: networkx>=3.0
Requires-Dist: numpy>=1.26.0
Requires-Dist: pandas>=2.0.0
Requires-Dist: shapely>=2.0.0
Description-Content-Type: text/markdown

# MODFLOW SWMOD (`swmod`)

**`swmod`** is a Python package for coupling custom, physically coherent surface water network models (nodes, channel reaches, control weirs) with MODFLOW 6 groundwater flow models using the MODFLOW API (`modflowapi`) and FloPy.

---

## Package Purpose & Scope

**`swmod`** is specifically designed for regional groundwater-surface water interaction modeling:

- **Steady-State & Long Time-Step Coupling**:
  Targeted at regional studies operating over daily, monthly, or steady-state stress periods. Because surface water flow reaches equilibrium much faster than groundwater moves through an aquifer, `swmod` solves for steady-state surface water mass balance ($R(h) = 0$) during each coupling iteration, avoiding the computational overhead of full 1D/2D unsteady Saint-Venant solvers.

- **Physically Coherent Hydraulics**:
  - **Nodes**: Lumped surface water storage bodies (lakes, ponds, reservoirs, ditch junctions, constant-head outfalls) exchanging flux with MODFLOW 6 RIV package cells.
  - **Reaches**: Open-channel flow based on Manning's friction ($Q = C \cdot \text{sign}(\Delta h) \sqrt{|\Delta h|}$) or linear conveyance, fully integrated with groundwater exchange along their length.
  - **Weirs**: Sharp/broad-crested control structures using a $C^1$-continuous, strictly monotonic Villemonte-type formulation combining free overflow ($Q_{\text{free}} = C_f b (h_u - z_c)^{1.5}$) with a regularized submergence factor $\phi(r)$ ($0 \le |Q| \le Q_{\text{free}}$) to guarantee smooth convergence during non-linear solver iterations.

- **GeoPandas & Area-Based Conductances**:
  Native integration with `geopandas` vector geometries (Polygons and LineStrings). Automatically computes cell intersection areas $A_{\text{intersect}}$ and RIV conductances $C_k = \frac{A_{\text{intersect}, k}}{c_{\text{bed}}}$ from riverbed resistance $c_{\text{bed}} = \frac{M}{K_{\text{bed}}}$ [days].

---

## Requirements

- Python 3.12 or newer

---

## Quickstart

```bash
# Install dependencies with uv
uv sync

# Download MODFLOW executables into .bin/ (required on every new machine; not stored in the repo)
uv run get-modflow .bin

# Run test suite
uv run pytest -v

# Run 4-node example
uv run python examples/two_lakes_ditch_weir.py

# Build and preview documentation locally
uv run sphinx-build -b html docs docs/_build/html
uv run python -m http.server --directory docs/_build/html 8000
```
