SUNDIALS: SUite of Nonlinear and DIfferential/ALgebraic Equation Solvers
CVODE

CVODE is a solver for stiff and nonstiff ordinary differential equation (ODE) systems (initial value problem) given in explicit form y’ = f(t,y).

The methods used in CVODE are variable-order, variable-step multistep methods. For nonstiff problems, CVODE includes the Adams-Moulton formulas, with the order varying between 1 and 12. For stiff problems, CVODE includes the Backward Differentiation Formulas (BDFs) in so-called fixed-leading coefficient form, with order varying between 1 and 5. For either choice of formula, the resulting nonlinear system is solved (approximately) at each integration step. For this, CVODE offers the choice of either functional iteration, suitable only for nonstiff systems, and various versions of Newton iteration. In the cases of a direct linear solver (dense or banded), the Newton iteration is a Modified Newton iteration, in that the Jacobian is fixed (and usually out of date). When using a Krylov method as the linear solver, the iteration is an Inexact Newton iteration, using the current Jacobian (through matrix-free products), in which the linear residual is nonzero but controlled.

The implicit nonlinear systems within implicit integrators are solved approximately at each integration step using a modified Newton method, an Inexact Newton method, or fixed-point solver (functional iteration). For the Newton-based methods and the serial or threaded NVECTOR modules in SUNDIALS, CVODE provides both direct (dense, band, or sparse) and preconditioned Krylov iterative (GMRES, BiCGStab, TFQMR) linear solvers. When used with one of the distributed parallel NVECTOR modules, including PETSc and hypre vectors, or a user-provided vector data structure, only the Krylov solvers are available, although a user may supply their own linear solver for any data structures if desired.  For the serial vector structure, there is a banded preconditioner module called CVBANDPRE for use with the Krylov solvers, while for the distributed memory parallel structure there is a preconditioner module called CVBBDPRE which provides a band-block-diagonal preconditioner.

For use with Fortran applications, a set of Fortran/C interface routines, called FCVODE, is also supplied. These are written in C, but assume that the user calling program and all user-supplied routines are in Fortran.

## cvode release history

### What’s New in v.4.0.0-dev.1

Version 4.0.0-dev.1 is a second step toward the full 4.0.0 release which should be complete by end of 2018.  The 4.0.0 release will include a full redesign of our nonlinear solver interfaces allowing for encapsulation of the nonlinear solvers and ease in interfacing outside nonlinear solver packages as well as a restructuring of the ARKode package to allow for more time stepping options.

• New features and/or enhancements

An API for encapsulating the nonlinear solvers used in SUNDIALS implicit
integrators has been introduced and are utilized by the CVODE and IDA packages.
The other SUNDIALS packages will be updated to use generic nonlinear solver in a
later release. The goal of this API is to ease the introduction of new nonlinear
solver options in SUNDIALS integrators and allow for external or user-supplied
nonlinear solvers. The SUNNONLINSOL API and provided SUNNONLINSOL modules are
described in a new user guide chapter and follow the same object oriented design
and implementation used by the NVECTOR, SUNMATRIX, and SUNLINSOL modules.

SUNNONLINSOL modules are intended to solve nonlinear systems formulated as
either a rootfinding problem F(y)=0 or a fixed-point problem y=G(Y).
Currently two SUNNONLINSOL implementations are provided,
SUNNONLINSOL_NEWTON and SUNNONLINSOL_FIXEDPOINT. These replicate the
previous integrator specific implementations of a Newton iteration and a
fixed-point iteration (previously referred to as functional iteration),
respectively. Additionally, the fixed-point iteration can use Anderson’s method
to accelerate convergence. Example programs using each of these nonlinear solver
modules in a standalone manner have been added and all CVODE AND IDA example programs
have been updated to use generic SUNNONLINSOL modules.

With the introduction of SUNNONLINSOL modules in CVODE, the input parameter ITER
to CVodeCreate has been removed as well as the constants CV_NEWTON
and CV_FUNCTIONAL. Similarly, the ITMETH parameter has been removed
from the Fortran interface function FCVMALLOC. Instead of specifying the
nonlinear iteration type when creating the CVODE memory structure, CVODE
uses the SUNNONLINSOL_NEWTON module implementation of a Newton iteration by
default.

