Cantera 2.6.0

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]
Collaboration diagram for CVodesIntegrator:
[legend]

## Public Member Functions
| CVodesIntegrator ()
| Constructor. More...
virtual void | setTolerances (double reltol, size_t n, double *abstol)
| Set error tolerances. More...
virtual void | setTolerances (double reltol, double abstol)
| Set error tolerances. More...
virtual void | setSensitivityTolerances (double reltol, double abstol)
| Set the sensitivity error tolerances. More...
virtual void | setProblemType (int probtype)
| Set the problem type. More...
virtual void | initialize (double t0, FuncEval &func)
| Initialize the integrator for a new problem. More...
virtual void | reinitialize (double t0, FuncEval &func)
virtual void | integrate (double tout)
| Integrate the system of equations. More...
virtual doublereal | step (double tout)
| Integrate the system of equations. More...
virtual double & | solution (size_t k)
| The current value of the solution of equation k. More...
virtual double * | solution ()
| The current value of the solution of the system of equations. More...
virtual double * | derivative (double tout, int n)
| n-th derivative of the output function at time tout. More...
virtual int | lastOrder () const
| Order used during the last solution step. More...
virtual int | nEquations () const
| The number of equations. More...
virtual int | nEvals () const
| The number of function evaluations. More...
virtual void | setMaxOrder (int n)
| Set the maximum integration order that will be used. More...
virtual void | setMethod (MethodType t)
| Set the solution method. More...
virtual void | setMaxStepSize (double hmax)
| Set the maximum step size. More...
virtual void | setMinStepSize (double hmin)
| Set the minimum step size. More...
virtual void | setMaxSteps (int nmax)
| Set the maximum number of time-steps the integrator can take before reaching the next output time. More...
virtual int | maxSteps ()
| Returns the maximum number of time-steps the integrator can take before reaching the next output time. More...
virtual void | setMaxErrTestFails (int n)
| Set the maximum permissible number of error test failures. More...
virtual void | setBandwidth (int N_Upper, int N_Lower)
virtual int | nSensParams ()
virtual double | sensitivity (size_t k, size_t p)
virtual std::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 | setTolerances (doublereal reltol, size_t n, doublereal *abstol)
| Set error tolerances. More...
virtual void | setTolerances (doublereal reltol, doublereal abstol)
| Set error tolerances. More...
virtual void | setSensitivityTolerances (doublereal reltol, doublereal abstol)
| Set the sensitivity error tolerances. More...
virtual void | setProblemType (int probtype)
| Set the problem type. More...
virtual void | initialize (doublereal t0, FuncEval &func)
| Initialize the integrator for a new problem. More...
virtual void | reinitialize (doublereal t0, FuncEval &func)
virtual void | integrate (doublereal tout)
| Integrate the system of equations. More...
virtual doublereal | step (doublereal tout)
| Integrate the system of equations. More...
virtual doublereal & | solution (size_t k)
| The current value of the solution of equation k. More...
virtual doublereal * | solution ()
| The current value of the solution of the system of equations. More...
virtual double * | derivative (double tout, int n)
| n-th derivative of the output function at time tout. More...
virtual int | lastOrder () const
| Order used during the last solution step. More...
virtual int | nEquations () const
| The number of equations. More...
virtual int | nEvals () const
| The number of function evaluations. More...
virtual void | setMaxOrder (int n)
| Set the maximum integration order that will be used. More...
virtual void | setMethod (MethodType t)
| Set the solution method. More...
virtual void | setMaxStepSize (double hmax)
| Set the maximum step size. More...
virtual void | setMinStepSize (double hmin)
| Set the minimum step size. More...
virtual void | setMaxErrTestFails (int n)
| Set the maximum permissible number of error test failures. More...
virtual void | setMaxSteps (int nmax)
| Set the maximum number of time-steps the integrator can take before reaching the next output time. More...
virtual int | maxSteps ()
| Returns the maximum number of time-steps the integrator can take before reaching the next output time. More...
virtual void | setBandwidth (int N_Upper, int N_Lower)
virtual int | nSensParams ()
virtual double | sensitivity (size_t k, size_t p)

