| Cantera 3.0.0

Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
CVodesIntegrator Class Reference

Wrapper class for 'cvodes' integrator from LLNL. More...

`#include <CVodesIntegrator.h>`

Inheritance diagram for CVodesIntegrator:
[legend]

## Detailed Description

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.
void | setTolerances (double reltol, size_t n, double *abstol) override
| Set error tolerances.
void | setTolerances (double reltol, double abstol) override
| Set error tolerances.
void | setSensitivityTolerances (double reltol, double abstol) override
| Set the sensitivity error tolerances.
void | initialize (double t0, FuncEval &func) override
| Initialize the integrator for a new problem.
void | reinitialize (double t0, FuncEval &func) override
void | integrate (double tout) override
| Integrate the system of equations.
double | step (double tout) override
| Integrate the system of equations.
double & | solution (size_t k) override
| The current value of the solution of equation k.
double * | solution () override
| The current value of the solution of the system of equations.
double * | derivative (double tout, int n) override
| n-th derivative of the output function at time tout.
int | lastOrder () const override
| Order used during the last solution step.
int | nEquations () const override
| The number of equations.
int | nEvals () const override
| The number of function evaluations.
void | setMaxOrder (int n) override
| Set the maximum integration order that will be used.
void | setMethod (MethodType t) override
| Set the solution method.
void | setMaxStepSize (double hmax) override
| Set the maximum step size.
void | setMinStepSize (double hmin) override
| Set the minimum step size.
void | setMaxSteps (int nmax) override
| Set the maximum number of time-steps the integrator can take before reaching the next output time.
int | maxSteps () override
| Returns the maximum number of time-steps the integrator can take before reaching the next output time.
void | setMaxErrTestFails (int n) override
| Set the maximum permissible number of error test failures.
AnyMap | solverStats () const override
| Get solver stats from integrator.
void | setLinearSolverType (const string &linSolverType) override
| Set the linear solver type.
string | linearSolverType () const override
| Return the integrator problem type.
void | setBandwidth (int N_Upper, int N_Lower) override
int | nSensParams () override
double | sensitivity (size_t k, size_t p) override
void | setProblemType (int probtype) override
| Set the problem type.
string | getErrorInfo (int N)
| Returns a string listing the weighted error estimates associated with each solution component.
Public Member Functions inherited from Integrator
| Integrator ()
| Default Constructor.
virtual | ~Integrator ()
| Destructor.
virtual void | setPreconditioner (shared_ptr< PreconditionerBase > preconditioner)
| Set preconditioner used by the linear solver.
virtual void | preconditionerSolve (size_t stateSize, double *rhs, double *output)
| Solve a linear system Ax=b where A is the preconditioner.
virtual PreconditionerSide | preconditionerSide ()
| Return the side of the system on which the preconditioner is applied.
virtual shared_ptr< PreconditionerBase > | preconditioner ()
| Return preconditioner reference to object.
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.

## Protected Member Functions
void | applyOptions ()
| Applies user-specified options to the underlying CVODES solver.

## 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.

## Private Attributes
size_t | m_neq = 0
void * | m_cvode_mem = nullptr
SundialsContext | m_sundials_ctx
| SUNContext object for Sundials>=6.0.
void * | m_linsol = nullptr
| Sundials linear solver object.
void * | m_linsol_matrix = nullptr
| matrix used by Sundials
FuncEval * | m_func = nullptr
double | m_t0 = 0.0
double | m_time
| The current system time, corresponding to m_y.
double | m_tInteg
| The latest time reached by the integrator. May be greater than m_time.
N_Vector | m_y = nullptr
| The system state at m_time.
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.

## 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()
PreconditionerSide | m_prec_side = PreconditionerSide::NO_PRECONDITION
| Type of preconditioning used in applyOptions.

## Constructor & Destructor Documentation

## ◆ CVodesIntegrator()

CVodesIntegrator | ( |  | ) |

Constructor.

Default settings: dense Jacobian, no user-supplied Jacobian function, Newton iteration.

Definition at line 79 of file CVodesIntegrator.cpp.

