4.1. Introduction

CVODES [112] is part of a software family called SUNDIALS: SUite of Nonlinear and DIfferential/ALgebraic equation Solvers [70]. This suite consists of CVODE, ARKODE, KINSOL, and IDA, and variants of these with sensitivity analysis capabilities. CVODES is a solver for stiff and nonstiff initial value problems (IVPs) for systems of ordinary differential equation (ODEs). In addition to solving stiff and nonstiff ODE systems, CVODES has sensitivity analysis capabilities, using either the forward or the adjoint methods.

4.1.1. Historical Background

Fortran solvers for ODE initial value problems are widespread and heavily used. Two solvers that have been written at LLNL in the past are VODE [21] and VODPK [27]. VODE is a general purpose solver that includes methods for both stiff and nonstiff systems, and in the stiff case uses direct methods (full or banded) for the solution of the linear systems that arise at each implicit step. Externally, VODE is very similar to the well known solver LSODE [97]. VODPK is a variant of VODE that uses a preconditioned Krylov (iterative) method, namely GMRES, for the solution of the linear systems. VODPK is a powerful tool for large stiff systems because it combines established methods for stiff integration, nonlinear iteration, and Krylov (linear) iteration with a problem-specific treatment of the dominant source of stiffness, in the form of the user-supplied preconditioner matrix [22]. The capabilities of both VODE and VODPK have been combined in the C-language package CVODE [38].

At present, CVODE may utilize a variety of Krylov methods provided in SUNDIALS that can be used in conjuction with Newton iteration: these include the GMRES (Generalized Minimal RESidual) [106], FGMRES (Flexible Generalized Minimum RESidual) [105], Bi-CGStab (Bi-Conjugate Gradient Stabilized) [131], TFQMR (Transpose-Free Quasi-Minimal Residual) [56], and PCG (Preconditioned Conjugate Gradient) [65] linear iterative methods. As Krylov methods, these require almost no matrix storage for solving the Newton equations as compared to direct methods. However, the algorithms allow for a user-supplied preconditioner matrix, and for most problems preconditioning is essential for an efficient solution. For very large stiff ODE systems, the Krylov methods are preferable over direct linear solver methods, and are often the only feasible choice. Among the Krylov methods in SUNDIALS, we recommend GMRES as the best overall choice. However, users are encouraged to compare all options, especially if encountering convergence failures with GMRES. Bi-CGStab and TFQMR have an advantage in storage requirements, in that the number of workspace vectors they require is fixed, while that number for GMRES depends on the desired Krylov subspace size. FGMRES has an advantage in that it is designed to support preconditioners that vary between iterations (e.g., iterative methods). PCG exhibits rapid convergence and minimal workspace vectors, but only works for symmetric linear systems.

In the process of translating the VODE and VODPK algorithms into C, the overall CVODE organization has been changed considerably. One key feature of the CVODE organization is that the linear system solvers comprise a layer of code modules that is separated from the integration algorithm, allowing for easy modification and expansion of the linear solver array. A second key feature is a separate module devoted to vector operations; this facilitated the extension to multiprosessor environments with minimal impacts on the rest of the solver, resulting in PVODE [30], the parallel variant of CVODE.

CVODES is written with a functionality that is a superset of that of the pair CVODE/PVODE. Sensitivity analysis capabilities, both forward and adjoint, have been added to the main integrator. Enabling forward sensititivity computations in CVODES will result in the code integrating the so-called sensitivity equations simultaneously with the original IVP, yielding both the solution and its sensitivity with respect to parameters in the model. Adjoint sensitivity analysis, most useful when the gradients of relatively few functionals of the solution with respect to many parameters are sought, involves integration of the original IVP forward in time followed by the integration of the so-called adjoint equations backward in time. CVODES provides the infrastructure needed to integrate any final-condition ODE dependent on the solution of the original IVP (in particular the adjoint system).

Development of CVODES was concurrent with a redesign of the vector operations module across the SUNDIALS suite. The key feature of the N_Vector module is that it is written in terms of abstract vector operations with the actual vector functions attached by a particular implementation (such as serial or parallel) of N_Vector. This allows writing the SUNDIALS solvers in a manner independent of the actual N_Vector implementation (which can be user-supplied), as well as allowing more than one N_Vector module to be linked into an executable file. SUNDIALS (and thus CVODES) is supplied with serial, MPI-parallel, and both OpenMP and Pthreads thread-parallel N_Vector implementations.

There were several motivations for choosing the C language for CVODE, and later for CVODES. First, a general movement away from Fortran and toward C in scientific computing was apparent. Second, the pointer, structure, and dynamic memory allocation features in C are extremely useful in software of this complexity. Finally, we prefer C over C++ for CVODES because of the wider availability of C compilers, the potentially greater efficiency of C, and the greater ease of interfacing the solver to applications written in extended Fortran.

4.1.2. Changes to SUNDIALS in release 7.1.0

Major Features

