Skip to main content

PyMPDATA usage examples reproducing results from literature and depicting how to use PyMPDATA in Python from Jupyter notebooks

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pympdata_examples-1.7.0.tar.gz (38.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pympdata_examples-1.7.0-py3-none-any.whl (55.3 kB view details)

Uploaded Python 3

File details

Details for the file pympdata_examples-1.7.0.tar.gz.

File metadata

  • Download URL: pympdata_examples-1.7.0.tar.gz
  • Upload date:
  • Size: 38.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pympdata_examples-1.7.0.tar.gz
Algorithm Hash digest
SHA256 653fc2f3e445e7c2c4509d79f658c133344578e87d7d6ef5b6cc70baa9de4b9a
MD5 2b43bd1bc9679c02654794e01772c5c5
BLAKE2b-256 0159ee9d7850faeced67885019e9f38ec4e51adaf2daf3b42e8f2a96a92f57ca

See more details on using hashes here.

File details

Details for the file pympdata_examples-1.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pympdata_examples-1.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c101c05b74768afe87ba47e620f4328d08a09f4d8220eda72d0bd817b183f4f
MD5 9f9759304166c661ab0b648a9e75e28a
BLAKE2b-256 3d4aa0bd7b08a264bb7f84aa2e73e1d15d68900e0795e8c8c7addba2fd0f50e9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page