A Python framework to solve stiff reaction-transport systems in seconds using a Monolithic Assembly of Nonlinear Transport Interactions Solver (MANTIS)
Reaction-transport systems involving fast precipitation/dissolution reactions are often extremely stiff. This poses a particular challenge in the geosciences, where the spatial extent of the reaction zone often requires centuries to kiloyears to reach equilibrium, whereas the reaction time scales are often on timescales of seconds. Operator splitting schemes that solve the fast reactions independently of transport are still time-step limited, as larger time steps result in mass imbalances. Here I present a Python framework that uses a fully coupled monolithic equation system that uses the Newton-Raphson scheme with a Block Thomas Algorithm that can be solved at almost arbitrary large time steps and often within a single iteration. This allows Mantis to solve stiff non-linear reaction networks within seconds, and in cases where a single iteration is sufficient, milliseconds. Mantis uses a finite volume framework paired with an intuitive template system to define species properties, kinetic constants, and reaction networks, including native support for kinetic and equilibrium isotope effects.
Many geochemical reactive-transport modeling packages rely on operator splitting (such as Sequential Non-Iterative Approach [SNIA] or Sequential Iterative Approach [SIA]) or decoupled Picard (Gauss-Seidel) iterations:
-
Monolithic Coupling vs. Operator Splitting:
-
Operator splitting alternates between solving pure transport and pure batch chemistry over a time step. While simple, it introduces splitting errors and often requires tiny time steps (
$\Delta t$ on the order of seconds or hours) to avoid artificial oscillations or numerical divergence when reactions are fast and stiff. - Picard iterations solve each chemical species sequentially, lagging cross-species couplings from the previous iteration. At sharp reaction fronts (e.g., where sulfide meets oxygen or ferric iron), this decoupling frequently causes severe numerical lag oscillations.
- MANTIS solves the entire system monolithically: Transport and reactions for all species are assembled into a single unified block-tridiagonal linear system at each Newton step. This achieves true simultaneous coupling and quadratic Newton convergence.
-
Operator splitting alternates between solving pure transport and pure batch chemistry over a time step. While simple, it introduces splitting errors and often requires tiny time steps (
-
Unconditional Numerical Stability:
- Thanks to its fully implicit monolithic formulation, MANTIS does not suffer from Courant-Friedrichs-Lewy (CFL) or diffusion time step stability restrictions, enabling long-term simulations (centuries to millennia) with large time steps.
While MANTIS provides robust and unconditionally stable solutions for stiff reactive transport, the current release has the following limitations:
-
Time-Invariant Spatial Mesh:
- The spatial grid
$z$ is static throughout the simulation. Dynamic grid adaptation, moving boundaries, or expanding domains (e.g., physical sediment column growth over time) are not currently supported.
- The spatial grid
-
Time-Invariant Porosity:
- The porosity profile
$\phi(z)$ is stationary in time (steady-state compaction). Transient sediment compaction or compaction-driven dynamic fluid expulsion over time is not currently modeled. A furture version may address this though.
- The porosity profile
-
Time-Invariant Temperature:
- The temperature profile of
$T(z)$ is steady-state. Dynamic thermal evolution and time-dependent diffusion coefficients or rate constants driven by non-isothermal thermal transients are not currently supported.
- The temperature profile of
pip install mantis-rtm
mantis_create_examples.py
Note that the optional video generation backend requires a working ffmpeg installation, and has not been tested on MacOS or Windows.
Please refer to https://mantis-rtm.readthedocs.io/en/latest for detailed usage instructions.
Please see Contribution Guide.
This project is licensed under the AGPL-3.0 License. See the LICENSE file for details.