Created shared user interface functions for ARKODE to allow more uniform control over time-stepping algorithms, improved extensibility, and simplified code maintenance. The corresponding stepper-specific user-callable functions are now deprecated and will be removed in a future major release.

Added CMake infrastructure that enables externally maintained addons/plugins to be optionally built with SUNDIALS. See Contributing for details.

New Features and Enhancements

Added support for Kokkos Kernels v4.

Added the following Runge-Kutta Butcher tables

  • ARKODE_FORWARD_EULER_1_1

  • ARKODE_RALSTON_EULER_2_1_2

  • ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2

  • ARKODE_BACKWARD_EULER_1_1

  • ARKODE_IMPLICIT_MIDPOINT_1_2

  • ARKODE_IMPLICIT_TRAPEZOIDAL_2_2

Added the following MRI coupling tables

  • ARKODE_MRI_GARK_FORWARD_EULER

  • ARKODE_MRI_GARK_RALSTON2

  • ARKODE_MRI_GARK_RALSTON3

  • ARKODE_MRI_GARK_BACKWARD_EULER

  • ARKODE_MRI_GARK_IMPLICIT_MIDPOINT

  • ARKODE_IMEX_MRI_GARK_EULER

  • ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL

  • ARKODE_IMEX_MRI_GARK_MIDPOINT

Added ARKodeButcherTable_ERKIDToName() and ARKodeButcherTable_DIRKIDToName() to convert a Butcher table ID to a string representation.

Added the function ARKodeSetAutonomous() in ARKODE to indicate that the implicit right-hand side function does not explicitly depend on time. When using the trivial predictor, an autonomous problem may reuse implicit function evaluations across stage solves to reduce the total number of function evaluations.

Users may now disable interpolated output in ARKODE by passing ARK_INTERP_NONE to ARKodeSetInterpolantType(). When interpolation is disabled, rootfinding is not supported, implicit methods must use the trivial predictor (the default option), and interpolation at stop times cannot be used (interpolating at stop times is disabled by default). With interpolation disabled, calling ARKodeEvolve() in ARK_NORMAL mode will return at or past the requested output time (setting a stop time may still be used to halt the integrator at a specific time). Disabling interpolation will reduce the memory footprint of an integrator by two or more state vectors (depending on the interpolant type and degree) which can be beneficial when interpolation is not needed e.g., when integrating to a final time without output in between or using an explicit fast time scale integrator with an MRI method.

Added “Resize” capability to ARKODE’s SPRKStep time-stepping module.

Enabled the Fortran interfaces to build with 32-bit sunindextype.

Bug Fixes

Updated the CMake variable HIP_PLATFORM default to amd as the previous default, hcc, is no longer recognized in ROCm 5.7.0 or newer. The new default is also valid in older version of ROCm (at least back to version 4.3.1).

Renamed the DPCPP value for the SUNDIALS_GINKGO_BACKENDS CMake option to SYCL to match Ginkgo’s updated naming convention.

Changed the CMake version compatibility mode for SUNDIALS to AnyNewerVersion instead of SameMajorVersion. This fixes the issue seen here.

Fixed a CMake bug that caused an MPI linking error for our C++ examples in some instances. Fixes GitHub Issue #464.

Fixed the runtime library installation path for windows systems. This fix changes the default library installation path from CMAKE_INSTALL_PREFIX/CMAKE_INSTALL_LIBDIR to CMAKE_INSTALL_PREFIX/CMAKE_INSTALL_BINDIR.

Fixed conflicting .lib files between shared and static libs when using MSVC on Windows

Fixed invalid SUNDIALS_EXPORT generated macro when building both shared and static libs.

Fixed a bug in some Fortran examples where c_null_ptr was passed as an argument to a function pointer instead of c_null_funptr. This caused compilation issues with the Cray Fortran compiler.

Fixed a bug in the HIP execution policies where WARP_SIZE would not be set with ROCm 6.0.0 or newer.

Fixed a bug that caused error messages to be cut off in some cases. Fixes GitHub Issue #461.

Fixed a memory leak when an error handler was added to a SUNContext. Fixes GitHub Issue #466.

Fixed a bug where MRIStepEvolve() would not handle a recoverable error produced from evolving the inner stepper.

Added missing SetRootDirection and SetNoInactiveRootWarn functions to ARKODE’s SPRKStep time-stepping module.

Fixed a bug in ARKodeSPRKTable_Create() where the coefficient arrays were not allocated.

Fix bug on LLP64 platforms (like Windows 64-bit) where KLU_INDEXTYPE could be 32 bits wide even if SUNDIALS_INT64_T is defined.

Check if size of SuiteSparse_long is 8 if the size of sunindextype is 8 when using KLU.

Fixed several build errors with the Fortran interfaces on Windows systems.

Deprecation Notices

Numerous ARKODE stepper-specific functions are now deprecated in favor of ARKODE-wide functions.

