API reference#
A run of pySDC is set up with a description, a dictionary that names a problem class, a sweeper class and their parameters, and possibly transfer classes and convergence controllers. A controller then runs it, with hooks, given in the controller parameters, recording what happens. The tables below list the classes pySDC ships for each of these roles, with the first sentence of their docstrings; each name links to its full documentation. The complete list of modules is at the end of this page.
Problems#
The equations: right-hand sides, implicit solves and, where known, exact solutions.
Class |
Summary |
|---|---|
Periodic 1D acoustic-advection system with finite differences, acoustic waves implicit and advection explicit. |
|
Periodic 1D advection-diffusion equation with FFTs, IMEX with diffusion implicit and advection explicit. |
|
Periodic 1D advection-diffusion equation with FFTs, fully implicit in advection and diffusion. |
|
Example implementing the unforced ND advection equation with periodic or Dirichlet boundary conditions in \([0,1]^N\) |
|
1D Allen-Cahn front with driving force, Dirichlet BCs and finite differences, fully implicit with Newton. |
|
1D Allen-Cahn front with driving force, Dirichlet BCs and finite differences, IMEX with Laplacian implicit. |
|
1D Allen-Cahn front with driving force and Dirichlet BCs, fully implicit with Newton, using Finel’s trick. |
|
1D Allen-Cahn equation with driving force, periodic BCs and finite differences, fully implicit with Newton. |
|
1D Allen-Cahn equation with driving force, periodic BCs and finite differences, IMEX with Laplacian implicit. |
|
1D periodic Allen-Cahn equation with driving force, multi-implicit: linear solve for Laplacian, Newton for rest. |
|
2D periodic Allen-Cahn equation with finite differences, fully implicit with Newton. |
|
2D periodic Allen-Cahn equation with finite differences, IMEX with Laplacian implicit, reaction explicit. |
|
2D periodic Allen-Cahn equation with finite differences, IMEX with Laplacian and cubic term implicit. |
|
2D periodic Allen-Cahn equation with finite differences, multi-implicit: Laplacian (CG), reaction (Newton). |
|
2D periodic Allen-Cahn with finite differences, multi-implicit: Laplacian plus cubic term, linear term. |
|
2D periodic Allen-Cahn equation with FFTs, IMEX with the Laplacian implicit and the reaction explicit. |
|
2D periodic Allen-Cahn equation with FFTs, IMEX with a stabilizing linear term shifted into the implicit part. |
|
Periodic Allen-Cahn equation with driving force and mpi4py-fft FFTs, IMEX with the Laplacian implicit. |
|
Periodic Allen-Cahn equation with mpi4py-fft FFTs, IMEX, with a time-dependent, mass-conserving driving force. |
|
Periodic Allen-Cahn equation coupled to a temperature equation, mpi4py-fft FFTs, IMEX with both Laplacians implicit. |
|
This class implements the Auzinger equation as initial value problem. |
|
Example implementing the battery drain model with \(N\) capacitors, where \(N\) is an arbitrary integer greater than zero. |
|
Example implementing the battery drain model with \(N=1\) capacitor, inherits from |
|
Battery drain model with one capacitor, treated fully implicitly with Newton instead of the IMEX splitting. |
|
Linearized 2D Boussinesq equations with finite differences, IMEX with waves implicit (GMRES), advection explicit. |
|
2D periodic Brusselator reaction-diffusion system with mpi4py-fft, IMEX with diffusion implicit, reactions explicit. |
|
Example implementing the model of a buck converter, which is also called a step-down converter. |
|
1D viscous Burgers equation with Dirichlet BCs and a Chebychev method, IMEX with diffusion implicit, advection explicit. |
|
2D viscous Burgers equation, periodic in x (FFT) and Dirichlet in z (Chebychev), diffusion implicit, advection explicit. |
|
This class implements a very simple test case of a ordinary differential equation consisting of one discrete event. |
|
Variant of |
|
Scalar test equation with a fast and a slow wave, IMEX with the fast part implicit and the slow part explicit. |
|
The Fermi-Pasta-Ulam-Tsingou (FPUT) problem was one of the first computer experiments. |
|
Gravitational N-body problem of the sun, the eight planets (Earth and Moon as one body) and Pluto. |
|
1D generalized Fisher equation with finite differences and Dirichlet BCs, fully implicit with Newton. |
|
1D generalized Fisher equation with PETSc finite differences, multi-implicit: diffusion (CG), reaction (SNES). |
|
1D generalized Fisher equation with PETSc finite differences, fully implicit with PETSc’s SNES. |
|
1D generalized Fisher equation with PETSc finite differences, IMEX with diffusion implicit, reaction explicit. |
|
Problem class wrapping a Gusto (Firedrake) equation, with all terms of its residual treated implicitly. |
|
Problem class wrapping a Gusto (Firedrake) equation, IMEX with the terms labeled implicit and explicit split. |
|
1D Gray-Scott reaction-diffusion system with FEniCS finite elements, fully implicit with FEniCS’ Newton solver. |
|
Gray-Scott in mass-matrix form, \(M \vec{u}' = F(\vec{u})\), with no mass inversion. |
|
2D periodic Gray-Scott system with PETSc finite differences, multi-implicit: diffusion (CG), reaction (SNES). |
|
2D periodic Gray-Scott system with PETSc finite differences, fully implicit with PETSc’s SNES. |
|
2D periodic Gray-Scott system with PETSc finite differences, IMEX with diffusion implicit, reaction explicit. |
|
Periodic Gray-Scott system with mpi4py-fft FFTs, IMEX with diffusion implicit and the reaction explicit. |
|
Periodic Gray-Scott system with mpi4py-fft, IMEX with diffusion and linear reaction terms implicit, rest explicit. |
|
Periodic Gray-Scott system with mpi4py-fft, multi-implicit: diffusion by FFT, reaction by Newton. |
|
Periodic Gray-Scott system with mpi4py-fft, multi-implicit: diffusion and linear terms by FFT, the rest by Newton. |
|
Example implementing the harmonic oscillator with mass \(1\) |
|
Forced 1D heat equation with FEniCS and Dirichlet BCs, IMEX, with the mass matrix inverted in the right-hand side. |
|
Forced 1D heat equation with FEniCS and Dirichlet BCs, IMEX, with the mass matrix applied instead of inverted. |
|
Forced 1D heat equation with FEniCS, IMEX with the mass matrix applied, and time-dependent Dirichlet BCs. |
|
Example implementing the forced two-dimensional heat equation with Dirichlet boundary conditions \((x, y) \in [0,1]^2\) |
|
1D Heat equation with Dirichlet Boundary conditions discretized on (-1, 1) using a Chebychev spectral method. |
|
1D Heat equation with Dirichlet Boundary conditions discretized on (-1, 1) using an ultraspherical spectral method. |
|
2D heat equation, periodic (FFT) or Dirichlet (Chebychev) in each direction, in first-order formulation. |
|
2D heat equation, periodic (FFT) or Dirichlet (ultraspherical) in each direction, in second-order formulation. |
|
This class implements the unforced \(N\)-dimensional heat equation with periodic boundary conditions |
|
This class implements the forced \(N\)-dimensional heat equation with periodic boundary conditions |
|
Forced 1D heat equation with Dirichlet BCs and Firedrake finite elements, IMEX with diffusion implicit. |
|
This class implements the second-order Hénon-Heiles system |
|
Problem implementing a specific form of the Logistic Differential Equation |
|
Lorenz system of three chaotic ODEs, treated fully implicitly with a Newton solver. |
|
Periodic nonlinear Schrödinger equation with mpi4py-fft, IMEX with the Laplacian implicit, nonlinearity explicit. |
|
Periodic nonlinear Schrödinger equation with mpi4py-fft, fully implicit with SciPy’s Newton-Krylov solver. |
|
Gravitational N-body problem of the outer solar system: the sun, Jupiter, Saturn, Uranus, Neptune and Pluto. |
|
Charged particles in a 3D Penning trap with Coulomb interaction, a second-order problem for the Boris integrator. |
|
Pi-line model of a transmission line as three linear ODEs, IMEX with the constant source term explicit. |
|
1D heat equation with a nonlinear heat source, modelling a magnet quench, fully implicit with Newton. |
|
1D heat equation with a nonlinear heat source, modelling a magnet quench, IMEX with diffusion implicit. |
|
2D Rayleigh-Benard convection, FFT in x and ultraspherical in z, IMEX with the nonlinear advection explicit. |
|
3D Rayleigh-Benard convection, FFT in x and y and ultraspherical in z, IMEX with the nonlinear advection explicit. |
|
Dahlquist test equation for many values of \(\lambda\) at once, treated fully implicitly. |
|
Test equation with the right-hand side split into an implicit and an explicit part |
|
Stiff Van der Pol oscillator as a system of two first-order ODEs, fully implicit with Newton. |
|
2D periodic vorticity-velocity problem with FEniCS, IMEX (diffusion implicit), with the mass matrix inverted. |
|
2D periodic vorticity-velocity problem with FEniCS, IMEX (diffusion implicit), with the mass matrix applied. |
|
Generic base class for IMEX problems using a spectral method to solve the Laplacian implicitly and a possible rest explicitly. |
|
Base class for finite difference spatial discretisation in \(N\) dimensions |
|
Generic class to solve problems of the form M u_t + L u = y, with mass matrix M, linear operator L and some right hand side y using spectral methods. |
|
This class implements a simple nonlinear ODE with a singularity in the derivative, taken from https://www.osti.gov/servlets/purl/6111421 (Problem E-4). |
|
Implement the Prothero-Robinson problem. |
|
Implement the Prothero-Robinson problem into autonomous form. |
|
Implement the Kaps problem. |
|
Chemical reaction with three components, modeled by the non-linear system. |
|
Implement the Jacobi Elliptic non-linear problem. |
|
Scalar ODE whose exact solution is a random polynomial in time, to test operations exact on polynomials. |
|
IMEX version of the polynomial test problem that assigns half the derivative to the implicit part and the other half to the explicit part. |
Sweepers#
The integrators within a step: SDC with its preconditioners and splittings, second-order and multistep methods, Runge-Kutta and ParaDiag.
Class |
Summary |
|---|---|
Base class for linear multistep methods, given by alpha and beta coefficients and a cache of previous steps. |
|
One-step Adams-Bashforth method, which is just forward Euler. |
|
Backward Euler written as a one-step implicit multistep method. |
|
Trapezoidal method dressed up as a multistep method. |
|
Third-order implicit two-step Adams-Moulton method, started with a trapezoidal rule step. |
|
Sweeper solving the collocation problem directly via diagonalization of Q. |
|
Variant of QDiagonalization for ParaDiag on problems whose right hand side has implicit and explicit parts. |
|
Base class for Runge-Kutta methods with lower triangular Butcher tableaux, wrapped in the sweeper interface. |
|
Implicit-explicit split Runge Kutta base class. |
|
Forward Euler. |
|
Backward Euler. |
|
First-order IMEX Euler with one backward Euler stage, at which both parts of the right hand side are evaluated. |
|
IMEX Euler with the explicit part evaluated at the start of the step, as a stiffly accurate two-stage method. |
|
Implicit Runge-Kutta method of second order, A-stable. |
|
Explicit Runge-Kutta method of second order. |
|
Implicit Runge-Kutta method of second order. |
|
Explicit Runge-Kutta of fourth order: Everybody’s darling. |
|
Second order explicit embedded Runge-Kutta method. |
|
Fifth order explicit embedded Runge-Kutta. |
|
Embedded A-stable diagonally implicit RK pair of order 3 and 4. |
|
L-stable Diagonally Implicit RK method with four stages of order 3. |
|
Stiffly accurate, fourth-order EDIRK with four stages. |
|
A-stable embedded RK pair of orders 5 and 3, ESDIRK5(3)6L[2]SA. |
|
A-stable embedded RK pair of orders 4 and 3, ESDIRK4(3)6L[2]SA. |
|
Explicit part of the ARK54 scheme. |
|
Implicit part of the ARK54 scheme. |
|
IMEX Runge-Kutta method ARK5(4)8L[2]SA of Kennedy and Carpenter, combining ARK548L2SAERK and ARK548L2SAESDIRK. |
|
Implicit part of ARK548L2SA: an L-stable, stiffly accurate ESDIRK pair of orders 5 and 4. |
|
Explicit part of ARK548L2SA: an explicit embedded Runge-Kutta pair of orders 5 and 4. |
|
Newer order-5 IMEX Runge-Kutta method ARK5(4)8L[2]SA of Kennedy and Carpenter, an alternative to ARK54. |
|
Explicit part of ARK32: an explicit embedded Runge-Kutta pair of orders 3 and 2. |
|
Implicit part of ARK32: an L-stable, stiffly accurate ESDIRK pair of orders 3 and 2. |
|
Embedded IMEX Runge-Kutta method ARK3(2)4L[2]SA of Kennedy and Carpenter, of orders 3 and 2. |
|
Second order two stage singly diagonally implicit globally stiffly accurate IMEX RK method with explicit first stage. |
|
Third order four stage singly diagonally implicit globally stiffly accurate IMEX RK method with explicit first stage. |
|
Base class for Runge-Kutta-Nystrom methods for second-order problems on particle data, as a sweeper. |
|
Classical fourth-order Runge-Kutta-Nystrom method, with the nodes and weights of RK4. |
|
Second-order velocity-Verlet scheme as a Runge-Kutta-Nystrom method, using a Boris solver for the velocity. |
|
SDC sweeper for charged particles in electromagnetic fields, with velocity-Verlet and a Boris push as base. |
|
Delta-form counterpart of |
|
Delta-form counterpart of |
|
Delta-form counterpart of |
|
Fully explicit SDC sweeper, with explicit Euler as the default base integrator. |
|
Generic implicit sweeper, expecting lower triangular matrix type as input |
|
MPI based sweeper where each rank administers one collocation node. |
|
Generic implicit sweeper parallelized across the nodes. |
|
Fully implicit SDC sweeper for the mass-matrix formulation (no M^-1 anywhere). |
|
SDC sweeper for right hand sides split into an implicitly and an explicitly treated part (IMEX-SDC). |
|
Node-parallel IMEX-SDC sweeper, one collocation node per MPI rank, so far only with Picard for the explicit part. |
|
IMEX-SDC sweeper for problems M u’ = f(u) with a mass matrix M, as they arise from finite elements. |
|
SDC sweeper for right hand sides with two parts, each treated implicitly with its own solver and preconditioner. |
|
SDC sweeper for second-order problems with velocity-independent forces, with velocity-Verlet as base integrator. |
Controllers#
Run the steps, one after the other or in parallel, with SDC, MLSDC, PFASST or ParaDiag.
Class |
Summary |
|---|---|
Controller running SDC, MLSDC and PFASST with each time step of a block on its own MPI rank. |
|
ParaDiag controller with MPI parallelism across time steps: one step per rank. |
|
ParaDiag controller with the time steps of a block emulated serially in one process. |
|
Controller running SDC, MLSDC and PFASST with the time steps of a block emulated serially in one process. |
Convergence controllers#
Change a run while it goes: error estimates, adaptive step sizes, stopping criteria and restarts.
Class |
Summary |
|---|---|
Choose the ParaDiag \(\alpha\) adaptively from the residual. |
|
This convergence controller allows to change the underlying quadrature between iterations. |
|
Abstract base class for adaptivity from arbitrary local error estimates and step size update rules. |
|
Base class for adaptivity from error estimates that need a converged collocation problem, restarting if it is not. |
|
Class to compute time step size adaptively based on embedded error estimate. |
|
Adaptivity for Runge-Kutta methods. |
|
Do adaptivity based on residual. |
|
Control the step size via a collocation based estimate of the local error. |
|
Compute the step size adaptively from an error estimate by extrapolation within the quadrature nodes. |
|
Compute the step size adaptively from an error estimate by interpolation within the quadrature nodes. |
|
Restart every step after one that requests a restart, and limit how often a step may be restarted in a row. |
|
Basic restarting for the non-MPI controller, which passes restart requests between steps through shared buffers. |
|
Basic restarting for the MPI controller, which passes restart requests on to the following ranks with MPI. |
|
Stop iterating once the contraction of the increments predicts that errtol is reached, for the non-MPI controller. |
|
Base class for convergence controllers that raise a ConvergenceError on all ranks as soon as one rank crashes. |
|
Crash all ranks when the solution contains nan or inf, or when its norm reaches the optional threshold thresh. |
|
Abort the code when the problem has exceeded a maximum runtime. |
|
Estimate the contraction factor by using the evolution of the embedded error estimate across iterations. |
|
Estimate the local error as the difference between two solutions of different order, such as two consecutive sweeps. |
|
Local error in a block of steps as the embedded estimate minus that of the step before, for the non-MPI controller. |
|
Local error in a block of steps as the embedded estimate minus that of the step before, for the MPI controller. |
|
Estimates an embedded error based on changing the underlying quadrature rule. |
|
Abstract base class for error estimates by Taylor extrapolation of solutions and right-hand sides from other times. |
|
Implementation of the extrapolation error estimate for the non-MPI controller. |
|
Estimate the local error by comparing the converged SDC solution to an extrapolation from other quadrature nodes. |
|
Estimate the local error by using all but one collocation node in a polynomial interpolation to that node. |
|
Polynomial interpolation error estimate for Firedrake functions, combining the node solutions term by term. |
|
Class that incorporates the Hot Rod detector [1] for soft faults. |
|
Gradually refine Newton tolerance based on SDC residual. |
|
Interpolate the solution and right hand side to the new set of collocation nodes after a restart. |
|
Give all steps of the next block the same step size, taken from the last step or from the first restarted one. |
|
Spread one step size to all steps of the next block for the non-MPI controller, reading the steps directly. |
|
Spread one step size to all steps of the next block for the MPI controller, with collectives across the time ranks. |
|
Clip the new step size to [dt_min, dt_max], and add a StepSizeSlopeLimiter if slope limits are given. |
|
Bound dt_new / dt to [dt_slope_min, dt_slope_max], keeping dt if the change is below dt_rel_min_slope. |
|
Class to round step size when using adaptive step size selection. |
|
Class to store the solution of the last iteration in a variable called ‘uold’ of the levels. |
Hooks#
Record what happens during a run into the statistics.
Class |
Summary |
|---|---|
Track the shrinking circle (or sphere) of an Allen-Cahn run. |
|
Hook for recording GPU timings of important operations during a pySDC run. |
|
Store the embedded error estimate at the end of each step as “error_embedded_estimate”. |
|
Store the embedded error estimate after each iteration as “error_embedded_estimate_post_iteration”. |
|
Base class for hooks that log the local or global error with respect to the u_exact of the problem. |
|
Log the global error with respect to u_exact at the end of each step as “e_global_post_step”. |
|
Log the global error after each iteration |
|
Compute the global error once after the run is finished. |
|
Log the local error with respect to u_exact defined in the problem class as “e_local_post_step”. |
|
Log the local error after each iteration |
|
Store the extrapolated error estimate at the end of each step as “error_extrapolation_estimate”. |
|
Record restarts as restart at the beginning of the step. |
|
Store the solution at the end of each step as “u”. |
|
Store the solution at the end of each iteration as “u”. |
|
Hook for logging the solution to file after the step using pickle. |
|
Log to file after certain amount of time has passed instead of after every step |
|
Write the solution every time_increment to one FieldsIO file set up by the problem, resuming an existing file. |
|
Store the step size at the end of each step as “dt”. |
|
Log the increment of all work counters in the problem between steps |
|
Log the number of SDC iterations between steps. |
|
Base class for hooks that plot the solution with the problem’s plot method, optionally saving each figure. |
|
Call a plotting function of the problem after every step |
Transfer#
Move data between the levels of MLSDC and PFASST: restriction and interpolation in space, and the FAS correction.
Class |
Summary |
|---|---|
Space-time transfer that passes a residual down and an accumulated correction up. |
|
Node-parallel counterpart of |
|
Node-parallel space-time transfer for sweepers where each MPI rank holds one collocation node. |
|
Space-time transfer for problems with a mass matrix, which enters the FAS correction and the restricted u0. |
|
This implementation can restrict and prolong between fenics meshes |
|
This implementation can restrict and prolong between Firedrake meshes |
|
This implementation can restrict and prolong between Firedrake meshes that are generated from a hierarchy. |
|
Space transfer between nd meshes by sparse interpolation matrices of even order, restricting by their transpose. |
|
Space transfer between periodic 1d meshes: injection to restrict, Fourier interpolation to prolong. |
|
Space transfer between periodic square 2d meshes: injection to restrict, Fourier interpolation to prolong. |
|
Space transfer between distributed periodic mpi4py-fft meshes: injection to restrict, spectral padding to prolong. |
|
Identity space transfer for levels on the same mesh, copying the data in both directions. |
|
This implementation can restrict and prolong between PETSc DMDA grids |
|
Identity space transfer for particles, fields and accelerations, copying the data in both directions. |
Data types#
What solutions and right-hand sides are stored in.
Class |
Summary |
|---|---|
Datatype with multiple components, each one an object of its own. |
|
CuPy-based datatype for serial or parallel meshes. |
|
CuPy-based mesh with multiple components, see |
|
CuPy mesh with an implicit part |
|
CuPy mesh with two parts |
|
FEniCS Function data type with arbitrary dimensions |
|
RHS data type for fenics_meshes with implicit and explicit components |
|
Wrapper for firedrake function data. |
|
Datatype for IMEX integration with firedrake data. |
|
Numpy-based datatype for serial or parallel meshes. |
|
Generic mesh with multiple components. |
|
Numpy-based mesh with multiple components, see |
|
NumPy mesh with an implicit part |
|
NumPy mesh with two parts |
|
Particle data type for particles in 3 dimensions |
|
Mesh holding the accelerations of the particles, the right-hand side type for |
|
Field data type for 3 dimensions |
|
PETSc |
|
RHS data type for Vec with implicit and explicit components |
|
RHS data type for Vec with two components |
Core#
The base classes everything above derives from, and the step and level they run on.
Class |
Summary |
|---|---|
Space-time transfer between two levels, interpolating across collocation nodes and computing the FAS correction. |
|
Perform simple checks on convergence for SDC iterations. |
|
Generic collocation class, that contains everything to do integration over intervals and between nodes. |
|
Base class to register parameters. |
|
Abstract base class of the controllers, which set up hooks and convergence controllers and run the steps in time. |
|
Frozen parameters of a convergence controller as attributes, with defaults for control_order and useMPI. |
|
Frozen container for named variables of a convergence controller. |
|
Abstract base class for convergence controllers, which plug into the controller to steer iterations and step sizes. |
|
Hook added to every controller, recording the residuals and the number of iterations of each step. |
|
Error Class handling/indicating problems with data types |
|
Error Class handling/indicating problems with parameters (mostly within dictionaries) |
|
Error class handling/indicating unlocked levels |
|
Error class handling/indicating problems with the collocation |
|
Error class handling/indicating problems with convergence |
|
Error class handling/indicating problems with the transfer processes |
|
Error class handling/indicating problems with the communication |
|
Error class handling/indicating problems with the controller |
|
Error class handling/indicating problems with the problem classes |
|
Exception thrown when setting a read-only class attribute |
|
Base class for hooks, with methods the controller calls around each run, step, iteration and sweep to record stats. |
|
Level class containing all management functionality for a single level |
|
Utility class for counting iterations. |
|
Prototype class for problems, just defines the attributes essential to get started. |
|
Abstract base class for the restriction and prolongation of data in space between a fine and a coarse problem. |
|
Step class, referencing most of the structure needed for the time-stepping |
|
Base abstract sweeper class, provides two base methods to generate QDelta matrices. |
|
Abstract base class for hooks timing the setup, run, predictor, steps, iterations, sweeps and communication. |
|
Hook for recording CPU timings of important operations during a pySDC run. |
Helpers#
Utilities for statistics, plots, setups, input and output.
Module |
Summary |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|