Cantera
3.0.0
|
Wrappers for the function evaluators for Nonlinear solvers and Time steppers. More...
#include <ResidJacEval.h>
Wrappers for the function evaluators for Nonlinear solvers and Time steppers.
A class for full (non-sparse dense matrices with Fortran-compatible data storage. The class adds support for identifying what types of calls are made to the residual evaluator by adding the ResidEval_Type_Enum class.
Definition at line 62 of file ResidJacEval.h.
Public Member Functions | |
ResidJacEval (double atol=1.0e-13) | |
Default constructor. | |
int | nEquations () const override |
Return the number of equations in the equation system. | |
virtual int | evalResidNJ (const double t, const double delta_t, const double *const y, const double *const ydot, double *const resid, const ResidEval_Type_Enum evalType=Base_ResidEval, const int id_x=-1, const double delta_x=0.0) |
Evaluate the residual function. | |
int | eval (const double t, const double *const y, const double *const ydot, double *const r) override |
Evaluate the residual function. | |
int | getInitialConditions (const double t0, double *const y, double *const ydot) override |
Fill in the initial conditions. | |
virtual double | filterNewStep (const double t, const double *const ybase, double *const step) |
Filter the solution predictions. | |
virtual double | filterSolnPrediction (const double t, double *const y) |
Filter the solution predictions. | |
void | setAtol (double atol) |
Set a global value of the absolute tolerance. | |
virtual int | evalTimeTrackingEqns (const double t, const double delta_t, const double *const y, const double *const ydot) |
Evaluate the time tracking equations, if any. | |
virtual bool | evalStoppingCritera (const double t, const double delta_t, const double *const y, const double *const ydot) |
Evaluate any stopping criteria other than a final time limit. | |
virtual int | calcDeltaSolnVariables (const double t, const double *const y, const double *const ydot, double *const delta_y, const double *const solnWeights=0) |
Return a vector of delta y's for calculation of the numerical Jacobian. | |
virtual void | calcSolnScales (const double t, const double *const y, const double *const y_old, double *const yScales) |
Returns a vector of column scale factors that can be used to column scale Jacobians. | |
virtual void | user_out2 (const int ifunc, const double t, const double delta_t, const double *const y, const double *const ydot) |
This function may be used to create output at various points in the execution of an application. | |
virtual void | user_out (const int ifunc, const double t, const double *y, const double *ydot) |
This function may be used to create output at various points in the execution of an application. | |
virtual int | matrixConditioning (double *const matrix, const int nrows, double *const rhs) |
Multiply the matrix by another matrix that leads to better conditioning. | |
virtual int | evalJacobian (const double t, const double delta_t, double cj, const double *const y, const double *const ydot, DenseMatrix &J, double *const resid) |
Calculate an analytical Jacobian and the residual at the current time and values. | |
virtual int | evalJacobianDP (const double t, const double delta_t, double cj, const double *const y, const double *const ydot, double *const *jacobianColPts, double *const resid) |
Calculate an analytical Jacobian and the residual at the current time and values. | |
Public Member Functions inherited from ResidEval | |
virtual void | constrain (const int k, const int flag) |
Constrain solution component k. | |
int | constraint (const int k) const |
virtual void | initSizes () |
Initialization function. | |
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. | |
virtual bool | isAlgebraic (const int k) |
virtual int | eval (const double t, const double *const y, const double *const ydot, double *const r) |
Evaluate the residual function. | |
virtual int | evalSS (const double t, const double *const y, double *const r) |
virtual int | evalSimpleTD (const double t, const double *const y, const double *const yold, double deltaT, double *const r) |
virtual int | getInitialConditions (const double t0, double *const y, double *const ydot) |
Fill in the initial conditions. | |
virtual int | nEquations () const =0 |
Return the number of equations in the equation system. | |
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. | |
int | nparams () const |
Return the number of parameters in the calculation. | |
Protected Attributes | |
double | m_atol |
constant value of atol | |
int | neq_ |
Number of equations. | |
Protected Attributes inherited from ResidEval | |
vector< int > | m_alg |
Mapping vector that stores whether a degree of freedom is a DAE or not. | |
map< int, int > | m_constrain |
ResidJacEval | ( | double | atol = 1.0e-13 | ) |
Default constructor.
atol | Initial value of the global tolerance (defaults to 1.0E-13) |
Definition at line 12 of file ResidJacEval.cpp.
|
overridevirtual |
Return the number of equations in the equation system.
Implements ResidEval.
Definition at line 18 of file ResidJacEval.cpp.
|
virtual |
Evaluate the residual function.
t | Time (input) |
delta_t | The current value of the time step (input) |
y | Solution vector (input, do not modify) |
ydot | Rate of change of solution vector. (input, do not modify) |
resid | Value of the residual that is computed (output) |
evalType | Type of the residual being computed (defaults to Base_ResidEval) |
id_x | Index of the variable that is being numerically differenced to find the Jacobian (defaults to -1, which indicates that no variable is being differenced or that the residual doesn't take this issue into account) |
delta_x | Value of the delta used in the numerical differencing |
Definition at line 120 of file ResidJacEval.cpp.
|
overridevirtual |
Evaluate the residual function.
Called by the integrator.
t | time. (input) |
y | solution vector. (input) |
ydot | rate of change of solution vector. (input) |
r | residual vector (output) |
Reimplemented from ResidEval.
Definition at line 129 of file ResidJacEval.cpp.
|
overridevirtual |
Fill in the initial conditions.
Values for both the solution and the value of ydot may be provided.
[in] | t0 | Time |
[out] | y | Solution vector |
[out] | ydot | Rate of change of solution vector. |
Reimplemented from ResidEval.
Definition at line 32 of file ResidJacEval.cpp.
|
virtual |
Filter the solution predictions.
Codes might provide a predicted step change. This routine filters the predicted solution vector eliminating illegal directions.
t | Time (input) |
ybase | Solution vector (input, output) |
step | Proposed step in the solution that will be cropped |
Definition at line 96 of file ResidJacEval.cpp.
|
virtual |
Filter the solution predictions.
Codes might provide a predicted solution vector. This routine filters the predicted solution vector.
t | Time (input) |
y | Solution vector (input, output) |
Definition at line 101 of file ResidJacEval.cpp.
void setAtol | ( | double | atol | ) |
Set a global value of the absolute tolerance.
atol | Value of atol |
Definition at line 23 of file ResidJacEval.cpp.
|
virtual |
Evaluate the time tracking equations, if any.
Evaluate time integrated quantities that are calculated at the end of every successful time step. This call is made once at the end of every successful time step that advances the time. It's also made once at the start of the time stepping.
t | Time (input) |
delta_t | The current value of the time step (input) |
y | Solution vector (input, do not modify) |
ydot | Rate of change of solution vector. (input, do not modify) |
Definition at line 58 of file ResidJacEval.cpp.
|
virtual |
Evaluate any stopping criteria other than a final time limit.
If we are to stop the time integration for any reason other than reaching a final time limit, tout, provide a test here. This call is made at the end of every successful time step iteration
t | Time (input) |
delta_t | The current value of the time step (input) |
y | Solution vector (input, do not modify) |
ydot | Rate of change of solution vector. (input, do not modify) |
Definition at line 106 of file ResidJacEval.cpp.
|
virtual |
Return a vector of delta y's for calculation of the numerical Jacobian.
There is a default algorithm provided.
delta_y[i] = atol[i] + 1.0E-6 ysoln[i] delta_y[i] = atol[i] + MAX(1.0E-6 ysoln[i] * 0.01 * solnWeights[i])
t | Time (input) |
y | Solution vector (input, do not modify) |
ydot | Rate of change of solution vector. (input, do not modify) |
delta_y | Value of the delta to be used in calculating the numerical Jacobian |
solnWeights | Value of the solution weights that are used in determining convergence (default = 0) |
Definition at line 66 of file ResidJacEval.cpp.
|
virtual |
Returns a vector of column scale factors that can be used to column scale Jacobians.
Default to yScales[] = 1.0
t | Time (input) |
y | Solution vector (input, do not modify) |
y_old | Old Solution vector (input, do not modify) |
yScales | Value of the column scales |
Definition at line 84 of file ResidJacEval.cpp.
|
virtual |
This function may be used to create output at various points in the execution of an application.
ifunc | identity of the call 0 Initial call 1 Called at the end of every successful time step -1 Called at the end of every unsuccessful time step 2 Called at the end of every call to integrateRJE() |
t | Time (input) |
delta_t | The current value of the time step (input) |
y | Solution vector (input, do not modify) |
ydot | Rate of change of solution vector. (input) |
Definition at line 46 of file ResidJacEval.cpp.
|
virtual |
This function may be used to create output at various points in the execution of an application.
This routine calls user_out2().
ifunc | identity of the call |
t | Time (input) |
y | Solution vector (input, do not modify) |
ydot | Rate of change of solution vector. (input) |
Definition at line 52 of file ResidJacEval.cpp.
|
virtual |
Multiply the matrix by another matrix that leads to better conditioning.
Provide a left sided matrix that will multiply the current Jacobian, after scaling and lead to a better conditioned system. This routine is called just before the matrix is factored.
Original Problem: J delta_x = - Resid
New problem: M (J delta_x) = - M Resid
matrix | Pointer to the current Jacobian (if zero, it's already been factored) |
nrows | offsets for the matrix |
rhs | residual vector. This also needs to be LHS multiplied by M |
Definition at line 114 of file ResidJacEval.cpp.
|
virtual |
Calculate an analytical Jacobian and the residual at the current time and values.
Only called if the jacFormation method is set to analytical
t | Time (input) |
delta_t | The current value of the time step (input) |
cj | Coefficient of yprime used in the evaluation of the Jacobian |
y | Solution vector (input, do not modify) |
ydot | Rate of change of solution vector. (input, do not modify) |
J | Reference to the DenseMatrix object to be calculated (output) |
resid | Value of the residual that is computed (output) |
Definition at line 136 of file ResidJacEval.cpp.
|
virtual |
Calculate an analytical Jacobian and the residual at the current time and values.
Only called if the jacFormation method is set to analytical
t | Time (input) |
delta_t | The current value of the time step (input) |
cj | Coefficient of yprime used in the evaluation of the Jacobian |
y | Solution vector (input, do not modify) |
ydot | Rate of change of solution vector. (input, do not modify) |
jacobianColPts | Pointer to the vector of pts to columns of the DenseMatrix object to be calculated (output) |
resid | Value of the residual that is computed (output) |
Definition at line 145 of file ResidJacEval.cpp.
|
protected |
constant value of atol
Definition at line 304 of file ResidJacEval.h.
|
protected |
Number of equations.
Definition at line 307 of file ResidJacEval.h.