## Public Attributes
std::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)

## Private Attributes
size_t | m_neq
void * | m_cvode_mem
SundialsContext | m_sundials_ctx
| SUNContext object for Sundials>=6.0. More...
void * | m_linsol
| Sundials linear solver object. More...
void * | m_linsol_matrix
| matrix used by Sundials More...
FuncEval * | m_func
double | m_t0
double | m_time
| The current integrator time. More...
N_Vector | m_y
N_Vector | m_abstol
N_Vector | m_dky
int | m_type
int | m_itol
int | m_method
int | m_maxord
double | m_reltol
double | m_abstols
double | m_reltolsens
double | m_abstolsens
size_t | m_nabs
double | m_hmax
double | m_hmin
int | m_maxsteps
int | m_maxErrTestFails
N_Vector * | m_yS
size_t | m_np
int | m_mupper
int | m_mlower
bool | m_sens_ok
| Indicates whether the sensitivities stored in m_yS have been updated for at the current integrator time. More...

## Detailed Description

Wrapper class for 'cvodes' integrator from LLNL.

See also
  FuncEval.h. Classes that use CVodesIntegrator: ImplicitChem, ImplicitSurfChem, Reactor

Definition at line 26 of file CVodesIntegrator.h.

## Constructor & Destructor Documentation

## ◆ CVodesIntegrator()

CVodesIntegrator | ( |  | ) |

Constructor.

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

Definition at line 92 of file CVodesIntegrator.cpp.

## ◆ ~CVodesIntegrator()

~CVodesIntegrator | ( |  | ) |
| virtual

Definition at line 122 of file CVodesIntegrator.cpp.

## Member Function Documentation

## ◆ setTolerances() [1/2]

void setTolerances | ( | double | reltol,
|  | size_t | n,
|  | double * | abstol
| ) |  |
| 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 165 of file CVodesIntegrator.cpp.

## ◆ setTolerances() [2/2]

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

Set error tolerances.

Parameters

  reltol | scalar relative tolerance
  abstol | scalar absolute tolerance

Reimplemented from Integrator.

Definition at line 181 of file CVodesIntegrator.cpp.

## ◆ setSensitivityTolerances()

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

Set the sensitivity error tolerances.

Parameters

  reltol | scalar relative tolerance
  abstol | scalar absolute tolerance

Reimplemented from Integrator.

Definition at line 188 of file CVodesIntegrator.cpp.

## ◆ setProblemType()

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

Set the problem type.

Parameters

  probtype | Type of the problem

Reimplemented from Integrator.

Definition at line 194 of file CVodesIntegrator.cpp.

## ◆ initialize()

void initialize | ( | double | t0,
|  | FuncEval & | func
| ) |  |
| 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 278 of file CVodesIntegrator.cpp.

References FuncEval::clearErrors(), CVodesIntegrator::m_sundials_ctx, CVodesIntegrator::m_time, and FuncEval::neq().

## ◆ reinitialize()

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

Reimplemented from Integrator.

Definition at line 373 of file CVodesIntegrator.cpp.

## ◆ integrate()

void integrate | ( | double | tout | ) |
| 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 526 of file CVodesIntegrator.cpp.

References CVodesIntegrator::getErrorInfo(), FuncEval::getErrors(), CVodesIntegrator::m_error_message, CVodesIntegrator::m_sens_ok, and CVodesIntegrator::m_time.

## ◆ step()

double step | ( | double | tout | ) |
| 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 546 of file CVodesIntegrator.cpp.

References CVodesIntegrator::getErrorInfo(), FuncEval::getErrors(), CVodesIntegrator::m_error_message, CVodesIntegrator::m_sens_ok, and CVodesIntegrator::m_time.