As a result of this new nonlinear solver object creation and attachment approach,
the function CVodeSetIterType has been removed. CVODE functions for
setting the nonlinear solver options (e.g., CVodeSetMaxNonlinIters) or
getting nonlinear solver statistics (e.g., CVodeGetNumNonlinSolvIters)
remain unchanged and internally call generic SUNNONLINSOL functions.

### What’s New in v.3.1.2

• Updated the minimum required version of CMake to 2.8.12 and enabled using rpath by default to locate shared libraries on OSX.
• Fixed Windows specific problem where ‘sunindextype’ was not correctly defined when using 64-bit integers for the SUNDIALS index type. On Windows ‘sunindextype’ is now defined as the MSVC basic type ‘__int64’

• Added sparse SUNMatrix “Reallocate” routine to allow specification of the nonzero storage.

• Updated the KLU SUNLinearSolver module to set constants for the two reinitialization types, and fixed a bug in the full reinitialization approach where the sparse SUNMatrix pointer would go out of scope on some architectures.

• Updated the “ScaleAdd” and “ScaleAddI” implementations in the sparse SUNMatrix module to more optimally handle the case where the target matrix contained sufficient storage for the sum, but had the wrong sparsity pattern.  The sum now occurs in-place, by performing the sum backwards in the existing storage.  However, it is still more efficient if the user-supplied Jacobian routine allocates storage for the sum ‘I+ gamma J’ manually (with zero entries if needed).

• Changed the LICENSE install path to ‘instdir/include/sundials’.

• In CVODE:

• Added the following examples from the usage notes page of the SUNDIALS website, and updated them to work with SUNDIALS 3.x:

• ‘cvDisc_dns.c’, which demonstrates using CVODE with discontinuous solutions or RHS.

• ‘cvRoberts_dns_negsol.c’, which illustrates the use of the RHS function return value to control unphysical negative concentrations.

### What’s new in v.4.0.0-dev

Version 4.0.0-dev is a first step toward the full 4.0.0 release which should be complete by end of 2018.  The 4.0.0 release will inlude a full redesign of our nonlinear solver interfaces allowing for encapsulation of the nonlinear solvers and ease in interfacing outside nonlinear solver packages.

• New features and/or enhancements
• Three fused vector operations and seven vector array operations have been added to the NVECTOR API. These optional operations are intended to increase data reuse in vector operations, reduce parallel communication on distributed memory systems, and lower the number of kernel launches on systems with accelerators. The new operations are N_VLinearCombination, N_VScaleAddMulti, N_VDotProdMulti, N_VLinearCombinationVectorArray, N_VScaleVectorArray, N_VConstVectorArray, N_VWrmsNormVectorArray, N_VWrmsNormMaskVectorArray, N_VScaleAddMultiVectorArray, and N_VLinearCombinationVectorArray. If any of these operations are defined as NULL in an NVECTOR implementation the NVECTOR interface will automatically call standard NVECTOR operations as necessary.   Details on the new operations can be found in the user guide Chapter on the NVECTOR API.
• Several changes were made to the build system.
• If MPI is enabled and MPI compiler wrappers are not set, the build system will check if  CMAKE_<language>_COMPILER can compile MPI programs before trying to locate and use an MPI installation. The native CMake FindMPI module is now used to locate an MPI installation.
• The options for setting MPI compiler wrappers and the executable for running MPI programs have been updated to align with those in the native CMake FindMPI module. This included changing MPI_MPICC to MPI_C_COMPILER, MPI_MPICXX to MPI_CXX_COMPILER, combining MPI_MPIF77 and MPI_MPIF90 to MPI_Fortran_COMPILER, and changing MPI_RUN_COMMAND to MPIEXEC.
• When a Fortran name-mangling scheme is needed (e.g., LAPACK_ENABLE is ON) the build system will infer the scheme from the Fortran compiler. If a Fortran compiler is not available or the inferred or default scheme needs to be overridden, the advanced options SUNDIALS_F77_FUNC_CASE and SUNDIALS_F77_FUNC_UNDERSCORES can be used to manually set the name-mangling scheme and bypass trying to infer the scheme.
• Parts of the main CMakeLists.txt file were moved to new files in the src and example directories to make the CMake configuration file structure more modular.

### What’s new in v.3.1.1

