Virtual base class for ODE/DAE right-hand-side function evaluators. More...
#include <FuncEval.h>
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. | |
|
inlinevirtual |
Evaluate the right-hand-side ODE function.
Called by the integrator.
[in] | t | time. |
[in] | y | solution vector, length neq() |
[out] | ydot | rate of change of solution vector, length neq() |
[in] | p | sensitivity parameter vector, length nparams() |
Reimplemented in ImplicitSurfChem, and ReactorNet.
Definition at line 44 of file FuncEval.h.
|
inlinevirtual |
Evaluate the right-hand-side DAE function.
Called by the integrator.
[in] | t | time. |
[in] | y | solution vector, length neq() |
[out] | ydot | rate of change of solution vector, length neq() |
[in] | p | sensitivity parameter vector, length nparams() |
[out] | residual | the DAE residuals, length nparams() |
Reimplemented in ReactorNet.
Definition at line 56 of file FuncEval.h.
|
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.
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().
Definition at line 7 of file FuncEval.cpp.
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().
Definition at line 39 of file FuncEval.cpp.
|
inlinevirtual |
Evaluate the setup processes for the Jacobian preconditioner.
[in] | t | time. |
[in] | y | solution vector, length neq() |
gamma | the gamma in M=I-gamma*J |
Reimplemented in ReactorNet.
Definition at line 97 of file FuncEval.h.
|
inlinevirtual |
Evaluate the linear system Ax=b where A is the preconditioner.
[in] | rhs | right hand side vector used in linear system |
[out] | output | output vector for solution |
Reimplemented in ReactorNet.
Definition at line 108 of file FuncEval.h.
|
inlinevirtual |
Update the preconditioner based on already computed jacobian values.
Reimplemented in ReactorNet.
Definition at line 113 of file FuncEval.h.
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.
[in] | t | time. |
[in] | y | solution vector, length neq() |
gamma | the gamma in M=I-gamma*J |
Definition at line 80 of file FuncEval.cpp.
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.
[in] | rhs | right hand side vector used in linear system |
[out] | output | output vector for solution |
Definition at line 113 of file FuncEval.cpp.
|
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.
|
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.
|
pure virtual |
Number of equations.
Implemented in ImplicitSurfChem, and ReactorNet.
|
inlinevirtual |
Number of sensitivity parameters.
Reimplemented in ReactorNet.
Definition at line 156 of file FuncEval.h.
|
inline |
Enable or disable suppression of errors when calling eval()
Definition at line 161 of file FuncEval.h.
|
inline |
Get current state of error suppression.
Definition at line 166 of file FuncEval.h.
string getErrors | ( | ) | const |
Return a string containing the text of any suppressed errors.
Definition at line 71 of file FuncEval.cpp.
|
inline |
Clear any previously-stored suppressed errors.
Definition at line 174 of file FuncEval.h.
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.
vector<double> m_paramScales |
Scaling factors for each sensitivity parameter.
Definition at line 184 of file FuncEval.h.
|
protected |
Definition at line 188 of file FuncEval.h.
|
protected |
Errors occurring during function evaluations.
Definition at line 191 of file FuncEval.h.