## ◆ ~CVodesIntegrator()

~CVodesIntegrator | ( |  | ) |
| override

Definition at line 85 of file CVodesIntegrator.cpp.

## Member Function Documentation

## ◆ setTolerances() [1/2]

void setTolerances | ( | double | reltol,
|  | size_t | n,
|  | double * | abstol
| ) |  |
| override virtual

Set error tolerances.

Parameters

  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.

## ◆ setTolerances() [2/2]

void setTolerances | ( | double | reltol,
|  | double | abstol
| ) |  |
| override virtual

Set error tolerances.

Parameters

  reltol | scalar relative tolerance
  abstol | scalar absolute tolerance

Reimplemented from Integrator.

Definition at line 142 of file CVodesIntegrator.cpp.

## ◆ setSensitivityTolerances()

void setSensitivityTolerances | ( | double | reltol,
|  | double | abstol
| ) |  |
| override virtual

Set the sensitivity error tolerances.

Parameters

  reltol | scalar relative tolerance
  abstol | scalar absolute tolerance

Reimplemented from Integrator.

Definition at line 149 of file CVodesIntegrator.cpp.

## ◆ initialize()

void initialize | ( | double | t0,
|  | FuncEval & | func
| ) |  |
| override virtual

Initialize the integrator for a new problem.

Call after all options have been set.

Parameters

  t0 | initial time
  func | RHS evaluator object for system of equations.

Reimplemented from Integrator.

Definition at line 251 of file CVodesIntegrator.cpp.

## ◆ reinitialize()

void reinitialize | ( | double | t0,
|  | FuncEval & | func
| ) |  |
| override virtual

Reimplemented from Integrator.

Definition at line 335 of file CVodesIntegrator.cpp.

## ◆ integrate()

void integrate | ( | double | tout | ) |
| override virtual

Integrate the system of equations.

Parameters

  tout | Integrate to this time. Note that this is the absolute time value, not a time interval.

Reimplemented from Integrator.

Definition at line 495 of file CVodesIntegrator.cpp.

## ◆ step()

double step | ( | double | tout | ) |
| override virtual

Integrate the system of equations.

Parameters

  tout | integrate to this time. Note that this is the absolute time value, not a time interval.

Reimplemented from Integrator.

Definition at line 533 of file CVodesIntegrator.cpp.

## ◆ solution() [1/2]

double & solution | ( | size_t | k | ) |
| override virtual

The current value of the solution of equation k.

Reimplemented from Integrator.

Definition at line 116 of file CVodesIntegrator.cpp.

## ◆ solution() [2/2]

double * solution | ( |  | ) |
| override virtual

The current value of the solution of the system of equations.

Reimplemented from Integrator.

Definition at line 121 of file CVodesIntegrator.cpp.

## ◆ derivative()

double * derivative | ( | double | tout,
|  | int | n
| ) |  |
| override virtual

n-th derivative of the output function at time tout.

Reimplemented from Integrator.

Definition at line 553 of file CVodesIntegrator.cpp.

## ◆ lastOrder()

int lastOrder | ( |  | ) | const
| override virtual

Order used during the last solution step.

Reimplemented from Integrator.

Definition at line 560 of file CVodesIntegrator.cpp.

## ◆ nEquations()

int nEquations | ( |  | ) | const
| inline override virtual

The number of equations.

Reimplemented from Integrator.

Definition at line 46 of file CVodesIntegrator.h.

## ◆ nEvals()

int nEvals | ( |  | ) | const
| override virtual

The number of function evaluations.

Reimplemented from Integrator.

Definition at line 567 of file CVodesIntegrator.cpp.

## ◆ setMaxOrder()

void setMaxOrder | ( | int | n | ) |
| inline override virtual

Set the maximum integration order that will be used.

Reimplemented from Integrator.

Definition at line 50 of file CVodesIntegrator.h.

## ◆ setMethod()

void setMethod | ( | MethodType | t | ) |
| override virtual

Set the solution method.

Reimplemented from Integrator.

Definition at line 173 of file CVodesIntegrator.cpp.

