Cantera  3.1.0a4
Loading...
Searching...
No Matches
FuncEval Class Referenceabstract

Virtual base class for ODE/DAE right-hand-side function evaluators. More...

#include <FuncEval.h>

Inheritance diagram for FuncEval:
[legend]

Detailed Description

Virtual base class for ODE/DAE right-hand-side function evaluators.

Classes derived from FuncEval evaluate the right-hand-side function \( \vec{F}(t,\vec{y}) \) in

\[ \dot{\vec{y}} = \vec{F}(t,\vec{y}). \]

Definition at line 31 of file FuncEval.h.

Public Member Functions

virtual void eval (double t, double *y, double *ydot, double *p)
 Evaluate the right-hand-side ODE function.
 
virtual void evalDae (double t, double *y, double *ydot, double *p, double *residual)
 Evaluate the right-hand-side DAE function.
 
virtual void getConstraints (double *constraints)
 Given a vector of length neq(), mark which variables should be considered algebraic constraints.
 
int evalNoThrow (double t, double *y, double *ydot)
 Evaluate the right-hand side using return code to indicate status.
 
int evalDaeNoThrow (double t, double *y, double *ydot, double *residual)
 Evaluate the right-hand side using return code to indicate status.
 
virtual void preconditionerSetup (double t, double *y, double gamma)
 Evaluate the setup processes for the Jacobian preconditioner.
 
virtual void preconditionerSolve (double *rhs, double *output)
 Evaluate the linear system Ax=b where A is the preconditioner.
 
virtual void updatePreconditioner (double gamma)
 Update the preconditioner based on already computed jacobian values.
 
int preconditioner_setup_nothrow (double t, double *y, double gamma)
 Preconditioner setup that doesn't throw an error but returns a CVODES flag.
 
int preconditioner_solve_nothrow (double *rhs, double *output)
 Preconditioner solve that doesn't throw an error but returns a CVODES flag.
 
virtual void getState (double *y)
 Fill in the vector y with the current state of the system.
 
virtual void getStateDae (double *y, double *ydot)
 Fill in the vectors y and ydot with the current state of the system.
 
virtual size_t neq () const =0
 Number of equations.
 
virtual size_t nparams () const
 Number of sensitivity parameters.
 
void suppressErrors (bool suppress)
 Enable or disable suppression of errors when calling eval()
 
bool suppressErrors () const
 Get current state of error suppression.
 
string getErrors () const
 Return a string containing the text of any suppressed errors.
 
void clearErrors ()
 Clear any previously-stored suppressed errors.
 

Public Attributes

vector< double > m_sens_params
 Values for the problem parameters for which sensitivities are computed This is the array which is perturbed and passed back as the fourth argument to eval().
 
vector< double > m_paramScales
 Scaling factors for each sensitivity parameter.
 

Protected Attributes

bool m_suppress_errors = false
 
vector< string > m_errors
 Errors occurring during function evaluations.
 

Member Function Documentation

◆ eval()

virtual void eval ( double  t,
double *  y,
double *  ydot,
double *  p 
)
inlinevirtual

Evaluate the right-hand-side ODE function.

Called by the integrator.

Parameters
[in]ttime.
[in]ysolution vector, length neq()
[out]ydotrate of change of solution vector, length neq()
[in]psensitivity parameter vector, length nparams()

Reimplemented in ImplicitSurfChem, and ReactorNet.

Definition at line 44 of file FuncEval.h.

◆ evalDae()

virtual void evalDae ( double  t,
double *  y,
double *  ydot,
double *  p,
double *  residual 
)
inlinevirtual

Evaluate the right-hand-side DAE function.

Called by the integrator.

Parameters
[in]ttime.
[in]ysolution vector, length neq()
[out]ydotrate of change of solution vector, length neq()
[in]psensitivity parameter vector, length nparams()
[out]residualthe DAE residuals, length nparams()

Reimplemented in ReactorNet.

Definition at line 56 of file FuncEval.h.

◆ getConstraints()

virtual void getConstraints ( double *  constraints)
inlinevirtual

Given a vector of length neq(), mark which variables should be considered algebraic constraints.

Reimplemented in ReactorNet.

Definition at line 63 of file FuncEval.h.

◆ evalNoThrow()

int evalNoThrow ( double  t,
double *  y,
double *  ydot 
)

Evaluate the right-hand side using return code to indicate status.

Errors are indicated using the return value, rather than by throwing exceptions. This method is used when calling from a C-based integrator such as CVODES. Exceptions may either be stored or printed, based on the setting of suppressErrors().

Returns
0 for a successful evaluation; 1 after a potentially- recoverable error; -1 after an unrecoverable error.

Definition at line 7 of file FuncEval.cpp.

◆ evalDaeNoThrow()

int evalDaeNoThrow ( double  t,
double *  y,
double *  ydot,
double *  residual 
)