• Fixed a potential memory leak in the SPGMR and SPFGMR linear solvers: if “Initialize” was called multiple times then the solver memory was reallocated (without being freed).
• Fixed C++11 compiler errors/warnings about incompatible use of string literals.

• Updated KLU SUNLinearSolver module to use a typedef for the precision-specific solve function to be used (to avoid compiler warnings).

• Added missing typecasts for some (void*) pointers (again, to avoid compiler warnings).

• Bugfix in sunmatrix_sparse.c where we had used ‘int’ instead of ‘sunindextype’ in one location.

• Fixed an indexing bug in the CUDA NVECTOR implementation of N_VWrmsNormMask and revised the RAJA NVECTOR implementation of N_VWrmsNormMask to work with mask arrays using values other than zero or one. Replaced doubles with realtypes in the RAJA vector test functions.

• Fixed compilation issue with GCC 7.3.0 and Fortran programs that do not require a SUNMatrix or SUNLinearSolver module (e.g. iterative linear solvers, explicit methods in ARKode, functional iteration in CVODE, etc.).

• In CVODE and CVODES:

• Fixed a minor bug in the CVODE and CVODES cvSLdet routine, where a return was missing in the error check for three inconsistent roots.

### What’s new in v.3.1.0?

• New features and/or enhancements
• Added NVECTOR print functions that write vector data to a specified file (e.g., N_VPrintFile_Serial).
• Added ‘make test’ and ‘make test_install’ options to the build system for testing SUNDIALS after building with ‘make’ and installing with ‘make install’ respectively.

### What’s new in v3.0.0?

• New features and/or enhancements
• New linear solver API and interfaces for all SUNDIALS packages and linear solvers.  The goal of the redesign of these interfaces was to provide more encapsulation and ease in interfacing custom linear solvers and interoperability with linear solver libraries.
• Added generic SUNMATRIX module with three provided implementations: dense, banded, and sparse.  These implementations replicate previous SUNDIALS Dls and Sls matrix structures in a single object-oriented API.
• Added example problems demonstrating use of generic SUNMATRIX modules.
• Added generic SUNLINEARSOLVER module with eleven provided implementations: dense, banded, LAPACK dense, LAPACK band, KLU, SuperLU_MT, SPGMR, SPBCGS, SPTFQMR, SPFGMR, and PCG.  These implementations replicate previous SUNDIALS generic linear solvers in a single object-oriented API.
• Added example problems demonstrating use of generic SUNLINEARSOLVER modules.
• Expanded package-provided direct linear solver (Dls) interfaces and scaled, preconditioned, iterative linear solver (Spils) interfaces to utilize generic SUNMATRIX and SUNLINEARSOLVER objects.
• Removed package-specific, linear solver-specific, solver modules (e.g. CVDENSE, KINBAND, IDAKLU, ARKSPGMR) since their functionality is entirely replicated by the generic Dls/Spils interfaces and SUNLINEARSOLVER/SUNMATRIX modules.  The exception is CVDIAG, a diagonal approximate Jacobian solver available to CVODE and CVODES.
• Converted all SUNDIALS example problems to utilize new generic SUNMATRIX and SUNLINEARSOLVER objects, along with updated Dls and Spils linear solver interfaces.
• Added Spils interface routines to ARKode, CVODE, CVODES, IDA and IDAS to allow specification of a user-provided “JTSetup” routine. This change supports users who wish to set up data structures for the user-provided Jacobian-times-vector (“JTimes”) routine, and where the cost of one JTSetup setup per Newton iteration can be amortized between multiple JTimes calls.
• Two new NVECTOR modules added: for CUDA and RAJA support for GPU systems.  These vectors are supplied to provide very basic support for running on GPU architectures.  Users are advised that these vectors both move all data to the GPU device upon construction, and speedup will only be realized if the user also conducts the right-hand-side function evaluation on the device. In addition, these vectors assume the problem fits on one GPU. For further information about RAJA, users are referred to the web site, https://software.llnl.gov/RAJA/.
• Addition of sunindextype option for 32- or 64-bit integer data index types within all SUNDIALS structures.
• Sunindextype can be int64_t or int32_t or long long int and int depending on machine support for portable types.
• The Fortran interfaces continue to use long_int for indices, except for their sparse matrix interface that now uses the new sunindextype.
• Includes interfaces to PETSc, hypre, SuperLU_MT, and KLU with either 64-bit or 32-bit capabilities depending how the user configures SUNDIALS.
• Temporary vectors were removed from preconditioner setup and solve routines for all packages.  It is assumed that all necessary data for user-provided preconditioner operations will be allocated and stored in user-provided data structures.
• The file include/sundials_fconfig.h was added.  This file contains SUNDIALS type information for use in Fortran programs.
• Added support for many xSDK-compliant build system keys.
• The xSDK is a movement in scientific software to provide a foundation for the rapid and efficient production of high-quality, sustainable extreme-scale scientific applications.
• Added functions SUNDIALSGetVersion and SUNDIALSGetVersionNumber to
get SUNDIALS release version information at runtime.

