Cantera  3.0.0
Loading...
Searching...
No Matches
ResidJacEval.cpp
Go to the documentation of this file.
1//! @file ResidJacEval.cpp
2
3// This file is part of Cantera. See License.txt in the top-level directory or
4// at https://cantera.org/license.txt for license and copyright information.
5
6#define CT_SKIP_DEPRECATION_WARNINGS
9
10namespace Cantera
11{
13 m_atol(atol)
14{
15 warn_deprecated("class ResidJacEval", "To be removed after Cantera 3.0");
16}
17
19{
20 return neq_;
21}
22
23void ResidJacEval::setAtol(double atol)
24{
25 m_atol = atol;
26 if (m_atol <= 0.0) {
27 throw CanteraError("ResidJacEval::setAtol",
28 "atol must be greater than zero");
29 }
30}
31
32int ResidJacEval::getInitialConditions(double t0, double* const y,
33 double* const ydot)
34{
35 for (int i = 0; i < neq_; i++) {
36 y[i] = 0.0;
37 }
38 if (ydot) {
39 for (int i = 0; i < neq_; i++) {
40 ydot[i] = 0.0;
41 }
42 }
43 return 1;
44}
45
46void ResidJacEval::user_out2(const int ifunc, const double t,
47 const double deltaT, const double* y,
48 const double* ydot)
49{
50}
51
52void ResidJacEval::user_out(const int ifunc, const double t,
53 const double* y, const double* ydot)
54{
55 user_out2(ifunc, t, 0.0, y, ydot);
56}
57
59 const double delta_t,
60 const double* y,
61 const double* ydot)
62{
63 return 1;
64}
65
67 const double* const ySoln,
68 const double* const ySolnDot,
69 double* const deltaYSoln,
70 const double* const solnWeights)
71{
72 if (!solnWeights) {
73 for (int i = 0; i < neq_; i++) {
74 deltaYSoln[i] = m_atol + fabs(1.0E-6 * ySoln[i]);
75 }
76 } else {
77 for (int i = 0; i < neq_; i++) {
78 deltaYSoln[i] = std::max(1.0E-2 * solnWeights[i], 1.0E-6 * fabs(ySoln[i]));
79 }
80 }
81 return 1;
82}
83
84void ResidJacEval::calcSolnScales(const double t,
85 const double* const ysoln,
86 const double* const ysolnOld,
87 double* const ysolnScales)
88{
89 if (ysolnScales && ysolnScales[0] == 0.0) {
90 for (int i = 0; i < neq_; i++) {
91 ysolnScales[i] = 1.0;
92 }
93 }
94}
95
96double ResidJacEval::filterNewStep(double t, const double* const ybase, double* const step)
97{
98 return 0.0;
99}
100
101double ResidJacEval::filterSolnPrediction(double t, double* const y)
102{
103 return 0.0;
104}
105
107 const double delta_t,
108 const double* const y,
109 const double* const ydot)
110{
111 return false;
112}
113
114int ResidJacEval::matrixConditioning(double* const matrix, const int nrows,
115 double* const rhs)
116{
117 return 1;
118}
119
120int ResidJacEval::evalResidNJ(const double t, const double deltaT,
121 const double* y, const double* ydot,
122 double* const resid,
123 const ResidEval_Type_Enum evalType,
124 const int id_x, const double delta_x)
125{
126 throw NotImplementedError("ResidJacEval::evalResidNJ");
127}
128
129int ResidJacEval::eval(const double t, const double* const y, const double* const ydot,
130 double* const r)
131{
132 double deltaT = -1.0;
133 return evalResidNJ(t, deltaT, y, ydot, r);
134}
135
136int ResidJacEval::evalJacobian(const double t, const double delta_t,
137 double cj, const double* const y,
138 const double* const ydot, DenseMatrix& J,
139 double* const resid)
140{
141 double* const* jac_colPts = J.colPts();
142 return evalJacobianDP(t, delta_t, cj, y, ydot, jac_colPts, resid);
143}
144
145int ResidJacEval::evalJacobianDP(const double t, const double delta_t,
146 const double c_j,
147 const double* const y,
148 const double* const ydot,
149 double* const* jac_colPts,
150 double* const resid)
151{
152 throw NotImplementedError("ResidJacEval::evalJacobianDP");
153}
154
155}
Dense, Square (not sparse) matrices.
Base class for exceptions thrown by Cantera classes.
A class for full (non-sparse) matrices with Fortran-compatible data storage, which adds matrix operat...
Definition DenseMatrix.h:55
An error indicating that an unimplemented function has been called.
virtual double filterNewStep(const double t, const double *const ybase, double *const step)
Filter the solution predictions.
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 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.
void setAtol(double atol)
Set a global value of the absolute tolerance.
int nEquations() const override
Return the number of equations in the equation system.
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 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 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 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.
ResidJacEval(double atol=1.0e-13)
Default constructor.
virtual double filterSolnPrediction(const double t, double *const y)
Filter the solution predictions.
int eval(const double t, const double *const y, const double *const ydot, double *const r) override
Evaluate the residual function.
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.
int getInitialConditions(const double t0, double *const y, double *const ydot) override
Fill in the initial conditions.
int neq_
Number of equations.
double m_atol
constant value of atol
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 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.
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
ResidEval_Type_Enum
Differentiates the type of residual evaluations according to functionality.
void warn_deprecated(const string &source, const AnyBase &node, const string &message)
A deprecation warning for syntax in an input file.
Definition AnyMap.cpp:1926