Source-linked AI summary
PETSc/TS: A Modern Scalable ODE/DAE Solver Library
Shrirang Abhyankar, Jed Brown, Emil M. Constantinescu, Debojyoti Ghosh, Barry F. Smith, Hong Zhang
TL;DR
ODE and DAE solvers must accommodate varied problem requirements, including different stability needs and sensitivity calculations. This paper presents PETSc’s time-integration library, combining solver methods with sensitivity and event-handling capabilities. It describes the integrators as scalable and built on PETSc’s mathematical libraries.
Problem
ODE/DAE integration must address different problem requirements, including method stability and Jacobian coding that can be a user stumbling block.
Source: §3 · p. 4, §4.1 · p. 10Method
The paper presents PETSc time integrators with explicit, implicit, and partitioned methods, alongside forward and adjoint sensitivity capabilities.
Source: §4.1 · p. 10, §9 · p. 26Results
The paper describes PETSc’s integrators as scalable and built on its mathematical libraries, with local and global error control, sensitivity computation, event handling, and monitoring tools.
Source: §9 · p. 26Takeaways & Limitations
The library brings time integration, error control, sensitivities, event handling, and solution monitoring into PETSc’s solver infrastructure.
Source: §9 · p. 26Forward sensitivity computation has cost linear in the number of parameters, which usually limits its application to cases involving few parameters.
Source: §5.2 · p. 20
Abstract
from arXiv · showhide
High-quality ordinary differential equation (ODE) solver libraries have a long history, going back to the 1970s. Over the past several years we have implemented, on top of the PETSc linear and nonlinear solver package, a new general-purpose, extensive, extensible library for solving ODEs and differential algebraic equations (DAEs). Package includes support for both forward and adjoint sensitivities that can be easily utilized by the TAO optimization package, which is also part of PETSc. The ODE/DAE integrator library strives to be highly scalable but also to deliver high efficiency for modest-sized problems. The library includes explicit solvers, implicit solvers, and a collection of implicit-explicit solvers, all with a common user interface and runtime selection of solver types, adaptive error control, and monitoring of solution progress. The library also offers enormous flexibility in selection of nonlinear and linear solvers, including the entire suite of PETSc iterative solvers, as well as several parallel direct solvers.
1. INTRODUCTION
ODE/DAE algorithms and general-purpose solver libraries have a long history and continue to evolve with applications and hardware. This paper presents PETSc’s general-purpose ODE/DAE integrator package and describes its design and use.
1. INTRODUCTION
- General-purpose software libraries for solving ODEs and DAEs have existed for at least forty years, and continue to evolve with applications and hardware.Source: §1 · p. 1
- The package is built on PETSc’s mathematical libraries for distributed-memory parallel computing.Source: §1 · pp. 1–2
- PETSc’s ODE/DAE integrator package provides local and global error control, sensitivity computation, and handling of events.The paper describes the package’s design, properties, and usage.Source: §1 · p. 2
2. BACKGROUND: PETSC LINEAR AND NONLINEAR SOLVERS
PETSc combines mathematical objects and solver classes within a scalable, MPI-based numerical library. Its compact APIs and runtime options support composing and configuring solvers for applications.
2. BACKGROUND: PETSC LINEAR AND NONLINEAR SOLVERS
- PETSc is a scalable, MPI-based, object-oriented numerical library written in C and usable from C, C++, Fortran, and Python.Source: §2 · p. 2
- PETSc’s core classes include vectors, matrices, preconditioners, Krylov solvers, and nonlinear solvers.Index sets provide an abstraction for indexing vectors and matrices.Source: §2 · p. 2
- The DM class connects meshes and discretizations to the algebraic and timestepper objects used to solve discrete problems.DMDA supports structured-grid finite differences, while DMPLEX supports unstructured-mesh finite elements or finite volumes.Source: §2 · p. 2
- PETSc keeps public APIs small and provides both programmatic control and an options database for runtime configuration.Source: §2 · p. 2
- PETSc manages object classes with C structs and function pointers, allowing an object’s derived class to be changed at runtime.For example, a linear solver can be changed from GMRES to Bi-CG-stab by resetting its type.Source: §2 · p. 2
- A typical PETSc object workflow creates and configures the object, sets it up, uses it, and then destroys it.Reference counting prevents objects shared by other objects from being destroyed prematurely.Source: §2 · p. 3
3. PETSC TIMESTEPPING APPLICATION PROGRAMMING INTERFACE
PETSc’s TS interface organizes time-dependent problems around a DAE form and user-provided functions and Jacobians. It provides tools for Jacobian construction and checking, and examples demonstrate solving ODEs through the interface.
3. PETSC TIMESTEPPING APPLICATION PROGRAMMING INTERFACE
- The TS interface organizes time-dependent problems around a DAE form and lets users provide the functions needed to define the system.When only G(t,u) is provided, TS assumes F(t,u,u̇)=u̇.Source: §3 · p. 3
- If F_u̇ is nonsingular, the equation can be transformed to explicit ODE form, but that transformation may not yield efficient algorithms.The implicit/DAE interface can reduce preparation overhead for ODEs with nontrivial mass matrices.Source: §3 · p. 3
- For implicit and semi-implicit methods, the Jacobian interface uses a shifted derivative of F with respect to u̇ plus its derivative with respect to u.The shift reflects how the time integrator approximates u̇ at the current step.Source: §3 · p. 4
- Providing F() and G() and their derivatives allows runtime switching among explicit, semi-implicit, and fully implicit methods.Source: §3 · p. 4
- PETSc offers matrix-free Jacobian application, Jacobian computation by coloring and differencing, and automatic testing of user-provided Jacobians.Source: §3 · p. 4
- The examples demonstrate TS solving a small ODE system in C and a stiff chemical-reaction ODE system in Python.The Python example uses the petsc4py binding and the Rosenbrock-W method.Source: §3 · pp. 5–7
- A work-precision diagram illustrates how choosing different TSAdapt tolerances affects computational effort and precision.Source: §3 · p. 8
4. TIMESTEPPING SCHEMES
PETSc offers families of explicit, implicit, and partitioned time integrators, with error control and flexible solver selection. The section describes partitioned and Rosenbrock schemes and adaptive timestep control.
4. TIMESTEPPING SCHEMES
- PETSc includes multistage, multistep, and general linear methods; users can register schemes, apply local error control, and select PETSc linear and nonlinear solvers.Explicit methods are described as fast and accurate, implicit methods as having robust stability properties, and partitioned methods as combining both.Source: §4 · p. 8
4.1. Partitioned Runge-Kutta
- Partitioned Runge-Kutta methods integrate nonstiff components explicitly and stiff components implicitly, and can handle some problem formulations that standard IMEX Runge-Kutta cannot.General F(t, u, u̇) = G(t, u) cases are not amenable to IMEX Runge-Kutta but can be solved with the fully implicit option.Source: §4.1 · pp. 9, 11
- Dense-output extrapolation used for Newton initial guesses accelerated nonlinear problems by up to three times, though gains are highly problem dependent.The initial guess for all stages is based on the previous step’s extrapolated dense-output solution.Source: §4.1 · p. 12
4.2. Rosenbrock
- Rosenbrock methods use explicit function evaluations and implicit linear solves, while W-methods permit an approximate Jacobian; the implementation accommodates singular mass matrices and noninvertible Γ.A singular mass matrix can yield a DAE, and correcting for noninvertible Γ allows methods with explicit stages.Source: §4.2 · pp. 12–13
4.3. Adaptive Timestepping and Error Control
- TSAdapt adjusts timesteps to meet absolute and relative error tolerances, rejecting steps that exceed them; PETSc also provides CFL and global-error adapters.Custom adapters can be registered through the PETSc API.Source: §4.3 · pp. 16–17
5. COMPUTING SENSITIVITIES (DERIVATIVES)
PETSc’s timestepping library provides discrete adjoint and forward sensitivity models for ODEs and DAEs. The section describes their implementation and use, including adjoint checkpointing and the forward method’s parameter-dependent cost.
5.1. Discrete adjoint sensitivity
- The adjoint solver supports multiobjective and integral objectives, hybrid systems with discontinuities, and checkpointing schemes.A forward run saves the solution trajectory; a backward run propagates adjoint sensitivities, with checkpointing balancing recomputation and storage.Source: §5.1 · p. 18
- The adjoint solver is built on PETSc’s TS components, and its components are compatible and used together to address hybrid-system difficulties.The discrete adjoint step requires trajectory information, which checkpointing can restore or recompute.Source: §5.1 · pp. 18–19
5.2. Discrete forward (tangent linear) sensitivity
- The PETSc timestepping library provides a discrete forward (tangent linear) model by differentiating a one-step integration algorithm with respect to parameters.Forward sensitivities can calculate gradients of scalar objectives and provide solution sensitivities used in second-order adjoint analysis.Source: §5.2 · pp. 19–20
- Forward sensitivity computation solves one linear equation per parameter at each timestep, so its cost grows linearly with the number of parameters.This cost usually limits the approach to cases involving few parameters.Source: §5.2 · p. 20
6. HANDLING DISCONTINUITIES AND EVENTS
PETSc/TS handles discontinuities with TSEvent, which detects and locates zero crossings of a switching function and applies the event at the located time. It supports event-specific direction and tolerance controls, including when multiple events occur within one timestep.
6. HANDLING DISCONTINUITIES AND EVENTS
- TSEvent detects and locates discontinuities by propagating a switching function h(t, x) = 0 alongside the equations and finding its zero crossing.Conditionals can depend on state-variable functions, not only simple box constraints.Source: §6 · p. 20
- At each timestep, the solver checks for a sign change in the event function, rolls back, and uses interpolation and shrinking time bounds to locate the crossing within tolerance.Users can select positive, negative, or either crossing direction.Source: §6 · pp. 20–21
- For simultaneous events, TSEvent uses the smallest interpolated timestep; it also uses Illinois and Anderson–Björck methods to avoid duplicate steps and speed detection.After locating the event, the discontinuity is applied and an additional step synchronizes with the next timestep.Source: §6 · p. 21
- In the bouncing-ball example, vertical position is the event function; at ground contact, the velocity reverses direction and is attenuated by a factor of 0.9.The example defines the motion by ˙u = v and ˙v = −9.8, with the ground at u = 0.Source: §6 · p. 21, Figure 4 · p. 22
7. MONITORING AND VISUALIZATION
PETSc/TS provides extensible monitoring and visualization to help users inspect solution behavior and solver properties, including when they do not know qualitative features such as stiffness in advance. Monitor callbacks can track solution quantities over a run, while PetscViewer supports viewing PETSc data and solver objects through text, files, or graphics.
7. MONITORING AND VISUALIZATION
- Because users may not know whether an ODE is stiff or which parts are stiff, PETSc/TS offers extensible monitoring and visualization of solutions and properties such as maxima and Jacobian eigenvalues.These tools are intended to help users understand qualitative solution properties.Source: §7 · p. 22
- The PetscViewer abstraction provides ASCII, binary, and graphics views of PETSc data and solver objects, with parallel-object reduction handled automatically.Views can range from solver type and options to saved solver state or graphics showing relationships among nested solver objects.Source: §7 · p. 22
- Multiple monitor callbacks can be attached to a solver, and the monitor routine is called at the beginning and end of each timestep to present solution information.Default monitors can print timestep and time or save the solution to binary or VTK files.Source: §7 · p. 23
- Monitor callbacks can compute and track solution properties over a simulation without requiring users to modify the integrator code.Examples include maximum and minimum values and conserved quantities; Fig. 5 depicts graphical monitoring of adaptive timestep changes.Source: §7 · p. 24, Figure 5 · p. 24
8. SUPPORT FOR SPECIFIC APPLICATION DOMAINS
PETSc/TS lets application areas use higher-level problem descriptions through interfaces for power systems and chemical reactions. The sections describe DMNetwork's role in network applications and show how PETSc can wrap TCHEM's chemistry routines.
8. SUPPORT FOR SPECIFIC APPLICATION DOMAINS
- PETSc/TS provides higher-level interfaces so application users can define and work with problems in their own vocabulary; the paper presents power systems analysis and chemical reactions as supported domains.The authors expect to extend this work in collaboration with application partners.Source: §8 · pp. 24–25
8.1. Electrical Power Grid via DMNetwork
- For transient stability analysis, power-grid stability is determined by time-domain simulation of grid DAEs, with differential equations for generators and motors and algebraic equations for the electrical network.DMNetwork manages network data and topology, represents node-edge relationships, and connects PETSc solvers with application physics.Source: §8.1 · p. 25
- Prior comparisons for transient stability problems found Rosenbrock schemes optimal in speedup and accuracy; separate work reported real-time simulation on a fairly large grid.The cited reports describe prior work, not results of new experiments in this paper.Source: §8.1 · p. 25
8.2. Chemical Reactions via TCHEM
- The TCHEM interface lets PETSc call chemistry routines for right-hand-side evaluation and Jacobian computation, integrating TCHEM capabilities with PETSc's ODE integrators.The code example wraps TCHEM routines that accept raw numerical values and returns the Jacobian for insertion into a PETSc matrix.Source: §8.2 · pp. 25–26
9. CONCLUSION
The paper presents PETSc as scalable infrastructure for solving ODEs and DAEs and describes its time-integration capabilities. These include integrators, error control, forward and adjoint sensitivities, event handling, and tools for monitoring and visualizing solutions and solver processes.
9. CONCLUSION
- PETSc provides infrastructure for efficient, scalable ODE and DAE solution, and the integrators build on PETSc's mathematical libraries.The paper introduces the time-integration component and gives usage examples.Source: §9 · p. 26
- The paper describes available integrators and their properties, along with local and global error control.Source: §9 · p. 26
- PETSc/TS supports forward and adjoint sensitivities, event handling for discontinuities, and tools to monitor and visualize solutions and the solution process.Source: §9 · p. 26