Deprecated the ARKStepSetOptimalParams function. Since this function does not have an ARKODE-wide equivalent, instructions have been added to the user guide for how to retain the current functionality using other user-callable functions.

The unsupported implementations of N_VGetArrayPointer and N_VSetArrayPointer for the hypre and PETSc vectors are now deprecated. Users should access the underlying wrapped external library vector objects instead with N_VGetVector_ParHyp and N_VGetVector_Petsc, respectively.

For changes in prior versions of SUNDIALS see §15.

4.1.3. Reading this User Guide

This user guide is a combination of general usage instructions. Specific example programs are provided as a separate document. We expect that some readers will want to concentrate on the general instructions, while others will refer mostly to the examples, and the organization is intended to accommodate both styles.

There are different possible levels of usage of CVODES. The most casual user, with a small IVP problem only, can get by with reading §4.2.1, then Chapter §4.4.1 up to §4.4.2 only, and looking at examples in [113]. In addition, to solve a forward sensitivity problem the user should read §4.2.7, followed by Chapter §4.4.3 and look at examples in [113].

In a different direction, a more expert user with an IVP problem may want to (a) use a package preconditioner (§4.4.2.7), (b) supply his/her own Jacobian or preconditioner routines (§4.4.1.4), (c) do multiple runs of problems of the same size (CVodeReInit()), (d) supply a new N_Vector module (§8), or even (e) supply new SUNLinearSolver and/or SUNMatrix modules (Chapters §9 and §10). An advanced user with a forward sensitivity problem may also want to (a) provide his/her own sensitivity equations right-hand side routine §4.4.3.3, (b) perform multiple runs with the same number of sensitivity parameters (§4.4.3.2.1, or (c) extract additional diagnostic information (§4.4.3.2.7). A user with an adjoint sensitivity problem needs to understand the IVP solution approach at the desired level and also go through §4.2.8 for a short mathematical description of the adjoint approach, Chapter §4.4.4 for the usage of the adjoint module in CVODES, and the examples in [113].

The structure of this document is as follows:

  • In Chapter §4.2, we give short descriptions of the numerical methods implemented by CVODES for the solution of initial value problems for systems of ODEs, continue with short descriptions of preconditioning §4.2.3, stability limit detection (§4.2.4), and rootfinding (§4.2.5), and conclude with an overview of the mathematical aspects of sensitivity analysis, both forward (§4.2.7) and adjoint (§4.2.8).

  • The following chapter describes the software organization of the CVODES solver (§4.3).

  • Chapter §4.4.1 is the main usage document for CVODES for simulation applications. It includes a complete description of the user interface for the integration of ODE initial value problems. Readers that are not interested in using CVODES for sensitivity analysis can then skip the next two chapters.

  • Chapter §4.4.3 describes the usage of CVODES for forward sensitivity analysis as an extension of its IVP integration capabilities. We begin with a skeleton of the user main program, with emphasis on the steps that are required in addition to those already described in Chapter §4.4.1. Following that we provide detailed descriptions of the user-callable interface routines specific to forward sensitivity analysis and of the additonal optional user-defined routines.

  • Chapter §4.4.4 describes the usage of CVODES for adjoint sensitivity analysis. We begin by describing the CVODES checkpointing implementation for interpolation of the original IVP solution during integration of the adjoint system backward in time, and with an overview of a user’s main program. Following that we provide complete descriptions of the user-callable interface routines for adjoint sensitivity analysis as well as descriptions of the required additional user-defined routines.

  • Chapter §8 gives a brief overview of the generic N_Vector module shared among the various components of SUNDIALS, and details on the N_Vector implementations provided with SUNDIALS.

  • Chapter §9 gives a brief overview of the generic SUNMatrix module shared among the various components of SUNDIALS, and details on the SUNMatrix implementations provided with SUNDIALS: a dense implementation (§9.9), a banded implementation (§9.12) and a sparse implementation (§9.14).

  • Chapter §10 gives a brief overview of the generic SUNLinearSolver module shared among the various components of SUNDIALS. This chapter contains details on the SUNLinearSolver implementations provided with SUNDIALS. The chapter also contains details on the SUNLinearSolver implementations provided with SUNDIALS that interface with external linear solver libraries.

  • Finally, in the appendices, we provide detailed instructions for the installation of CVODES, within the structure of SUNDIALS (Appendix §1.1), as well as a list of all the constants used for input to and output from CVODES functions (Appendix §4.5).

Finally, the reader should be aware of the following notational conventions in this user guide: program listings and identifiers (such as CVodeInit) within textual explanations appear in typewriter type style; fields in C structures (such as content) appear in italics; and packages or modules, such as CVDLS, are written in all capitals.

Warning

Usage and installation instructions that constitute important warnings are marked in yellow boxes like this one.

4.1.4. SUNDIALS License and Notices

All SUNDIALS packages are released open source, under the BSD 3-Clause license for more details see the LICENSE and NOTICE files provided with all SUNDIALS packages.