## ◆ solution() [1/2]

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

The current value of the solution of equation k.

Reimplemented from Integrator.

Definition at line 155 of file CVodesIntegrator.cpp.

## ◆ solution() [2/2]

double * solution | ( |  | ) |
| virtual

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

Reimplemented from Integrator.

Definition at line 160 of file CVodesIntegrator.cpp.

## ◆ derivative()

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

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

Reimplemented from Integrator.

Definition at line 565 of file CVodesIntegrator.cpp.

References FuncEval::getErrors(), and CVodesIntegrator::m_error_message.

## ◆ lastOrder()

int lastOrder | ( |  | ) | const
| virtual

Order used during the last solution step.

Reimplemented from Integrator.

Definition at line 581 of file CVodesIntegrator.cpp.

## ◆ nEquations()

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

The number of equations.

Reimplemented from Integrator.

Definition at line 47 of file CVodesIntegrator.h.

## ◆ nEvals()

int nEvals | ( |  | ) | const
| virtual

The number of function evaluations.

Reimplemented from Integrator.

Definition at line 588 of file CVodesIntegrator.cpp.

## ◆ setMaxOrder()

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

Set the maximum integration order that will be used.

Reimplemented from Integrator.

Definition at line 51 of file CVodesIntegrator.h.

## ◆ setMethod()

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

Set the solution method.

Reimplemented from Integrator.

Definition at line 199 of file CVodesIntegrator.cpp.

References Cantera::Adams_Method, and Cantera::BDF_Method.

## ◆ setMaxStepSize()

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

Set the maximum step size.

Reimplemented from Integrator.

Definition at line 210 of file CVodesIntegrator.cpp.

## ◆ setMinStepSize()

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

Set the minimum step size.

Reimplemented from Integrator.

Definition at line 218 of file CVodesIntegrator.cpp.

## ◆ setMaxSteps()

void setMaxSteps | ( | int | nmax | ) |
| 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 226 of file CVodesIntegrator.cpp.

## ◆ maxSteps()

int maxSteps | ( |  | ) |
| virtual

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

Reimplemented from Integrator.

Definition at line 234 of file CVodesIntegrator.cpp.

## ◆ setMaxErrTestFails()

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

Set the maximum permissible number of error test failures.

Reimplemented from Integrator.

Definition at line 239 of file CVodesIntegrator.cpp.

## ◆ setBandwidth()

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

Reimplemented from Integrator.

Definition at line 60 of file CVodesIntegrator.h.

## ◆ nSensParams()

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

Reimplemented from Integrator.

Definition at line 64 of file CVodesIntegrator.h.

## ◆ sensitivity()

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

Reimplemented from Integrator.

Definition at line 595 of file CVodesIntegrator.cpp.

## ◆ getErrorInfo()

string getErrorInfo | ( | int | N | ) |
| virtual

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

References CVodesIntegrator::m_sundials_ctx.

Referenced by CVodesIntegrator::integrate(), and CVodesIntegrator::step().

## ◆ applyOptions()

void applyOptions | ( |  | ) |
| protected

Applies user-specified options to the underlying CVODES solver.

Called during integrator initialization or reinitialization.

Definition at line 389 of file CVodesIntegrator.cpp.

References CVodesIntegrator::m_linsol, CVodesIntegrator::m_linsol_matrix, and CVodesIntegrator::m_sundials_ctx.

## ◆ sensInit()

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

Definition at line 247 of file CVodesIntegrator.cpp.

## Member Data Documentation

## ◆ m_error_message

std::string m_error_message

Error message information provide by CVodes.

Definition at line 76 of file CVodesIntegrator.h.

Referenced by Cantera::cvodes_err(), CVodesIntegrator::derivative(), CVodesIntegrator::integrate(), and CVodesIntegrator::step().

## ◆ m_neq

size_t m_neq
| private

Definition at line 86 of file CVodesIntegrator.h.

