Skip to main content

Introduction

PyMPDATA examples are bundled with PyMPDATA and located in the examples subfolder. They constitute a separate PyMPDATA_examples Python package which is also available at PyPI. The examples have additional dependencies listed in PyMPDATA_examples package setup.py file. Running the examples requires the PyMPDATA_examples package to be installed.

We recommend you look through the example gallery below to see the examples in action.

Example gallery

Unless stated otherwise the following examples solve the basic advection equation: $$ \partial_t (\psi) + \nabla \cdot (u \psi) = 0 $$

The examples are grouped by the dimensionality of the computational grid.

in 1D

tags link
advection-diffusion equation
$$ \partial_t (\psi) + \nabla \cdot (u \psi) + \mu \Delta (\psi) = 0 $$
advection_diffusion_1d*
Black-Scholes equation, option pricing
$$ \frac{\partial f}{\partial t} + rS \frac{\partial f}{\partial S} + \frac{\sigma^2}{2} S^2 \frac{\partial^2 f}{\partial S^2} - rf = 0$$
Arabas_and_Farhat_2020*
advection equation, homogeneous, several algorithm variants comparison: infinite-gauge, flux-corrected,.. Smolarkiewicz_2006_Figs_3_4_10_11_12
Size-spectral advection, particle population condensational growth, coordinate transformation
$$ \partial_t (G \psi) + \nabla \cdot (Gu \psi) = 0 $$
Olesik_et_al_2022*
advection equation, double-pass donor-cell option DPDC
Burgers' equation
$$ \frac{\partial u}{\partial t} = -\frac{1}{2} \frac{\partial u^2}{\partial x} $$
burgers_equation*
Burgers eq. example

in 2D

tags link
Boussinesq system for buoyancy-driven flow
$$\begin{eqnarray}\partial_t \vec{v}+\nabla\cdot\left(\vec{v}\otimes\vec{v}\right)=-\nabla\pi-\vec{g}\frac{\theta^\prime}{\theta_0}\\ \partial_t\theta+\nabla\cdot\left(\vec{v}\theta\right)=0\\ \nabla\cdot\vec{v}=0\end{eqnarray}$$
Jaruga_et_al_2015
boussinesq-2d
advection-diffusion equation
$$ \partial_t (\psi) + \nabla \cdot (u \psi) + \mu \Delta (\psi) = 0 $$
advection_diffusion_2d*
adv-diff
Spectral-spatial advection, particle population condensational growth in a vertical column of air, time dependent flow Shipway_and_Hill_2012
spectral-spatial
shallow-water equations
$$\begin{eqnarray} \partial_t h + \partial_x (uh) + \partial_y (vh) &=& 0~ \\ \partial_t (uh) + \partial_x ( uuh) + \partial_y (vuh) &=& - h \partial_x h~ \\ \partial_t (vh) + \partial_x ( uvh) + \partial_y (vvh) &=& - h \partial_y h~ \end{eqnarray}$$
Jarecka_et_al_2015*
advection equation, solid body rotation Molenkamp_test_as_in_Jaruga_et_al_2015_Fig_12*
advection equation, solid body rotation wikipedia_example*
Wikipedia example
advection equation, coordinate transformation, spherical coordinates, see also examples in PyMPDATA-MPI $$ \partial_t (G \psi) + \nabla \cdot (Gu \psi) = 0 $$ Williamson_and_Rasch_1989_as_in_Jaruga_et_al_2015_Fig_14
mpi-gif
advection equation, comparison against DG solution using Trixi.jl (Ranocha et al. 2022) trixi_comparison
Black-Scholes equation, option pricing
$$ \frac{\partial f}{\partial t} + rS \frac{\partial f}{\partial S} + \frac{\sigma^2}{2} S^2 \frac{\partial^2 f}{\partial S^2} + \frac{dA}{dt}\frac{\partial f}{\partial A} - rf = 0$$
Magnuszewski_et_al_2025

in 3D

tags link
homogeneous advection equation Smolarkiewicz_1984
homogeneous advection equation, performance comparison against libmpdata++, scalability analysis in respect to threads Bartman_et_al_2022

* - with comparison against analytic solution

Installation

Since the examples package includes Jupyter notebooks (and their execution requires write access), the suggested install and launch steps are:

git clone https://github.com/open-atmos/PyMPDATA-examples.git cd PyMPDATA-examples pip install -e . jupyter-notebook

Alternatively, one can also install the examples package from pypi.org by using pip install PyMPDATA-examples.

Metadata

Release files for pympdata-examples 1.7.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pympdata-examples 1.7.3
File Size Uploaded
pympdata_examples-1.7.3.tar.gz 37.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pympdata-examples 1.7.3
File Interpreter ABI Platform
pympdata_examples-1.7.3-py3-none-any.whl Python 3 none any Details

Total release size: 91.9 kB

Release files / pympdata_examples-1.7.3.tar.gz

Download URL pympdata_examples-1.7.3.tar.gz
Size 37.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e59b53fbc34882f1c92e6c88cbf94e0a8599a006f62880f0e60f8b8a07b05194
BLAKE2b-256 checksum
How to use checksums
7a7b22ab6fc6654670e5c3323f33226638adedb07be4c84ee25152d646ab5cdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / pympdata_examples-1.7.3-py3-none-any.whl

Download URL pympdata_examples-1.7.3-py3-none-any.whl
Size 54.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
178b09509b22ded49732fee3782770c66d48ca2c7b863800ade683ec87fa890b
BLAKE2b-256 checksum
How to use checksums
3beea1e1f0976c29bd64f7322d845892e65be60ae80ee298756ca3bf31216144
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Release history Release notifications | RSS feed

This release

1.7.3 This release

2 release files

1.7.2

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.3

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.6

2 release files

1.3.5

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.1

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.14

2 release files

1.0.13

2 release files

1.0.12

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0

2 release files

0.12

2 release files

0.11

2 release files

0.10

2 release files

0.9

2 release files

0.8

2 release files

0.7

2 release files

0.6

2 release files

0.4

2 release files

0.3

2 release files

0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page