PyMPDATA

PyMPDATA

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:

$$ \partial_t (G\psi) + \nabla \cdot (G\vec{u}\psi) + \mu \Delta (G\psi) = 0 $$
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 advection
Buoyancy-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)

Papers on or using PyMPDATA

🎓 Student project opportunities

Contributors from our team

Piotr Bartman-Szwarc
Completed MSc project in 2020 (major: Computer Science, Jagiellonian Univ.)
Michael Olesik
Completed MSc project in 2020 (major: Physics, Jagiellonian Univ.)
Michał Wroński
Ongoing BEng project (major: Micro- and Nanotechnologies in Biophysics, AGH)
Michał Kowalczyk
Completed BEng project in 2025 (major: Technical Physics, AGH)
Paweł Magnuszewski
Completed MSc project in 2025 (major: Computer Science & Intelligent Systems, AGH)
Kacper Derlatka
Completed MSc project in 2023 (major: Computer Science, Jagiellonian Univ.)
Sylwester Arabas
Team lead (PhD, Physics, U. Warsaw, 2013)