Evaluate the right-hand side using return code to indicate status.

Errors are indicated using the return value, rather than by throwing exceptions. This method is used when calling from a C-based integrator such as CVODES. Exceptions may either be stored or printed, based on the setting of suppressErrors().

Returns
0 for a successful evaluation; 1 after a potentially- recoverable error; -1 after an unrecoverable error.

Definition at line 39 of file FuncEval.cpp.

◆ preconditionerSetup()

virtual void preconditionerSetup ( double  t,
double *  y,
double  gamma 
)
inlinevirtual

Evaluate the setup processes for the Jacobian preconditioner.

Parameters
[in]ttime.
[in]ysolution vector, length neq()
gammathe gamma in M=I-gamma*J
Warning
This function is an experimental part of the Cantera API and may be changed or removed without notice.

Reimplemented in ReactorNet.

Definition at line 97 of file FuncEval.h.

◆ preconditionerSolve()

virtual void preconditionerSolve ( double *  rhs,
double *  output 
)
inlinevirtual

Evaluate the linear system Ax=b where A is the preconditioner.

Parameters
[in]rhsright hand side vector used in linear system
[out]outputoutput vector for solution
Warning
This function is an experimental part of the Cantera API and may be changed or removed without notice.

Reimplemented in ReactorNet.

Definition at line 108 of file FuncEval.h.

◆ updatePreconditioner()

virtual void updatePreconditioner ( double  gamma)
inlinevirtual

Update the preconditioner based on already computed jacobian values.

Reimplemented in ReactorNet.

Definition at line 113 of file FuncEval.h.

◆ preconditioner_setup_nothrow()

int preconditioner_setup_nothrow ( double  t,
double *  y,
double  gamma 
)

Preconditioner setup that doesn't throw an error but returns a CVODES flag.

It also helps as a first level of polymorphism which identifies the specific FuncEval, e.g., ReactorNet.

Parameters
[in]ttime.
[in]ysolution vector, length neq()
gammathe gamma in M=I-gamma*J
Warning
This function is an experimental part of the Cantera API and may be changed or removed without notice.

Definition at line 80 of file FuncEval.cpp.

◆ preconditioner_solve_nothrow()

int preconditioner_solve_nothrow ( double *  rhs,
double *  output 
)

Preconditioner solve that doesn't throw an error but returns a CVODES flag.

It also helps as a first level of polymorphism which identifies the specific FuncEval, e.g., ReactorNet.

Parameters
[in]rhsright hand side vector used in linear system
[out]outputoutput vector for solution
Warning
This function is an experimental part of the Cantera API and may be changed or removed without notice.

Definition at line 113 of file FuncEval.cpp.

◆ getState()

virtual void getState ( double *  y)
inlinevirtual

Fill in the vector y with the current state of the system.

Used for getting the initial state for ODE systems.

Reimplemented in ImplicitSurfChem, and ReactorNet.

Definition at line 142 of file FuncEval.h.

◆ getStateDae()

virtual void getStateDae ( double *  y,
double *  ydot 
)
inlinevirtual

Fill in the vectors y and ydot with the current state of the system.

Used for getting the initial state for DAE systems.

Reimplemented in ReactorNet.

Definition at line 148 of file FuncEval.h.

◆ neq()

virtual size_t neq ( ) const
pure virtual

Number of equations.

Implemented in ImplicitSurfChem, and ReactorNet.

◆ nparams()

virtual size_t nparams ( ) const
inlinevirtual

Number of sensitivity parameters.

Reimplemented in ReactorNet.

Definition at line 156 of file FuncEval.h.

◆ suppressErrors() [1/2]

void suppressErrors ( bool  suppress)
inline

Enable or disable suppression of errors when calling eval()

Definition at line 161 of file FuncEval.h.

◆ suppressErrors() [2/2]

bool suppressErrors ( ) const
inline

Get current state of error suppression.

Definition at line 166 of file FuncEval.h.

◆ getErrors()

string getErrors ( ) const

Return a string containing the text of any suppressed errors.

Definition at line 71 of file FuncEval.cpp.

◆ clearErrors()

void clearErrors ( )
inline

Clear any previously-stored suppressed errors.

Definition at line 174 of file FuncEval.h.

Member Data Documentation

◆ m_sens_params

vector<double> m_sens_params

Values for the problem parameters for which sensitivities are computed This is the array which is perturbed and passed back as the fourth argument to eval().

Definition at line 181 of file FuncEval.h.

◆ m_paramScales

vector<double> m_paramScales

Scaling factors for each sensitivity parameter.

Definition at line 184 of file FuncEval.h.

◆ m_suppress_errors

bool m_suppress_errors = false
protected

Definition at line 188 of file FuncEval.h.

◆ m_errors

vector<string> m_errors
protected

Errors occurring during function evaluations.

Definition at line 191 of file FuncEval.h.


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