A machine learning boosted parallel-in-time differential equation solver framework
Project description
PararealML
PararealML is a differential equation solver library featuring a Parareal framework based on a unified interface for initial value problems and various solvers including a number of machine learning accelerated ones. The library's main purpose is to provide a toolset to investigate the properties of the Parareal algorithm, especially when using machine learning accelerated coarse operators, across various problems. The library's implementation of the Parareal algorithm uses MPI via mpi4py.
Main components
The library has a modular design to allow for easy extensibility. The main components that enable this are described below.
Differential equation
Differential equations extend the DifferentialEquation
base class. In PararealML, all differential equations are time-dependent. Moreover, the unknown variables of differential equations are by definition vector-valued to support systems of differential equations. Both ordinary and partial differential equations are supported.
The library provides out-of-the-box implementations for a number of differential equations including:
PopulationGrowthEquation
LotkaVolterraEquation
LorenzEquation
SIREquation
VanDerPolEquation
NBodyGravitationalEquation
DiffusionEquation
ConvectionDiffusionEquation
WaveEquation
CahnHilliardEquation
BurgerEquation
ShallowWaterEquation
NavierStokesEquation
To solve other differential equations, the DifferentialEquation
class can be easily extended. The only method that needs to be implemented to do so is symbolic_equation_system
which defines the system of differential equations using symbolic expressions.
Mesh
Meshes in PararealML are represented by the Mesh
class which defines a hyper-grid with a pair of boundaries and a uniform step size along each dimension. Meshes may be defined in a Cartesian or curvilinear (polar, cylindrical, or spherical) coordinate system.
Boundary conditions
All boundary conditions extend the BoundaryCondition
base class. In PararealML, boundary conditions are functions of time and space. It is possible to specify static boundary conditions that only depend on the spatial coordinates to enable the pre-computation of boundary values and thus potentially improve the performance of some of the solvers.
The most important boundary conditions provided are:
DirichletBoundaryCondition
NeumannBoundaryCondition
CauchyBoundaryCondition
Constrained problem
Constrained problems encapsulate either simple ordinary differential equations or partial differential equations coupled with a mesh and boundary conditions. This offers a level of abstraction over the two kinds of differential equations. Constrained problems are represented by the ConstrainedProblem
class whose constructor takes a differential equation and optionally a mesh and a set of boundary conditions.
Initial conditions
In PararealML, all initial conditions extend the InitialCondition
base class.
The library provides a number initial condition implementations including:
DiscreteInitialCondition
ContinuousInitialCondition
GaussianInitialCondition
MarginalBetaProductInitialCondition
Initial value problem
Initial value problems are constrained problems associated with a time domain and initial conditions. They are represented by the InitialValueProblem
class whose constructor takes a constrained problem, a tuple of two bounds defining the time interval, and an initial condition instance.
Operator
All operators extend the Operator
base class. Operators are standalone differential equation solvers that can be used as operators in the Parareal framework as well. They are generally constructed by providing a time step size, possibly along other arguments. They then can solve initial value problems and return the trajectories of the solutions with a temporal granularity defined by their time step sizes. The Parareal framework is an operator itself as well.
The list of provided operators is:
ODEOperator
: an ODE solver based on the solve_ivp function of SciPy'sintegrate
moduleFDMOperator
: a fast finite difference operator that can solve both ODEs and PDEsPIDONOperator
: a Physics-Informed DeepONet operator that can be trained using variable initial conditions and that can solve both ODEs and PDEsAutoRegressionOperator
: an auto-regression operator trained on data generated by an oracle operator that can solve any differential equation that it is trained onPararealOperator
: a Parareal framework that can solve any differential equation its operators can
Solution
The solve
method of every operator returns an instance of the Solution
class that supports a number of functionalities including interpolation, difference computation, and plot generation. The interpolation capability of this class allows the solution to be queried at any spatial point in addition to the cell centers or vertices of the mesh. Moreover, it also allows for the mixing of cell-center-oriented and vertex-oriented solvers as the fine and coarse operators of the Parareal framework.
Plot
Visualizing the solutions of differential equations is supported by PararealML through the Plot
base class which enables displaying and saving plots. There are a number of implementations of this class to visualize the solutions of various types of differential equations in any of the supported coordinate systems. The generate_plots
method of the Solution
class can conveniently generate all of the relevant plots based on the type of the problem solved. The library provides the following types of plots:
TimePlot
: a simple y-against-t plot to visualise the solutions of systems of ODEsPhaseSpacePlot
: a 2D or 3D phase space plot for systems of 2 or 3 ODEs respectivelyNBodyPlot
: a 2D or 3D animated scatter plot for 2D or 3D n-body simulationsSpaceLinePlot
: an animated line plot for 1D PDEsContourPlot
: an animated contour plot for 2D PDEsSurfacePlot
: an animated 3D surface plot for 2D PDEsScatterPlot
: an animated 3D scatter plot for 3D PDEsStreamPlot
: an animated 2D stream plot for the solution vector field of 2D PDEsQuiverPlot
: an animated 2D or 3D quiver plot for the solution vector field of 2D or 3D PDEs
A few examples of plots generated by PararealML can be seen below.
Examples
The examples folder contains a range of different examples of using the library for solving various differential equations both in serial and parallel. The scripts also include examples of using machine learning operators.
Installation
To install PararealML, an implementation of the MPI standard must be pre-installed and the mpicc
program must be on the search path as per the installation guide of mpi4py. With that set up, the library can be installed by running pip install pararealml
.
Development
- To install the dependencies of the library, run
make install
(this requires an existing MPI installation andmpicc
). - To perform linting, execute
make lint
. - The library uses type-hints throughout. For type checking, use the command
make type-check
. - The format any changed modules, run
make format
. - To run the unit tests, execute
make test
. - To run any of the example scripts using an arbitrary number of MPI processes, run
make run p={number of processes} example={name of example file without extension}
(e.g.make run p=4 example=lorenz_parareal
).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file pararealml-0.3.0.tar.gz
.
File metadata
- Download URL: pararealml-0.3.0.tar.gz
- Upload date:
- Size: 101.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.6 tqdm/4.63.0 importlib-metadata/4.6.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9340ddaf413c8b73e335fa37d6ef3e9da22a8e2dc9eb42ddeba74484d07a054 |
|
MD5 | 98c8e2784260188a14ce6a77e6fbd4d4 |
|
BLAKE2b-256 | 5ea576903b4893722181c5915de40607c4802f0374fbe4afa09ad07f98e46def |
File details
Details for the file pararealml-0.3.0-py3.8.egg
.
File metadata
- Download URL: pararealml-0.3.0-py3.8.egg
- Upload date:
- Size: 432.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.6 tqdm/4.63.0 importlib-metadata/4.6.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebf6bcdb6de3f33fd264e299d7d3fb4b74bb021a741780f0bf052df80c947c98 |
|
MD5 | 38ac589514f656a3a5de15155acb550d |
|
BLAKE2b-256 | 2d8f81dd44f2502949acad03666bd865076caec1b5e963e295f3596123f6cf1f |
File details
Details for the file pararealml-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: pararealml-0.3.0-py3-none-any.whl
- Upload date:
- Size: 169.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.6 tqdm/4.63.0 importlib-metadata/4.6.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2859309ab7d76bb94f79b070ed18f9c6d684dd67e49ce7db5272feebbd2080f6 |
|
MD5 | c756a52f4a7128e788cdb86173b62ec5 |
|
BLAKE2b-256 | 7521bf5c3da8692d60fe1dd6c86a3162a1242fbd7edb0342b95404375ecd1262 |