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, span< const double > y, span< double > ydot, span< const double > p) |
| Evaluate the right-hand-side ODE function. | |
| virtual void | evalDae (double t, span< const double > y, span< const double > ydot, span< const double > p, span< double > residual) |
| Evaluate the right-hand-side DAE function. | |
| virtual void | getConstraints (span< double > constraints) |
| Given a vector of length neq(), mark which variables should be considered algebraic constraints. | |
| int | evalNoThrow (double t, span< const double > y, span< double > ydot) |
| Evaluate the right-hand side using return code to indicate status. | |
| int | evalDaeNoThrow (double t, span< const double > y, span< const double > ydot, span< double > residual) |
| Evaluate the right-hand side using return code to indicate status. | |
| virtual void | preconditionerSetup (double t, span< const double > y, double gamma) |
| Evaluate the setup processes for the Jacobian preconditioner. | |
| virtual void | preconditionerSolve (span< const double > rhs, span< 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, span< const double > y, double gamma) |
| Preconditioner setup that doesn't throw an error but returns a CVODES flag. | |
| int | preconditioner_solve_nothrow (span< const double > rhs, span< double > output) |
| Preconditioner solve that doesn't throw an error but returns a CVODES flag. | |
| virtual size_t | nRootFunctions () const |
| Number of event/root functions exposed to the integrator. | |
| virtual void | evalRootFunctions (double t, span< const double > y, span< double > gout) |
| Evaluate the event/root functions currently in play. | |
| int | evalRootFunctionsNoThrow (double t, span< const double > y, span< double > gout) |
| Wrapper for evalRootFunctions that converts exceptions to return codes. | |
| virtual void | getState (span< double > y) |
| Fill in the vector y with the current state of the system. | |
| virtual void | getStateDae (span< double > y, span< 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 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() |
| [in] | 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 57 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 64 of file FuncEval.h.
| int evalNoThrow | ( | double | t, |
| span< const double > | y, | ||
| span< 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, |
| span< const double > | y, | ||
| span< const double > | ydot, | ||
| span< 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 99 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 110 of file FuncEval.h.
|
inlinevirtual |
Update the preconditioner based on already computed jacobian values.
Reimplemented in ReactorNet.
Definition at line 115 of file FuncEval.h.
| int preconditioner_setup_nothrow | ( | double | t, |
| span< const 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 81 of file FuncEval.cpp.
| int preconditioner_solve_nothrow | ( | span< const double > | rhs, |
| span< 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 114 of file FuncEval.cpp.
|
inlinevirtual |
Number of event/root functions exposed to the integrator.
0 indicates root finding is disabled.
Reimplemented in ReactorNet.
Definition at line 144 of file FuncEval.h.
|
inlinevirtual |
Evaluate the event/root functions currently in play.
Integrators invoke this whenever root finding is enabled; implementations should fill gout with the function values.
| [in] | t | Time at which to evaluate the root functions |
| [in] | y | Current solution vector at time t of length neq() |
| [out] | gout | Array of length nRootFunctions() to be filled with the values of the root functions |
Reimplemented in ReactorNet.
Definition at line 157 of file FuncEval.h.
| int evalRootFunctionsNoThrow | ( | double | t, |
| span< const double > | y, | ||
| span< double > | gout | ||
| ) |
Wrapper for evalRootFunctions that converts exceptions to return codes.
Definition at line 147 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 ReactorNet.
Definition at line 166 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 172 of file FuncEval.h.
|
pure virtual |
Number of equations.
Implemented in ReactorNet.
|
inlinevirtual |
Number of sensitivity parameters.
Reimplemented in ReactorNet.
Definition at line 180 of file FuncEval.h.
|
inline |
Enable or disable suppression of errors when calling eval()
Definition at line 185 of file FuncEval.h.
|
inline |
Get current state of error suppression.
Definition at line 190 of file FuncEval.h.
| string getErrors | ( | ) | const |
Return a string containing the text of any suppressed errors.
Definition at line 72 of file FuncEval.cpp.
|
inline |
Clear any previously-stored suppressed errors.
Definition at line 198 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 205 of file FuncEval.h.
| vector<double> m_paramScales |
Scaling factors for each sensitivity parameter.
Definition at line 208 of file FuncEval.h.
|
protected |
Definition at line 212 of file FuncEval.h.
|
protected |
Errors occurring during function evaluations.
Definition at line 215 of file FuncEval.h.