• To avoid potential namespace conflicts, the macros defining booleantype values TRUE and FALSE have been changed to SUNTRUE and SUNFALSE respectively.

• In build system:
• Added separate BLAS_ENABLE and BLAS_LIBRARIES CMake variables.
• Additional error checking during CMake configuration.
• Fixed minor CMake bugs.
• Renamed CMake options to enable/disable examples for greater clarity and added option to enable/disable Fortran 77 examples:
• Changed EXAMPLES_ENABLE to EXAMPLES_ENABLE_C.
• Changed CXX_ENABLE to EXAMPLES_ENABLE_CXX.
• Changed F90_ENABLE to EXAMPLES_ENABLE_F90.
• Corrections and additions to all User Guides.
• Bug fixes
• In CVodeFree, now call lfree() unconditionally (if non-NULL).

### What’s new in v2.9.0?

• New features and/or enhancements
• Two new NVECTOR modules added: for Hypre ParVector and PETSc.
• In vector API, added new required function, N_VGetVectorID.
• Upgrades to sparse solver interfaces; now support CSR matrix type with KLU solver.
• Example codes were changed from using NV_DATA macro to using N_VGetArrayPointer_* when using the native vectors shipped with SUNDIALS.
• In FCVODE, added fcvRoberts_klu.f and fcvRoberts_sps.f fortran sparse direct solver examples.
• Updated to return integers from linear solver and preconditioner ‘free’ functions.
• Bug fixes
• In FCVODE, fixed argument order bugs in FCVKLU and FCVSUPERLUMT linear solver interfaces.
• Fixed memory leak in banded preconditioner interface.
• Fixed some examples w.r.t. switch to new macro/function names SUNRexp etc.
• Various minor fixes to installation-related files.
• Corrected name N_VCloneEmptyVectorArray to N_VCloneVectorArrayEmpty in all documentation files.
• In FCVODE, added missing Fortran interface routines so that users can supply the sparse Jacobian routine.
• Minor corrections and additions to User Guide, including removal of references to specific NVECTOR names in usage skeletons.

### What’s new in v2.8.0?

• New features
• Added interface to the sparse direct solver KLU.
• Bug fixes
• Fixed minor bug in cvRootfind involving rootdir input.
• Fixed line setting smu in CVLapackBand.
• Changes to the FCVODE module
• In optional input routines FCVSETIIN and FCVSETRIN, removed the optional fourth argument key_length.
• Revised integer declarations in all examples so that those which must match a C type long int are declared INTEGER*8.
• Changes related to the build system
• Dropped support and documentation of the Autotools mode of installation.

### What’s new in v2.7.0?

• Bug fixes
• logic in CVSetTqBDF changed to avoid a divide by zero.
• linear solver memory set to zero after being created.
• linear solver memory is freed on an error return.
• Changes to user interface
• Problem size and related integers (bandwidth parameters etc.) all have type long int, except for those in user calls specifying BLAS/LAPACK routines.

### What’s new in v2.6.0?

• New features
• new linear solver module, based on Blas and Lapack for both dense and banded matrices.
• option to specify which direction of zero-crossing is to be monitored while performing rootfinding.
• Changes to user interface
• reorganization of all linear solver modules into two families (besides the existing family of scaled preconditioned iterative linear solvers, the direct solvers, including the new Lapack-based ones, were also organized into a direct family).
• maintaining a single pointer to user data, optionally specified through a Set-type function.
• general streamlining of the preconditioner modules distributed with the solver.

### What’s new in v2.5.0?

