Draft:MPDATA
In numerical analysis of partial differential equations, MPDATA is a family of iterative finite-difference/finite-volume methods for numerically integrating of hyperbolic differential equations modelling conservation laws of the form:
where is an advected scalar field (or advectee); is the flow velocity vector field (or advector), may either play the role of the fluid density, the Jacobian of coordinate transformation from Cartesian to curvilinear framework , or their product; combines all source terms[1].
MPDATA stands for Multidimensional Positive Definite Advection Transport Algorithm. The algorithm was formulated by Piotr K. Smolarkiewicz[2][3] (and is also referred to as Smolarkiewicz's method[4]) at the US National Center for Atmospheric Research - NCAR (at the time, Smolarkiewicz was a fellow of the NCAR Advanced Study Program and a recent graduate from Krzysztof Haman's group at the University of Warsaw; the seminal 1983 and 1984 MPDATA publications mention both institutions).
The crux of the method lies in iterative application of the upwind scheme. The first iteration employs the advective velocity , 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[5] 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 , 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. Depending on the MPDATA variant, convergence of up to third-order in time and space can be achieved[6].
While the original formulation of MPDATA employed structured grids, the algorithm has been subsequently also formulated for unstructured grids[7]. Despite being formulated for and named in reference to advection problems, as any other advection numerical scheme, MPDATA also applies to solutions of advection-diffusion as well as diffusion-only problems if Fickian diffusive terms are expressed as advective fluxes[8] (approach referred to as the pseudo-velocity technique[9][10]).
Description of the basic scheme in 1D
MPDATA is inherently multi-dimensional, and primarily used in computational fluid dynamics where the advective volocities and problem geometries are variable in time. Still, the key idea underlying the MPDATA approach can be conveyed with a basic example of solenoidal stationary flow in one dimension[11] (i.e., constant in time and space), without coordinate transformation (), for the case of homogeneous advection () of a nonnegative scalar field (), with the following flux form of the advection equation:
Upwind discretisation of the problem on a regular staggered grid with a time step and a grid step , with , , and the half-integer spatial indices corresponding to grid-cell walls:
··· | · | · | · | ···
can be formulated with (for arbitrary ):
with the flux function defined using positive and negative parts of as:
Introducing the non-dimensional Courant number , the resultant explicit-in-time scheme (referred to as "upwind", "upstream" or "donor-cell"), for a constant reads: Template:NumBlk which is conservative, sing-preserving and stable for . However, the scheme is only first-order accurate in space () and time (), and incurs numerical diffusion which can be quantified with the modified-equation analysis by substituting the discretised values other than in (Template:EquationNote) with their Taylor expansions (using the Big O notation):
which yields (up to second-order terms):
in which the highlighted second-order time derivative can be replaced with second-order spatial derivative using the Cauchy-Kovalevskaya procedure (i.e., by substituting eq. (Template:EquationNote) into a time-derivative of eq. (Template:EquationNote) giving ) yielding the following, so-called, modified equation:
which confirms that, as and , the upwind scheme approximates eq. (Template:EquationNote), but the truncation error has a leading-order Fickian source term with a coefficient of numerical diffusion given by [12].
The concept of MPDATA lies in reversing the effect of numerical diffusion by using the pseudo-velocity technique[9][10] that allows to express diffusion terms in transport problems using an equation of the same form as (Template:EquationNote). To this end, Smolarkiewicz introduced the anti-diffusive pseudo velocity (note the opposite sign stemming from, de facto, integrating backwards in time to reverse the effect of diffusion):
and proposed discretisation allowing to perform a corrective step using upwind integration with an anti-diffusive Courant number field:
Template:NumBlk where numbers algorithm iterations. The first pass of the scheme is an ordinary upwind integration using and yielding . In the second pass, the values of the anti-diffusive Courant number are computed based on and , and used to perform an upwind anti-diffusive pass yielding . Note that even for constant-in- physical , the anti-diffusive varies in (and thus corresponds to a divergent flow). Subsequent iterations are correcting the integration of the anti-diffusive corrections from previous passes. If iterations are used, is used as the result of integration of the advective term over one .
TODO: A bounded
TODO: (note: multiple dimensions)
TODO: stencil (numerical analysis) (and how it changes with iterations)
TODO: stability condition
TODO: positive definiteness, etc
TODO: conservativeness
TODO: anti-diffusive velocity is not solenoidal!
TODO: Last but not least ... bounadry conditions ...
Minimal implementation and convergence analysis in Python
...
Algorithm variants and techniques used in concert with MPDATA
The basic scheme... (note that many of the non-basic variants of the algorithm have larger stencils). + examples generated with PyMPDATA ?
- double-pass donor cell ...[13]
- infinite-gauge variant ...[14]
- non-oscillatory variant ... flux limiter... [15]
- divergent-flow correction ...
- higher-order terms ...
- application to advection-diffusion problems
- application to inhomogeneous problems
- application to problems featuring pressure-gradient source terms (e.g., Boussinesq approximation (buoyancy) of the Navier-Stokes equations)
- adaptive mesh refinement controlled by antidiffusive velocities[17]
Algorithm steps (shallow-water system example)
The algorithm steps listed below constitute a solver to a minimal fluid dynamics problem - an inviscid shallow water equations system (in two spatial dimensions, assuming flat bathymetry):
Template:NumBlk where is the advector (one vector field discretised at cell walls); fluid height , momentum components and are the advectees (three scalar fields discretised at cell centers).
Since the scalar fields representing momentum components and are not of constant sign, it is recommended to use the infinite-gauge variant of MPDATA. This variant implies non-monotonic solutions, hence in practice it is only practical together with the non-oscillatory option used as well. Steps pertaining to both options are featured below.
An MPDATA-based solution consists of the following steps:
- ...
- ...
Applications
Equation (Template:EquationNote), which is numerically approximated with MPDATA, is used in modelling a wide range of transport phenomena across different scales and flow regimes. MPDATA has documented applications in the following domains:
- numerical weather prediction (NWP) systems:
- compressible dynamical core for the COSMO system[18]
- nonhydrostatic finite-volume dynamical core for the ECMWF Integrated Forecast System (IFS)[19]
- ocean modelling:
- passive tracer advection in terrain-following coordinates in the Regional Ocean Modeling System (ROMS)[20]
- large eddy simulations:
- moist atmospheric flows (including representation of cloud and precipitation processes)[21]
- multi-phase particle-laden flows (e.g., contrail formation[22], aerosol-cloud-precipitation interactions[23])
- turbulent magnetohydrodynamics[24] (including Hall magnetohydrodynamics[25])
- simulations of wind-driven sand dune dynamics[26]
- simulations of flows past complex structures (e.g. the Pentagon building[16] and the Palace of Culture and Science in Warsaw[27])
- direct numerical simulations:
- multi-phase flows (fog formation)[28]
- solvers for shallow water equations resolving:
- mathematical finance:
- solutions to the Black-Scholes-type equations (a stochastic differential equation transformed into a partial differential equation using Itô's lemma) cast as an advective transport problem for pricing of European and American options[33]
Open-source implementations
- reusable MPDATA libraries and packages:
- libmpdata++: structured-grid MPDATA implemented in C++ using Blitz++ for array handling and array-valued expressions, and OpenMP for multi-threading. API and usage examples documented in a journal article[34]. Featuring distributed-memory parallelism using Message Passing Interface (MPI)[35]. Supports integration in 1-, 2- and 3-dimensional domains. Implements arbitrary number of corrective iterations, the infinite-gauge, non-oscillatory and fully-third-order variants. Features implementations of a shallow-water equation system solver, and a conjugate-residual Poisson equation solver for handling pressure terms in momentum conservation equations. The library has been developed as a dynamical core for the UWLCM[36] large eddy simulation system. Released under the GNU GPL v3 license.
- PyMPDATA structured-grid MPDATA implemented in Python using NumPy and Numba for array handling, just-in-time compilation and multi-threading[37], supporting distributed-memory parallelism using MPI via Numba-MPI[38]. Supports integration in 1-, 2- and 3-dimensional domains, arbitrary number of corrective iterations, implements infinite-gauge, non-oscillatory and double-pass-donor-cell algorithm variants. Pure-Python wheels available on PyPI, release tarballs archived at Zenodo[39]. Released under the GNU GPL v3 license together with a set of examples in a form of Jupyter notebooks. Web-based code-coupled documentation in English[40].
- MPDATA implementations integrated in other software:
- AtmosFOAM (a derivative of OpenFOAM; OpenFOAM is distributed under the GPL v3 license) features implementations of MPDATA in both C++ and Python/Numba[41].
- mpdat_2d: a FORTRAN 77 subroutine implementing 2-dimensional structured-grid MPDATA including the non-oscillatory option (likely a derivative of the original MPDATA implementation created at NCAR) has been publicly released[42] as a part of babyEULAG code[43]. No documentation or README, unspecified license and authorship.
- smolar: structured-grid MPDATA implemented as a C library supporting multi-threading and multi-process parallelism, as well as offloading of anti-diffusive velocity computation to GPU using CUDA. Code publicly available on GitHub[44] without release versioning, unspecified license, documentation in Russian language credited to Russian Academy of Sciences.
- advectionHPCtester: structured-grid 3-dimensional implementation of the basic scheme in FORTRAN. Code archived on Zenodo[45]. Released under the GNU LGPL.
References
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite book
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ 9.0 9.1 Template:Citation
- ↑ 10.0 10.1 Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite conference
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ 16.0 16.1 Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Cite journal
- ↑ Template:Citation
- ↑ Template:Citation
- ↑ Template:Citation
- ↑ Template:Citation
- ↑ Template:Cite journal
- ↑ Template:Citation
- ↑ Template:Citation