## ◆ m_cvode_mem

void* m_cvode_mem
| private

Definition at line 87 of file CVodesIntegrator.h.

## ◆ m_sundials_ctx

SundialsContext m_sundials_ctx
| private

SUNContext object for Sundials>=6.0.

Definition at line 88 of file CVodesIntegrator.h.

Referenced by CVodesIntegrator::applyOptions(), CVodesIntegrator::getErrorInfo(), and CVodesIntegrator::initialize().

## ◆ m_linsol

void* m_linsol
| private

Sundials linear solver object.

Definition at line 89 of file CVodesIntegrator.h.

Referenced by CVodesIntegrator::applyOptions().

## ◆ m_linsol_matrix

void* m_linsol_matrix
| private

matrix used by Sundials

Definition at line 90 of file CVodesIntegrator.h.

Referenced by CVodesIntegrator::applyOptions().

## ◆ m_func

FuncEval* m_func
| private

Definition at line 91 of file CVodesIntegrator.h.

## ◆ m_t0

double m_t0
| private

Definition at line 92 of file CVodesIntegrator.h.

## ◆ m_time

double m_time
| private

The current integrator time.

Definition at line 93 of file CVodesIntegrator.h.

Referenced by CVodesIntegrator::initialize(), CVodesIntegrator::integrate(), and CVodesIntegrator::step().

## ◆ m_y

N_Vector m_y
| private

Definition at line 94 of file CVodesIntegrator.h.

## ◆ m_abstol

N_Vector m_abstol
| private

Definition at line 94 of file CVodesIntegrator.h.

## ◆ m_dky

N_Vector m_dky
| private

Definition at line 95 of file CVodesIntegrator.h.

## ◆ m_type

int m_type
| private

Definition at line 96 of file CVodesIntegrator.h.

## ◆ m_itol

int m_itol
| private

Definition at line 97 of file CVodesIntegrator.h.

## ◆ m_method

int m_method
| private

Definition at line 98 of file CVodesIntegrator.h.

## ◆ m_maxord

int m_maxord
| private

Definition at line 99 of file CVodesIntegrator.h.

## ◆ m_reltol

double m_reltol
| private

Definition at line 100 of file CVodesIntegrator.h.

## ◆ m_abstols

double m_abstols
| private

Definition at line 101 of file CVodesIntegrator.h.

## ◆ m_reltolsens

double m_reltolsens
| private

Definition at line 102 of file CVodesIntegrator.h.

## ◆ m_abstolsens

double m_abstolsens
| private

Definition at line 102 of file CVodesIntegrator.h.

## ◆ m_nabs

size_t m_nabs
| private

Definition at line 103 of file CVodesIntegrator.h.

## ◆ m_hmax

double m_hmax
| private

Definition at line 104 of file CVodesIntegrator.h.

## ◆ m_hmin

double m_hmin
| private

Definition at line 104 of file CVodesIntegrator.h.

## ◆ m_maxsteps

int m_maxsteps
| private

Definition at line 105 of file CVodesIntegrator.h.

## ◆ m_maxErrTestFails

int m_maxErrTestFails
| private

Definition at line 106 of file CVodesIntegrator.h.

## ◆ m_yS

N_Vector* m_yS
| private

Definition at line 107 of file CVodesIntegrator.h.

## ◆ m_np

size_t m_np
| private

Definition at line 108 of file CVodesIntegrator.h.

## ◆ m_mupper

int m_mupper
| private

Definition at line 109 of file CVodesIntegrator.h.

## ◆ m_mlower

int m_mlower
| private

Definition at line 109 of file CVodesIntegrator.h.

## ◆ m_sens_ok

bool m_sens_ok
| private

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

Definition at line 113 of file CVodesIntegrator.h.

Referenced by CVodesIntegrator::integrate(), and CVodesIntegrator::step().

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

- CVodesIntegrator.h
- CVodesIntegrator.cpp