Cantera
3.1.0a1
|
Wrapper class for 'cvodes' integrator from LLNL. More...
#include <CVodesIntegrator.h>
Wrapper class for 'cvodes' integrator from LLNL.
See FuncEval.h. Classes that use CVodesIntegrator: ImplicitSurfChem, ReactorNet
Definition at line 26 of file CVodesIntegrator.h.
Public Member Functions | |
CVodesIntegrator () | |
Constructor. More... | |
void | setTolerances (double reltol, size_t n, double *abstol) override |
Set error tolerances. More... | |
void | setTolerances (double reltol, double abstol) override |
Set error tolerances. More... | |
void | setSensitivityTolerances (double reltol, double abstol) override |
Set the sensitivity error tolerances. More... | |
void | initialize (double t0, FuncEval &func) override |
Initialize the integrator for a new problem. More... | |
void | reinitialize (double t0, FuncEval &func) override |
void | integrate (double tout) override |
Integrate the system of equations. More... | |
double | step (double tout) override |
Integrate the system of equations. More... | |
double & | solution (size_t k) override |
The current value of the solution of equation k. More... | |
double * | solution () override |
The current value of the solution of the system of equations. More... | |
double * | derivative (double tout, int n) override |
n-th derivative of the output function at time tout. More... | |
int | lastOrder () const override |
Order used during the last solution step. More... | |
int | nEquations () const override |
The number of equations. More... | |
int | nEvals () const override |
The number of function evaluations. More... | |
void | setMaxOrder (int n) override |
Set the maximum integration order that will be used. More... | |
void | setMethod (MethodType t) override |
Set the solution method. More... | |
void | setMaxStepSize (double hmax) override |
Set the maximum step size. More... | |
void | setMinStepSize (double hmin) override |
Set the minimum step size. More... | |
void | setMaxSteps (int nmax) override |
Set the maximum number of time-steps the integrator can take before reaching the next output time. More... | |
int | maxSteps () override |
Returns the maximum number of time-steps the integrator can take before reaching the next output time. More... | |
void | setMaxErrTestFails (int n) override |
Set the maximum permissible number of error test failures. More... | |
AnyMap | solverStats () const override |
Get solver stats from integrator. More... | |
void | setLinearSolverType (const string &linSolverType) override |
Set the linear solver type. More... | |
string | linearSolverType () const override |
Return the integrator problem type. More... | |
void | setBandwidth (int N_Upper, int N_Lower) override |
int | nSensParams () override |
double | sensitivity (size_t k, size_t p) override |
string | getErrorInfo (int N) |
Returns a string listing the weighted error estimates associated with each solution component. More... | |
Public Member Functions inherited from Integrator | |
Integrator () | |
Default Constructor. More... | |
virtual | ~Integrator () |
Destructor. More... | |
virtual void | setPreconditioner (shared_ptr< PreconditionerBase > preconditioner) |
Set preconditioner used by the linear solver. More... | |
virtual void | preconditionerSolve (size_t stateSize, double *rhs, double *output) |
Solve a linear system Ax=b where A is the preconditioner. More... | |
virtual PreconditionerSide | preconditionerSide () |
Return the side of the system on which the preconditioner is applied. More... | |
virtual shared_ptr< PreconditionerBase > | preconditioner () |
Return preconditioner reference to object. More... | |
virtual int | maxOrder () const |
virtual int | maxNonlinIterations () const |
virtual void | setMaxNonlinIterations (int n) |
virtual int | maxNonlinConvFailures () const |
virtual void | setMaxNonlinConvFailures (int n) |
virtual bool | algebraicInErrorTest () const |
virtual void | includeAlgebraicInErrorTest (bool yesno) |
Public Attributes | |
string | m_error_message |
Error message information provide by CVodes. More... | |
Protected Member Functions | |
void | applyOptions () |
Applies user-specified options to the underlying CVODES solver. More... | |
Private Member Functions | |
void | sensInit (double t0, FuncEval &func) |
void | checkError (long flag, const string &ctMethod, const string &cvodesMethod) const |
Check whether a CVODES method indicated an error. More... | |
Private Attributes | |
size_t | m_neq = 0 |
void * | m_cvode_mem = nullptr |
SundialsContext | m_sundials_ctx |
SUNContext object for Sundials>=6.0. More... | |
void * | m_linsol = nullptr |
Sundials linear solver object. More... | |
void * | m_linsol_matrix = nullptr |
matrix used by Sundials More... | |
FuncEval * | m_func = nullptr |
double | m_t0 = 0.0 |
double | m_time |
The current system time, corresponding to m_y. More... | |
double | m_tInteg |
The latest time reached by the integrator. May be greater than m_time. More... | |
N_Vector | m_y = nullptr |
The system state at m_time. More... | |
N_Vector | m_abstol = nullptr |
N_Vector | m_dky = nullptr |
string | m_type = "DENSE" |
int | m_itol |
int | m_method |
int | m_maxord = 0 |
double | m_reltol = 1e-9 |
double | m_abstols = 1e-15 |
double | m_reltolsens = 1e-5 |
double | m_abstolsens = 1e-4 |
size_t | m_nabs = 0 |
double | m_hmax = 0.0 |
double | m_hmin = 0.0 |
int | m_maxsteps = 20000 |
int | m_maxErrTestFails = 0 |
N_Vector * | m_yS = nullptr |
size_t | m_np = 0 |
int | m_mupper = 0 |
int | m_mlower = 0 |
bool | m_sens_ok = false |
Indicates whether the sensitivities stored in m_yS have been updated for at the current integrator time. More... | |
Additional Inherited Members | |
Protected Attributes inherited from Integrator | |
shared_ptr< PreconditionerBase > | m_preconditioner |
Pointer to preconditioner object used in integration which is set by setPreconditioner and initialized inside of ReactorNet::initialize() More... | |
PreconditionerSide | m_prec_side = PreconditionerSide::NO_PRECONDITION |
Type of preconditioning used in applyOptions. More... | |
CVodesIntegrator | ( | ) |
Constructor.
Default settings: dense Jacobian, no user-supplied Jacobian function, Newton iteration.
Definition at line 79 of file CVodesIntegrator.cpp.
|
overridevirtual |
Set error tolerances.
reltol | scalar relative tolerance |
n | Number of equations |
abstol | array of N absolute tolerance values |
Reimplemented from Integrator.
Definition at line 126 of file CVodesIntegrator.cpp.
|
overridevirtual |
Set error tolerances.
reltol | scalar relative tolerance |
abstol | scalar absolute tolerance |
Reimplemented from Integrator.
Definition at line 142 of file CVodesIntegrator.cpp.
|
overridevirtual |
Set the sensitivity error tolerances.
reltol | scalar relative tolerance |
abstol | scalar absolute tolerance |
Reimplemented from Integrator.
Definition at line 149 of file CVodesIntegrator.cpp.
|
overridevirtual |
Initialize the integrator for a new problem.
Call after all options have been set.
t0 | initial time |
func | RHS evaluator object for system of equations. |
Reimplemented from Integrator.
Definition at line 233 of file CVodesIntegrator.cpp.
|
overridevirtual |
Integrate the system of equations.
tout | Integrate to this time. Note that this is the absolute time value, not a time interval. |
Reimplemented from Integrator.
Definition at line 477 of file CVodesIntegrator.cpp.
|
overridevirtual |
Integrate the system of equations.
tout | integrate to this time. Note that this is the absolute time value, not a time interval. |
Reimplemented from Integrator.
Definition at line 515 of file CVodesIntegrator.cpp.
|
overridevirtual |
The current value of the solution of equation k.
Reimplemented from Integrator.
Definition at line 116 of file CVodesIntegrator.cpp.
|
overridevirtual |
The current value of the solution of the system of equations.
Reimplemented from Integrator.
Definition at line 121 of file CVodesIntegrator.cpp.
|
overridevirtual |
n-th derivative of the output function at time tout.
Reimplemented from Integrator.
Definition at line 535 of file CVodesIntegrator.cpp.
|
overridevirtual |
Order used during the last solution step.
Reimplemented from Integrator.
Definition at line 542 of file CVodesIntegrator.cpp.
|
inlineoverridevirtual |
The number of equations.
Reimplemented from Integrator.
Definition at line 46 of file CVodesIntegrator.h.
|
overridevirtual |
The number of function evaluations.
Reimplemented from Integrator.
Definition at line 549 of file CVodesIntegrator.cpp.
|
inlineoverridevirtual |
Set the maximum integration order that will be used.
Reimplemented from Integrator.
Definition at line 50 of file CVodesIntegrator.h.
|
overridevirtual |
Set the solution method.
Reimplemented from Integrator.
Definition at line 155 of file CVodesIntegrator.cpp.
|
overridevirtual |
Set the maximum step size.
Reimplemented from Integrator.
Definition at line 166 of file CVodesIntegrator.cpp.
|
overridevirtual |
Set the minimum step size.
Reimplemented from Integrator.
Definition at line 174 of file CVodesIntegrator.cpp.
|
overridevirtual |
Set the maximum number of time-steps the integrator can take before reaching the next output time.
nmax | The maximum number of steps, setting this value to zero disables this option. |
Reimplemented from Integrator.
Definition at line 182 of file CVodesIntegrator.cpp.
|
overridevirtual |
Returns the maximum number of time-steps the integrator can take before reaching the next output time.
Reimplemented from Integrator.
Definition at line 190 of file CVodesIntegrator.cpp.
|
overridevirtual |
Set the maximum permissible number of error test failures.
Reimplemented from Integrator.
Definition at line 195 of file CVodesIntegrator.cpp.
|
overridevirtual |
Get solver stats from integrator.
Reimplemented from Integrator.
Definition at line 556 of file CVodesIntegrator.cpp.
|
inlineoverridevirtual |
Set the linear solver type.
linSolverType | Type of the linear solver |
Reimplemented from Integrator.
Definition at line 60 of file CVodesIntegrator.h.
|
inlineoverridevirtual |
Return the integrator problem type.
Reimplemented from Integrator.
Definition at line 63 of file CVodesIntegrator.h.
string getErrorInfo | ( | int | N | ) |
Returns a string listing the weighted error estimates associated with each solution component.
This information can be used to identify which variables are responsible for integrator failures or unexpected small timesteps.
Definition at line 638 of file CVodesIntegrator.cpp.
|
protected |
Applies user-specified options to the underlying CVODES solver.
Called during integrator initialization or reinitialization.
Definition at line 334 of file CVodesIntegrator.cpp.
|
private |
Check whether a CVODES method indicated an error.
If so, throw an exception containing the method name and the error code stashed by the cvodes_err() function.
Definition at line 663 of file CVodesIntegrator.cpp.
string m_error_message |
Error message information provide by CVodes.
Definition at line 82 of file CVodesIntegrator.h.
|
private |
SUNContext object for Sundials>=6.0.
Definition at line 98 of file CVodesIntegrator.h.
|
private |
Sundials linear solver object.
Definition at line 99 of file CVodesIntegrator.h.
|
private |
matrix used by Sundials
Definition at line 100 of file CVodesIntegrator.h.
|
private |
The current system time, corresponding to m_y.
Definition at line 105 of file CVodesIntegrator.h.
|
private |
The latest time reached by the integrator. May be greater than m_time.
Definition at line 108 of file CVodesIntegrator.h.
|
private |
The system state at m_time.
Definition at line 111 of file CVodesIntegrator.h.
|
private |
Indicates whether the sensitivities stored in m_yS have been updated for at the current integrator time.
Definition at line 134 of file CVodesIntegrator.h.