## ◆ setMaxStepSize()

void setMaxStepSize | ( | double | hmax | ) |
| override virtual

Set the maximum step size.

Reimplemented from Integrator.

Definition at line 184 of file CVodesIntegrator.cpp.

## ◆ setMinStepSize()

void setMinStepSize | ( | double | hmin | ) |
| override virtual

Set the minimum step size.

Reimplemented from Integrator.

Definition at line 192 of file CVodesIntegrator.cpp.

## ◆ setMaxSteps()

void setMaxSteps | ( | int | nmax | ) |
| override virtual

Set the maximum number of time-steps the integrator can take before reaching the next output time.

Parameters

  nmax | The maximum number of steps, setting this value to zero disables this option.

Reimplemented from Integrator.

Definition at line 200 of file CVodesIntegrator.cpp.

## ◆ maxSteps()

int maxSteps | ( |  | ) |
| override virtual

Returns the maximum number of time-steps the integrator can take before reaching the next output time.

Reimplemented from Integrator.

Definition at line 208 of file CVodesIntegrator.cpp.

## ◆ setMaxErrTestFails()

void setMaxErrTestFails | ( | int | n | ) |
| override virtual

Set the maximum permissible number of error test failures.

Reimplemented from Integrator.

Definition at line 213 of file CVodesIntegrator.cpp.

## ◆ solverStats()

AnyMap solverStats | ( |  | ) | const
| override virtual

Get solver stats from integrator.

Reimplemented from Integrator.

Definition at line 574 of file CVodesIntegrator.cpp.

## ◆ setLinearSolverType()

void setLinearSolverType | ( | const string & | linSolverType | ) |
| inline override virtual

Set the linear solver type.

Parameters

  linSolverType | Type of the linear solver

Reimplemented from Integrator.

Definition at line 60 of file CVodesIntegrator.h.

## ◆ linearSolverType()

string linearSolverType | ( |  | ) | const
| inline override virtual

Return the integrator problem type.

Reimplemented from Integrator.

Definition at line 63 of file CVodesIntegrator.h.

## ◆ setBandwidth()

void setBandwidth | ( | int | N_Upper,
|  | int | N_Lower
| ) |  |
| inline override virtual

Reimplemented from Integrator.

Definition at line 66 of file CVodesIntegrator.h.

## ◆ nSensParams()

int nSensParams | ( |  | ) |
| inline override virtual

Reimplemented from Integrator.

Definition at line 70 of file CVodesIntegrator.h.

## ◆ sensitivity()

double sensitivity | ( | size_t | k,
|  | size_t | p
| ) |  |
| override virtual

Reimplemented from Integrator.

Definition at line 633 of file CVodesIntegrator.cpp.

## ◆ setProblemType()

void setProblemType | ( | int | probtype | ) |
| override virtual

Set the problem type.

Parameters

  probtype | Type of the problem

Deprecated:
  This function is to be removed along with the integer constants used in conditionals to set the problem type currently. This includes DENSE, JAC, NOJAC, BAND, and DIAG

Reimplemented from Integrator.

Definition at line 155 of file CVodesIntegrator.cpp.

## ◆ getErrorInfo()

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 656 of file CVodesIntegrator.cpp.

## ◆ applyOptions()

void applyOptions | ( |  | ) |
| protected

Applies user-specified options to the underlying CVODES solver.

Called during integrator initialization or reinitialization.

Definition at line 352 of file CVodesIntegrator.cpp.

## ◆ sensInit()

void sensInit | ( | double | t0,
|  | FuncEval & | func
| ) |  |
| private

Definition at line 221 of file CVodesIntegrator.cpp.

## ◆ checkError()

void checkError | ( | long | flag,
|  | const string & | ctMethod,
|  | const string & | cvodesMethod
| ) |  | const
| 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 681 of file CVodesIntegrator.cpp.

## Member Data Documentation

## ◆ m_error_message

string m_error_message

Error message information provide by CVodes.

Definition at line 83 of file CVodesIntegrator.h.

## ◆ m_neq

size_t m_neq = 0
| private

