8#ifndef CT_CVODESWRAPPER_H
9#define CT_CVODESWRAPPER_H
15#include "sundials/sundials_nvector.h"
35 void setTolerances(
double reltol,
size_t n,
double* abstol)
override;
39 void reinitialize(
double t0,
FuncEval& func)
override;
41 double step(
double tout)
override;
44 double*
derivative(
double tout,
int n)
override;
47 return static_cast<int>(m_neq);
49 int nEvals()
const override;
61 m_type = linSolverType;
66 void setBandwidth(
int N_Upper,
int N_Lower)
override {
70 int nSensParams()
override {
71 return static_cast<int>(m_np);
73 double sensitivity(
size_t k,
size_t p)
override;
90 void sensInit(
double t0,
FuncEval& func);
94 void checkError(
long flag,
const string& ctMethod,
const string& cvodesMethod)
const;
113 N_Vector m_abstol =
nullptr;
114 N_Vector m_dky =
nullptr;
115 string m_type =
"DENSE";
119 double m_reltol = 1e-9;
120 double m_abstols = 1e-15;
121 double m_reltolsens = 1e-5;
122 double m_abstolsens = 1e-4;
126 int m_maxsteps = 20000;
127 int m_maxErrTestFails = 0;
128 N_Vector* m_yS =
nullptr;
A map of string keys to values whose type can vary at runtime.
Wrapper class for 'cvodes' integrator from LLNL.
double step(double tout) override
Integrate the system of equations.
void setMaxStepSize(double hmax) override
Set the maximum step size.
double * solution() override
The current value of the solution of the system of equations.
N_Vector m_y
The system state at m_time.
void * m_cvode_mem
CVODES internal memory object.
void * m_linsol
Sundials linear solver object.
int nEvals() const override
The number of function evaluations.
int nEquations() const override
The number of equations.
CVodesIntegrator()
Constructor.
void setMaxOrder(int n) override
Set the maximum integration order that will be used.
double m_time
The current system time, corresponding to m_y.
bool m_sens_ok
Indicates whether the sensitivities stored in m_yS have been updated for at the current integrator ti...
int maxSteps() override
Returns the maximum number of time-steps the integrator can take before reaching the next output time...
SundialsContext m_sundials_ctx
SUNContext object for Sundials>=6.0.
void setLinearSolverType(const string &linSolverType) override
Set the linear solver type.
void checkError(long flag, const string &ctMethod, const string &cvodesMethod) const
Check whether a CVODES method indicated an error.
void setSensitivityTolerances(double reltol, double abstol) override
Set the sensitivity error tolerances.
void applyOptions()
Applies user-specified options to the underlying CVODES solver.
int lastOrder() const override
Order used during the last solution step.
void setMinStepSize(double hmin) override
Set the minimum step size.
void integrate(double tout) override
Integrate the system of equations.
void setTolerances(double reltol, size_t n, double *abstol) override
Set error tolerances.
double * derivative(double tout, int n) override
n-th derivative of the output function at time tout.
string m_error_message
Error message information provide by CVodes.
void setMaxErrTestFails(int n) override
Set the maximum permissible number of error test failures.
string linearSolverType() const override
Return the integrator problem type.
void setMaxSteps(int nmax) override
Set the maximum number of time-steps the integrator can take before reaching the next output time.
AnyMap solverStats() const override
Get solver stats from integrator.
void * m_linsol_matrix
matrix used by Sundials
double m_tInteg
The latest time reached by the integrator. May be greater than m_time.
void initialize(double t0, FuncEval &func) override
Initialize the integrator for a new problem.
string getErrorInfo(int N)
Returns a string listing the weighted error estimates associated with each solution component.
void setMethod(MethodType t) override
Set the solution method.
Virtual base class for ODE/DAE right-hand-side function evaluators.
Abstract base class for ODE system integrators.
A wrapper for managing a SUNContext object, need for Sundials >= 6.0.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
Namespace for the Cantera kernel.
MethodType
Specifies the method used to integrate the system of equations.