pure-Python, open-source implementation of the MPDATA algorithm
PyMPDATA is a high-performance Numba-accelerated Python package implementing the MPDATA algorithm by Smolarkiewicz et al.
aimed at solving generalised advection-diffusion PDEs in geophysical fluid dynamics and beyond.
It numerically solves equations of form:
where \(\psi\) is the advectee, \(u\) is the advector and the \(G\) factor describes the coordinate transformation.
The last term is related to Fickian diffusion and is optional.
The crux of the method lies in iterative application of the upwind scheme.
The first iteration employs the advective velocity \(\vec{u}\), while each subsequent iteration employs a so-called antidiffusive velocity which
corrects solution from prior iteration reducing the numerical diffusion.
The antidiffusive velocities are formulated through modified equation analysis of the upwind scheme and feature cross-dimensional dependencies
(i.e., applying MPDATA in multiple dimensions is not equivalent to application of one-dimensional MPDATA in all dimensions),
the scheme is thus not dimensionally split, hence “M” in the algorithm name.
Since each iteration of the scheme constitutes a forward-in-time upwind pass, the scheme inherits characteristics of the upwind scheme:
CFL stability criterion, conservativeness, embarrassingly parallel domain decomposition, and sign-preservation.
For non-negative fields \(\psi\), sign-preservation translates to positive definiteness, hence the “PD” in the algorithm name.
Application of the corrective iterations improves scheme convergence rate compared with first-order upwind.
Basic 2D advectionBuoyancy-driven flow in Boussinesq approximation
The package depends on NumPy, Numba and Numba-MPI.
This allows for taking advantage of Just-In-Time (JIT) compilation provided by Numba, and in case of computational clusters, distributed memory parallelism
with PyMPDATA-MPI.
PyMPDATA has an example gallery available as a separate Python package, showing how it can be used to solve equations such as
the Black-Scholes equation,
Burgers equation and
shallow-water equations.
The project can be found on PyPI, with its source code hosted on GitHub,
along with the documentation and example gallery.
Selected papers on the MPDATA algorithm (features implemented in PyMPDATA)