Definition at line 97 of file CVodesIntegrator.h.

## ◆ m_cvode_mem

void* m_cvode_mem = nullptr
| private

Definition at line 98 of file CVodesIntegrator.h.

## ◆ m_sundials_ctx

SundialsContext m_sundials_ctx
| private

SUNContext object for Sundials>=6.0.

Definition at line 99 of file CVodesIntegrator.h.

## ◆ m_linsol

void* m_linsol = nullptr
| private

Sundials linear solver object.

Definition at line 100 of file CVodesIntegrator.h.

## ◆ m_linsol_matrix

void* m_linsol_matrix = nullptr
| private

matrix used by Sundials

Definition at line 101 of file CVodesIntegrator.h.

## ◆ m_func

FuncEval* m_func = nullptr
| private

Definition at line 102 of file CVodesIntegrator.h.

## ◆ m_t0

double m_t0 = 0.0
| private

Definition at line 103 of file CVodesIntegrator.h.

## ◆ m_time

double m_time
| private

The current system time, corresponding to m_y.

Definition at line 106 of file CVodesIntegrator.h.

## ◆ m_tInteg

double m_tInteg
| private

The latest time reached by the integrator. May be greater than m_time.

Definition at line 109 of file CVodesIntegrator.h.

## ◆ m_y

N_Vector m_y = nullptr
| private

The system state at m_time.

Definition at line 112 of file CVodesIntegrator.h.

## ◆ m_abstol

N_Vector m_abstol = nullptr
| private

Definition at line 114 of file CVodesIntegrator.h.

## ◆ m_dky

N_Vector m_dky = nullptr
| private

Definition at line 115 of file CVodesIntegrator.h.

## ◆ m_type

string m_type = "DENSE"
| private

Definition at line 116 of file CVodesIntegrator.h.

## ◆ m_itol

int m_itol
| private

Definition at line 117 of file CVodesIntegrator.h.

## ◆ m_method

int m_method
| private

Definition at line 118 of file CVodesIntegrator.h.

## ◆ m_maxord

int m_maxord = 0
| private

Definition at line 119 of file CVodesIntegrator.h.

## ◆ m_reltol

double m_reltol = 1e-9
| private

Definition at line 120 of file CVodesIntegrator.h.

## ◆ m_abstols

double m_abstols = 1e-15
| private

Definition at line 121 of file CVodesIntegrator.h.

## ◆ m_reltolsens

double m_reltolsens = 1e-5
| private

Definition at line 122 of file CVodesIntegrator.h.

## ◆ m_abstolsens

double m_abstolsens = 1e-4
| private

Definition at line 123 of file CVodesIntegrator.h.

## ◆ m_nabs

size_t m_nabs = 0
| private

Definition at line 124 of file CVodesIntegrator.h.

## ◆ m_hmax

double m_hmax = 0.0
| private

Definition at line 125 of file CVodesIntegrator.h.

## ◆ m_hmin

double m_hmin = 0.0
| private

Definition at line 126 of file CVodesIntegrator.h.

## ◆ m_maxsteps

int m_maxsteps = 20000
| private

Definition at line 127 of file CVodesIntegrator.h.

## ◆ m_maxErrTestFails

int m_maxErrTestFails = 0
| private

Definition at line 128 of file CVodesIntegrator.h.

## ◆ m_yS

N_Vector* m_yS = nullptr
| private

Definition at line 129 of file CVodesIntegrator.h.

## ◆ m_np

size_t m_np = 0
| private

Definition at line 130 of file CVodesIntegrator.h.

## ◆ m_mupper

int m_mupper = 0
| private

Definition at line 131 of file CVodesIntegrator.h.

## ◆ m_mlower

int m_mlower = 0
| private

Definition at line 132 of file CVodesIntegrator.h.

## ◆ m_sens_ok

bool m_sens_ok = false
| private

Indicates whether the sensitivities stored in m_yS have been updated for at the current integrator time.

Definition at line 135 of file CVodesIntegrator.h.

The documentation for this class was generated from the following files:

- CVodesIntegrator.h
- CVodesIntegrator.cpp