• Bug fixes
• fixed bug in final stopping times to resolve potential conflicts when tout is close to tstop.
• Changes related to the build system
• rearranged the entire SUNDIALS source tree.
• all exported header files are now installed in separate subdirectories of the installtion include directory.
• header files are included now by specifying the relative path (e.g. #include <cvode/cvode.h>).

### What’s new in v2.4.0?

• New features
• added CVSPBCG interface module to allow CVODE to interface with the shared SPBCG (scaled preconditioned Bi-CGSTAB) linear solver module.
• added CVSPTFQMR interface module to allow CVODE to interface with the shared SPTFQMR (scaled preconditioned TFQMR) linear solver module.
• added support for SPBCG and SPTFQMR to the CVBBDPRE and CVBANDPRE preconditioner modules.
• added support for interpreting failures in user-supplied functions.
• Changes to user interface
• changed argument of CVodeFree, CVBandPrecFree, and CVBBDPrecFree to be the address of the respective memory block pointer, so that its NULL value is propagated back to the calling function.
• added CVSPBCG module which defines appropriate CVSpbcg* functions to allow CVODE to interface with the shared SPBCG linear solver module.
• added CVBBDSpbcg function to CVBBDPRE module and CVBPSpbcg function to CVBANDPRE module to support SPBCG linear solver module.
• added CVBBDSptfqmr function to CVBBDPRE module and CVBPSptfqmr function to CVBANDPRE module to support SPTFQMR linear solver module.
• changed function type names to accomodate all the Scaled Preconditioned Iterative Linear Solvers now available:
CVSpgmrJactimesVecFn -> CVSpilsJacTimesVecFn
CVSpgmrPrecSetupFn -> CVSpilsPrecSetupFn
CVSpgmrPrecSolveFn -> CVSpilsPrecSolveFn
• changed function types so that all user-supplied functions return an integer flag.
• added option for user-supplied error handler function.
• changed some names for CVBANDPRE and CVBBDPRE function outputs.
• renamed all exported header files (except for cvode.h, all header files have the prefix cvode_).
• changed naming scheme for CVODE examples.
• Changes to the FCVODE module
• optional inputs are now set using routines FCVSETIIN (integer inputs) and FCVSETRIN (real inputs) through pairs key-value. Optional outputs are still obtained from two arrays (IOUT and ROUT), owned by the user and passed as arguments to FCVMALLOC. Note that the argument OPTIN was removed from FCVMALLOC.
• changed the prototypes of user-supplied functions so that they all return an error flag as their last argument.
• the arguments OPTIN, IOPT, and ROPT were removed from FCVREINIT.
• Changes related to the build system
• updated configure script and Makefiles for Fortran examples to avoid C++ compiler errors (now use CC and MPICC to link only if necessary).
• the main CVODE header file (cvode.h) is still exported to the install include directory. However, all other CVODE header files are exported into a cvode subdirectory of the install include directory.
• the CVODE library now contains all shared object files (there is no separate libsundials_shared library any more).

### What’s new in v2.3.0?

• New features
• added option for user-provided error weight computation function (of type CVEwtFn specified through CVodeSetEwtFn).
• Changes to user interface
• CVODE now stores tolerances through values rather than references (to resolve potential scoping issues).
• CVODE now passes information back to the user through values rather than references (error weights, estimated local errors, root info).
• CVodeMalloc, CVodeReInit, CVodeSetTolerances: added option itol=CV_WF to indicate user-supplied function for computing the error weights; reltol is now declared as realtype. Note that it is now illegal to call CVodeSetTolerances before CVodeMalloc. It is now legal to deallocate the absolute tolerance N_Vector right after its use.
• CVodeGetErrorWeights: the user is now responsible for allocating space for the N_Vector in which error weights will be copied.
• CVodeGetEstLocalErrors: the user is now responsible for allocating space for the N_Vector in which estimated local errors will be copied.
• CVodeGetRootInfo: the user is now responsible for allocating space for the int array in which root information will be copied.
• Passing a value of 0 for the maximum step size, the minimum step size, or for maxsteps results in the solver using the corresponding default value (infinity, 0, 500, respectively).
• Several optional input functions were combined into a single one (CVodeRootInit and CvodeSetGdata, CVDenseSetJacFn and CVDenseSetJacData, CVBandSetJacFn and CVBandSetJacData, CVSpgmrSetPrecSolveFn and CVSpgmrSetPrecSetFn and CVSpgmrSetPrecData, CVSpgmrSetJacTimesVecFn and CVSpgmrSetJacData).
• Changes to the FCVODE module
• Added option for user-supplied error weight computation subroutine (FCVEWT). Use FCVEWTSET to indicate that FCVEWT is provided.
• Due to the changes to the main solver, if FCVPSOL is provided then FCVPSET must also be defined, even if it is empty.

### What’s new in v2.2.2?

• Bug fixes
• fixed bug in CVode function: Initial setting of tretlast = *tret = tn removed (correcting erroneous behavior at first call to the rootfinding function CVRcheck3).
• Removed redundant setting of tretlast = *tret = tn at CLOSE_ROOTS return from CVode.
• Changes to documentation
• added section with numerical values of all input and output solver constants.
• added more detailed notes on the type of absolute tolerances.
• added more details on ownership of memory for the array returned by CVodeGetRootInfo.
• Changes related to the build system
• fixed autoconf-related bug to allow configuration with the PGI Fortran compiler.
• modified to use customized detection of the Fortran name mangling scheme (autoconf’s AC_F77_WRAPPERS routine is problematic on some platforms).
• added –with-mpi-flags as a configure option to allow user to specify MPI-specific flags.
• updated Makefiles for Fortran examples to avoid C++ compiler errors (now use CC and MPICC to link).

### What’s new in v2.2.1?

• Changes related to the build system
• changed order of compiler directives in header files to avoid compilation errors when using a C++ compiler.
• changed method of generating sundials_config.h to avoid potential warnings of redefinition of preprocessor symbols.

### What’s new in v2.2.0?

• New features
• added option to specify a value of the independent variable (time) past which the integration is never to proceed.
• added option to disable all error messages.
• Changes related to the NVECTOR module
• removed machEnv, redefined table of vector operations (now contained in the N_Vector structure itself).
• all CVODE functions create new N_Vector variables through cloning, using an N_Vector passed by the user as a template.
• Changes to type names and CVODE constants
• removed type ‘integertype’; instead use int or long int, as appropriate.
• restructured the list of return values from the various CVODE functions.
• changed all CVODE constants (inputs and return values) to have the prefix ‘CV_’ (e.g. CV_SUCCESS).
• renamed various function types to have the prefix ‘CV’ (e.g. CVRhsFn).
• Changes to optional input/ouput
• added CVodeSet* and CVodeGet* functions for optional inputs/outputs, replacing the arrays iopt and ropt.
• added new optional inputs (e.g. maximum number of Newton iterations, maximum number of convergence failures, etc).
• the value of the last return flag from any function within a linear solver module can be obtained as an optional output (e.g. CVDenseGetLastFlag).
• Changes to user-callable functions
• added new function CVodeCreate which initializes the CVODE solver object and returns a pointer to the CVODE memory block.
• removed N (problem size) from all functions except the initialization functions for the direct linear solvers (CVDense and CVBand).
• shortened argument lists of most CVODE functions (the arguments that were dropped can now be specified through CVodeSet* functions).
• removed reinitialization functions for band/dense/SPGMR linear solvers (same functionality can be obtained using CV*Set* functions).
• in CVBBDPRE, added a new function, CVBBDSpgmr to initialize the SPGMR linear solver with the BBD preconditioner.
• function names changed in CVBANDPRE and CVBBDPRE for uniformity.
• Changes to user-supplied functions
• removed N (probem dimension) from argument lists.
• shortened argument lists for user dense/band/SPGMR Jacobian routines.
• in CVSPGMR, shortened argument lists for user preconditioner functions.
• Changes to the FCVODE module
• revised to use underscore and precision flags at compile time (from configure).
• reorganized FCVODE into fewer files.
• added tstop, one-step, and STALD options, and interfaces to CVBANDPRE and rootfinding capabilities.
• use CV*Set* and CV*Get* functions from CVODE (although the optional I/O is still communicated to the user of FCVODE through arrays IOPT and ROPT).
• added new optional inputs and outputs (e.g.tstop, nlscoef, maxnef, maxcor, maxncf, etc.) and rearranged locations in IOPT and ROPT for uniformity.