Cantera 2.6.0

Public Member Functions | Protected Attributes | List of all members
ResidEval Class Referenceabstract

Virtual base class for DAE residual function evaluators. More...

`#include <ResidEval.h>`

Inheritance diagram for ResidEval:
[legend]

## Public Member Functions
virtual void | constrain (const int k, const int flag)
| Constrain solution component k. More...
int | constraint (const int k) const
virtual void | initSizes ()
| Initialization function. More...
virtual void | setAlgebraic (const int k)
| Specify that solution component k is purely algebraic - that is, the derivative of this component does not appear in the residual function. More...
virtual bool | isAlgebraic (const int k)
virtual int | eval (const doublereal t, const doublereal *const y, const doublereal *const ydot, doublereal *const r)
| Evaluate the residual function. More...
virtual int | evalSS (const doublereal t, const doublereal *const y, doublereal *const r)
virtual int | evalSimpleTD (const doublereal t, const doublereal *const y, const doublereal *const yold, doublereal deltaT, doublereal *const r)
virtual int | getInitialConditions (const doublereal t0, doublereal *const y, doublereal *const ydot)
| Fill in the initial conditions. More...
virtual int | nEquations () const =0
| Return the number of equations in the equation system. More...
virtual void | writeSolution (int ievent, const double time, const double deltaT, const int time_step_num, const double *y, const double *ydot)
| Write out to a file or to standard output the current solution. More...
int | nparams () const
| Return the number of parameters in the calculation. More...

## Protected Attributes
vector_int | m_alg
| Mapping vector that stores whether a degree of freedom is a DAE or not. More...
std::map< int, int > | m_constrain

## Detailed Description

Virtual base class for DAE residual function evaluators.

Classes derived from ResidEval evaluate the residual function

\[ \vec{F}(t,\vec{y}, \vec{y^\prime}) \]

The DAE solver attempts to find a solution y(t) such that F = 0.

Definition at line 32 of file ResidEval.h.

## Constructor & Destructor Documentation

## ◆ ResidEval()

ResidEval | ( |  | ) |
| inline

Definition at line 35 of file ResidEval.h.

## ◆ ~ResidEval()

virtual ~ResidEval | ( |  | ) |
| inline virtual

Definition at line 36 of file ResidEval.h.

## Member Function Documentation

## ◆ constrain()

virtual void constrain | ( | const int | k,
|  | const int | flag
| ) |  |
| inline virtual

Constrain solution component k.

Possible values for 'flag' are:

- c_NONE no constraint
- c_GE_ZERO >= 0
- c_GT_ZERO > 0
- c_LE_ZERO <= 0
- c_LT_ZERO < 0

Definition at line 47 of file ResidEval.h.

## ◆ constraint()

int constraint | ( | const int | k | ) | const
| inline

Definition at line 50 of file ResidEval.h.

## ◆ initSizes()

virtual void initSizes | ( |  | ) |
| inline virtual

Initialization function.

Definition at line 55 of file ResidEval.h.

References ResidEval::m_alg, and ResidEval::nEquations().

Referenced by ResidEval::getInitialConditions(), and ResidEval::setAlgebraic().

## ◆ setAlgebraic()

virtual void setAlgebraic | ( | const int | k | ) |
| inline virtual

Specify that solution component k is purely algebraic - that is, the derivative of this component does not appear in the residual function.

Definition at line 64 of file ResidEval.h.

References ResidEval::initSizes(), and ResidEval::m_alg.

## ◆ isAlgebraic()

virtual bool isAlgebraic | ( | const int | k | ) |
| inline virtual

Definition at line 71 of file ResidEval.h.

## ◆ eval()

virtual int eval | ( | const doublereal | t,
|  | const doublereal *const | y,
|  | const doublereal *const | ydot,
|  | doublereal *const | r
| ) |  |
| inline virtual

Evaluate the residual function.

Called by the integrator.

Parameters

  t | time. (input)
  y | solution vector. (input)
  ydot | rate of change of solution vector. (input)
  r | residual vector (output)

Reimplemented in ResidJacEval.

Definition at line 82 of file ResidEval.h.

## ◆ evalSS()

virtual int evalSS | ( | const doublereal | t,
|  | const doublereal *const | y,
|  | doublereal *const | r
| ) |  |
| inline virtual

Definition at line 88 of file ResidEval.h.

## ◆ evalSimpleTD()

virtual int evalSimpleTD | ( | const doublereal | t,
|  | const doublereal *const | y,
|  | const doublereal *const | yold,
|  | doublereal | deltaT,
|  | doublereal *const | r
| ) |  |
| inline virtual

Definition at line 93 of file ResidEval.h.

## ◆ getInitialConditions()

virtual int getInitialConditions | ( | const doublereal | t0,
|  | doublereal *const | y,
|  | doublereal *const | ydot
| ) |  |
| inline virtual

Fill in the initial conditions.

Values for both the solution and the value of ydot may be provided.

Parameters

  [in] | t0 | Time
  [out] | y | Solution vector
  [out] | ydot | Rate of change of solution vector.

Returns
  a flag to indicate that operation is successful. 1 Means a successful operation -0 or neg value Means an unsuccessful operation

Reimplemented in ResidJacEval.

Definition at line 116 of file ResidEval.h.

References ResidEval::initSizes().

## ◆ nEquations()

virtual int nEquations | ( |  | ) | const
| pure virtual

Return the number of equations in the equation system.

Implemented in ResidJacEval.

Referenced by ResidEval::initSizes(), and ResidEval::writeSolution().

## ◆ writeSolution()

virtual void writeSolution | ( | int | ievent,
|  | const double | time,
|  | const double | deltaT,
|  | const int | time_step_num,
|  | const double * | y,
|  | const double * | ydot
| ) |  |
| inline virtual

Write out to a file or to standard output the current solution.

ievent is a description of the event that caused this function to be called.

Definition at line 131 of file ResidEval.h.

References ResidEval::nEquations(), Cantera::writelog(), and Cantera::writelogf().

## ◆ nparams()

int nparams | ( |  | ) | const
| inline

Return the number of parameters in the calculation.

This is the number of parameters in the sensitivity calculation. We have set this to zero and have included it for later expansion

Definition at line 156 of file ResidEval.h.

## Member Data Documentation

## ◆ m_alg

vector_int m_alg
| protected

Mapping vector that stores whether a degree of freedom is a DAE or not.

The first index is the equation number. The second index is 1 if it is a DAE, and zero if it is not.

Definition at line 166 of file ResidEval.h.

Referenced by ResidEval::initSizes(), and ResidEval::setAlgebraic().

## ◆ m_constrain

std::map<int, int> m_constrain
| protected

Definition at line 167 of file ResidEval.h.

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

- ResidEval.h