Cantera  4.0.0a2
Loading...
Searching...
No Matches
SteadyStateSystem.h
Go to the documentation of this file.
1//! @file SteadyStateSystem.h
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#ifndef CT_STEADYSTATESYSTEM_H
7#define CT_STEADYSTATESYSTEM_H
8
9#include <cmath>
10
12#include "cantera/base/AnyMap.h"
13#include "SystemJacobian.h"
14
15namespace Cantera
16{
17
18class Func1;
19class MultiNewton;
20
21//! Error thrown when time stepping cannot proceed and the steady-state solver
22//! should be given a chance to recover by other means.
24{
25public:
26 template <typename... Args>
27 TimeStepError(const string& func, const string& msg, const Args&... args) :
28 CanteraError(func, msg, args...) {}
29
30 string getClass() const override {
31 return "TimeStepError";
32 }
33};
34
35//! Base class for representing a system of differential-algebraic equations and solving
36//! for its steady-state response.
37//!
38//! @since New in %Cantera 3.2.
39//! @ingroup numerics
41{
42public:
44 virtual ~SteadyStateSystem();
45 SteadyStateSystem(const SteadyStateSystem&) = delete;
46 SteadyStateSystem& operator=(const SteadyStateSystem&) = delete;
47
48 //! Evaluate the residual function
49 //!
50 //! @param[in] x State vector
51 //! @param[out] r On return, contains the residual vector
52 //! @param rdt Reciprocal of the time step. if omitted, then the internally stored
53 //! value (accessible using the rdt() method) is used.
54 //! @param count Set to zero to omit this call from the statistics
55 virtual void eval(span<const double> x, span<double> r,
56 double rdt=-1.0, int count=1) = 0;
57
58 //! Evaluates the Jacobian at x0 using finite differences.
59 //!
60 //! The Jacobian is computed by perturbing each component of `x0`, evaluating the
61 //! residual function, and then estimating the partial derivatives numerically using
62 //! finite differences to determine the corresponding column of the Jacobian.
63 //!
64 //! @param x0 State vector at which to evaluate the Jacobian
65 virtual void evalJacobian(span<const double> x0) = 0;
66
67 //! Compute the weighted norm of `step`.
68 //!
69 //! The purpose is to measure the "size" of the step vector @f$ \Delta x @f$ in a
70 //! way that takes into account the relative importance or scale of different
71 //! solution components. Each component of the step vector is normalized by a weight
72 //! that depends on both the current magnitude of the solution vector and specified
73 //! tolerances. This makes the norm dimensionless and scaled appropriately, avoiding
74 //! issues where some components dominate due to differences in their scales. See
75 //! OneDim::weightedNorm() for a representative implementation.
76 virtual double weightedNorm(span<const double> step) const = 0;
77
78 //! Set the initial guess. Should be called before solve().
79 void setInitialGuess(span<const double> x);
80
81 //! Solve the steady-state problem, taking internal timesteps as necessary until
82 //! the Newton solver can converge for the steady problem.
83 //! @param loglevel Controls amount of diagnostic output.
84 void solve(int loglevel=0);
85
86 //! Get the converged steady-state solution after calling solve().
87 void getState(span<double> x) const;
88
89 //! Steady-state max norm (infinity norm) of the residual evaluated using solution
90 //! x. On return, array r contains the steady-state residual values.
91 double ssnorm(span<const double> x, span<double> r);
92
93 //! Transient max norm (infinity norm) of the residual evaluated using solution
94 //! x and the current timestep (rdt). On return, array r contains the
95 //! transient residual values.
96 double tsnorm(span<const double> x, span<double> r);
97
98 //! Total solution vector length;
99 size_t size() const {
100 return m_size;
101 }
102
103 //! Call to set the size of internal data structures after first defining the system
104 //! or if the problem size changes, for example after grid refinement.
105 //!
106 //! The #m_size variable should be updated before calling this method
107 virtual void resize();
108
109 //! Jacobian bandwidth.
110 size_t bandwidth() const {
111 return m_bw;
112 }
113
114 //! Get the name of the i-th component of the state vector
115 virtual string componentName(size_t i) const { return fmt::format("{}", i); }
116
117 //! Get header lines describing the column names included in a component label.
118 //! Headings should be aligned with items formatted in the output of
119 //! componentTableLabel(). Two lines are allowed. If only one is needed, the first
120 //! line should be blank.
121 virtual pair<string, string> componentTableHeader() const {
122 return {"", "component name"};
123 }
124
125 //! Get elements of the component name, aligned with the column headings given
126 //! by componentTableHeader().
127 virtual string componentTableLabel(size_t i) const { return componentName(i); }
128
129 //! Get the upper bound for global component *i* in the state vector
130 virtual double upperBound(size_t i) const = 0;
131
132 //! Get the lower bound for global component *i* in the state vector
133 virtual double lowerBound(size_t i) const = 0;
134
135 //! Return a reference to the Newton iterator.
137
138 //! Set the linear solver used to hold the Jacobian matrix and solve linear systems
139 //! as part of each Newton iteration.
140 void setLinearSolver(shared_ptr<SystemJacobian> solver);
141
142 //! Get the the linear solver being used to hold the Jacobian matrix and solve
143 //! linear systems as part of each Newton iteration.
144 shared_ptr<SystemJacobian> linearSolver() const { return m_jac; }
145
146 //! @name Solver statistics
147 //! Per-grid solver statistics, collected after each successful solve on a
148 //! grid. Times are wall-clock seconds.
149 //! @{
150
151 //! Return solver statistics as a map of per-grid arrays. Keys:
152 //! `grid_points`, `steps`, `residual_evals`, `residual_time`,
153 //! `jacobian_evals`, `jacobian_time`, `factorizations`, `factor_time`,
154 //! `linear_solves`, `solve_time`, `total_time`.
155 //!
156 //! This method is non-const because it calls saveStats() to flush
157 //! statistics for the current (possibly not-yet-committed) grid before
158 //! returning.
159 //!
160 //! An entry whose `total_time` is 0 corresponds to a grid where the solve
161 //! attempt failed (threw) before completing; its other timing fields will
162 //! also be partial.
164 saveStats();
165 return m_stats;
166 }
167
168 //! Commit statistics for the current grid into #m_stats and reset the
169 //! staging counters. A no-op unless at least one Jacobian evaluation and
170 //! one residual evaluation have occurred since the last commit.
171 virtual void saveStats();
172
173 //! Clear all saved solver statistics and reset the staging counters.
174 virtual void clearStats();
175
176 //! Record wall-clock time [s] spent factorizing the Jacobian. Called by
177 //! the Newton solver.
178 void recordFactorization(double wallTime) {
179 m_factorTime += wallTime;
181 }
182
183 //! Record wall-clock time [s] spent in a linear solve. Called by the
184 //! Newton solver.
185 void recordLinearSolve(double wallTime) {
186 m_solveTime += wallTime;
188 }
189
190 //! Update the transient term of the Jacobian (forming and factorizing
191 //! @f$ M = I - \gamma J @f$) and record the elapsed wall-clock time as a
192 //! factorization in the solver statistics. Used at every factorization site
193 //! so that `factor_time` accounts for steady and time-stepping factorizations
194 //! alike.
195 void factorizeJacobian();
196 //! @}
197
198 //! Reciprocal of the time step.
199 double rdt() const {
200 return m_rdt;
201 }
202
203 //! True if transient mode.
204 bool transient() const {
205 return (m_rdt != 0.0);
206 }
207
208 //! True if steady mode.
209 bool steady() const {
210 return (m_rdt == 0.0);
211 }
212
213 //! Prepare for time stepping beginning with solution *x* and timestep *dt*.
214 virtual void initTimeInteg(double dt, span<const double> x);
215
216 //! Prepare to solve the steady-state problem. After invoking this method,
217 //! subsequent calls to solve() will solve the steady-state problem. Sets the
218 //! reciprocal of the time step to zero, and, if it was previously non-zero, signals
219 //! that a new Jacobian will be needed.
220 virtual void setSteadyMode();
221
222 //! Access the vector indicating which equations contain a transient term.
223 //! Elements are 1 for equations with a transient terms and 0 otherwise.
224 vector<int>& transientMask() {
225 return m_mask;
226 }
227
228 //! Take time steps using Backward Euler.
229 //!
230 //! @param nsteps number of steps
231 //! @param dt initial step size
232 //! @param x current solution vector
233 //! @param r solution vector after time stepping
234 //! @param loglevel controls amount of printed diagnostics
235 //! @returns size of last timestep taken
236 double timeStep(int nsteps, double dt, span<double> x, span<double> r,
237 int loglevel);
238
239 //! Reset values such as negative species concentrations
240 virtual void resetBadValues(span<double> x) {}
241
242 //! @name Options
243 //! @{
244
245 //! Set the number of time steps to try when the steady Newton solver is
246 //! unsuccessful.
247 //! @param stepsize Initial time step size [s]
248 //! @param tsteps A sequence of time step counts to take after subsequent failures
249 //! of the steady-state solver. The last value in `tsteps` will be used again
250 //! after further unsuccessful solution attempts.
251 void setTimeStep(double stepsize, span<const int> tsteps);
252
253 //! Set the minimum time step allowed during time stepping
254 void setMinTimeStep(double tmin) {
255 m_tmin = tmin;
256 }
257
258 //! Set the maximum time step allowed during time stepping
259 void setMaxTimeStep(double tmax) {
260 m_tmax = tmax;
261 }
262
263 //! Sets a factor by which the time step is reduced if the time stepping fails.
264 //! The default value is 0.5.
265 //!
266 //! @param tfactor factor time step is multiplied by if time stepping fails
267 void setTimeStepFactor(double tfactor) {
268 m_tfactor = tfactor;
269 }
270
271 //! Set the growth factor used after successful timesteps when the Jacobian is
272 //! re-used.
273 //!
274 //! This factor is used directly by the `fixed-growth` strategy, and as the
275 //! accepted growth factor or upper bound for the other named strategies.
276 //!
277 //! The default value is 1.5, matching historical behavior.
278 //! @param tfactor Finite growth factor applied to successful timesteps;
279 //! must be >= 1.0.
280 void setTimeStepGrowthFactor(double tfactor) {
281 if (!std::isfinite(tfactor) || tfactor < 1.0) {
282 throw CanteraError("SteadyStateSystem::setTimeStepGrowthFactor",
283 "Time step growth factor must be finite and >= 1.0. Got {}.",
284 tfactor);
285 }
286 m_tstep_growth = tfactor;
287 }
288
289 //! Get the successful-step time step growth factor.
290 double timeStepGrowthFactor() const {
291 return m_tstep_growth;
292 }
293
294 //! Set the strategy used to grow the timestep after a successful step that
295 //! reuses the current Jacobian.
296 //!
297 //! Available options are:
298 //! - `fixed-growth`: Always apply timeStepGrowthFactor().
299 //! - `steady-norm`: Apply timeStepGrowthFactor() only if the steady-state
300 //! residual norm decreases.
301 //! - `transient-residual`: Apply timeStepGrowthFactor() only if the transient
302 //! residual norm decreases.
303 //! - `residual-ratio`: Scale the growth factor based on transient residual
304 //! improvement, capped by timeStepGrowthFactor().
305 //! - `newton-iterations`: Apply timeStepGrowthFactor() only if the most recent
306 //! Newton solve used at most 3 iterations.
307 //!
308 //! The default strategy is `fixed-growth`, which matches historical behavior.
309 void setTimeStepGrowthStrategy(const string& strategy);
310
311 //! Get the configured timestep growth strategy.
312 string timeStepGrowthStrategy() const;
313
314 //! Set the maximum number of timeteps allowed before successful steady-state solve
315 void setMaxTimeStepCount(int nmax) {
316 m_nsteps_max = nmax;
317 }
318
319 //! Get the maximum number of timeteps allowed before successful steady-state solve
320 int maxTimeStepCount() const {
321 return m_nsteps_max;
322 }
323 //! @}
324
325 //! Set the maximum number of steps that can be taken using the same Jacobian
326 //! before it must be re-evaluated.
327 //! @param ss_age Age limit during steady-state mode
328 //! @param ts_age Age limit during time stepping mode. If not specified, the
329 //! steady-state age is also used during time stepping.
330 void setJacAge(int ss_age, int ts_age=-1);
331
332 //! Set a function that will be called every time #eval is called.
333 //! Can be used to provide keyboard interrupt support in the high-level
334 //! language interfaces.
335 void setInterrupt(Func1* interrupt) {
336 m_interrupt = interrupt;
337 }
338
339 //! Set a function that will be called after each successful timestep. The
340 //! function will be called with the size of the timestep as the argument.
341 //! Intended to be used for observing solver progress for debugging
342 //! purposes.
343 void setTimeStepCallback(Func1* callback) {
344 m_time_step_callback = callback;
345 }
346
347 //! Configure perturbations used to evaluate finite difference Jacobian
348 //! @param relative Relative perturbation (multiplied by the absolute value of
349 //! each component). Default `1.0e-5`.
350 //! @param absolute Absolute perturbation (independent of component value).
351 //! Default `1.0e-10`.
352 //! @param threshold Threshold below which to exclude elements from the Jacobian
353 //! Default `0.0`.
354 void setJacobianPerturbation(double relative, double absolute, double threshold) {
355 m_jacobianRelPerturb = relative;
356 m_jacobianAbsPerturb = absolute;
357 m_jacobianThreshold = threshold;
358 }
359
360 //! Write solver debugging based on the specified log level.
361 //!
362 //! @see Sim1D::writeDebugInfo for a specific implementation of this capability.
363 virtual void writeDebugInfo(const string& header_suffix, const string& message,
364 int loglevel, int attempt_counter) {}
365
366 //! Delete debug output file that may be created by writeDebugInfo() when solving
367 //! with high `loglevel`.
368 virtual void clearDebugFile() {}
369
370protected:
371 //! Value reported as `grid_points` in solver statistics. Overridden by
372 //! subclasses with a meaningful grid-point count; defaults to the total
373 //! number of unknowns.
374 virtual size_t gridSize() const { return m_size; }
375
376 enum class TimeStepGrowthStrategy {
377 fixed,
378 steadyNorm,
379 transientResidual,
380 residualRatio,
381 newtonIterations
382 };
383
384 //! Evaluate the steady-state Jacobian, accessible via linearSolver()
385 //! @param[in] x Current state vector, length size()
386 void evalSSJacobian(span<const double> x);
387
388 static TimeStepGrowthStrategy parseTimeStepGrowthStrategy(const string& strategy);
389 static string timeStepGrowthStrategyName(TimeStepGrowthStrategy strategy);
390
391 //! Determine the timestep growth factor after a successful step.
392 //!
393 //! Called only when a successful step reuses the current Jacobian.
394 double calculateTimeStepGrowthFactor(span<const double> x_before,
395 span<const double> x_after);
396
397 //! Array of number of steps to take after each unsuccessful steady-state solve
398 //! before re-attempting the steady-state solution. For subsequent time stepping
399 //! calls, the final value is reused. See setTimeStep().
400 vector<int> m_steps = { 10 };
401
402 double m_tstep = 1.0e-5; //!< Initial timestep
403 double m_tmin = 1e-16; //!< Minimum timestep size
404 double m_tmax = 1e+08; //!< Maximum timestep size
405
406 //! Factor time step is multiplied by if time stepping fails ( < 1 )
407 double m_tfactor = 0.5;
408
409 //! Growth factor for successful steps that reuse the Jacobian.
410 //!
411 //! Used directly for `fixed-growth`, and as the base / cap value for the
412 //! other named growth strategies.
413 double m_tstep_growth = 1.5;
414
415 //! Selected strategy for successful-step growth.
416 TimeStepGrowthStrategy m_tstep_growth_strategy = TimeStepGrowthStrategy::fixed;
417
418 shared_ptr<vector<double>> m_state; //!< Solution vector
419
420 //! Work array used to hold the residual or the new solution
421 vector<double> m_xnew;
422
423 //! State vector after the last successful set of time steps
424 vector<double> m_xlast_ts;
425
426 unique_ptr<MultiNewton> m_newt; //!< Newton iterator
427 double m_rdt = 0.0; //!< Reciprocal of time step
428
429 shared_ptr<SystemJacobian> m_jac; //!< Jacobian evaluator
430 bool m_jac_ok = false; //!< If `true`, Jacobian is current
431
432 size_t m_bw = 0; //!< Jacobian bandwidth
433 size_t m_size = 0; //!< %Solution vector size
434
435 //! Work arrays used during Jacobian evaluation
436 vector<double> m_work1, m_work2;
437
438 vector<int> m_mask; //!< Transient mask. See transientMask()
439 int m_ss_jac_age = 20; //!< Maximum age of the Jacobian in steady-state mode.
440 int m_ts_jac_age = 20; //!< Maximum age of the Jacobian in time-stepping mode.
441
442 //! Counter used to manage the number of states stored in the debug log file
443 //! generated by writeDebugInfo()
445
446 //! Constant that determines the maximum number of states stored in the debug log
447 //! file generated by writeDebugInfo()
449
450 //! Function called at the start of every call to #eval.
451 Func1* m_interrupt = nullptr;
452
453 //! User-supplied function called after each successful timestep.
455
456 int m_nsteps = 0; //!< Number of time steps taken in the current call to solve()
457 int m_nsteps_max = 500; //!< Maximum number of timesteps allowed per call to solve()
458
459 //! @name Solver-statistics storage
460 //! `m_stats` holds committed per-grid statistics (arrays indexed by grid);
461 //! the remaining members are staging accumulators for the current grid,
462 //! committed by saveStats().
463 //! @{
464
465 //! Committed per-grid statistics. Each key holds an array indexed by grid.
466 //! Schema is established in clearStats().
468
469 int m_nevals = 0; //!< Standalone residual evaluations (not Jacobian fill)
470 double m_evaltime = 0.0; //!< Wall time [s] in standalone residual evals
471 int m_factorizations = 0; //!< Jacobian factorizations on the current grid
472 double m_factorTime = 0.0; //!< Wall time [s] factorizing the Jacobian
473 int m_linearSolves = 0; //!< Linear solves on the current grid
474 double m_solveTime = 0.0; //!< Wall time [s] in linear solves
475 double m_gridTime = 0.0; //!< Total wall time [s] solving on the current grid
476 //! @}
477
478 //! Threshold for ignoring small elements in Jacobian
480 //! Relative perturbation of each component in finite difference Jacobian
481 double m_jacobianRelPerturb = 1e-5;
482 //! Absolute perturbation of each component in finite difference Jacobian
483 double m_jacobianAbsPerturb = 1e-10;
484
485};
486
487}
488
489#endif
Declarations for class SystemJacobian.
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:431
Base class for exceptions thrown by Cantera classes.
CanteraError()
Protected default constructor discourages throwing errors containing no information.
Base class for 'functor' classes that evaluate a function of one variable.
Definition Func1.h:75
Newton iterator for multi-domain, one-dimensional problems.
Definition MultiNewton.h:24
Base class for representing a system of differential-algebraic equations and solving for its steady-s...
int m_nsteps
Number of time steps taken in the current call to solve()
double calculateTimeStepGrowthFactor(span< const double > x_before, span< const double > x_after)
Determine the timestep growth factor after a successful step.
size_t m_size
Solution vector size
int m_nsteps_max
Maximum number of timesteps allowed per call to solve()
virtual void resize()
Call to set the size of internal data structures after first defining the system or if the problem si...
int m_linearSolves
Linear solves on the current grid.
shared_ptr< SystemJacobian > linearSolver() const
Get the the linear solver being used to hold the Jacobian matrix and solve linear systems as part of ...
double timeStep(int nsteps, double dt, span< double > x, span< double > r, int loglevel)
Take time steps using Backward Euler.
virtual void resetBadValues(span< double > x)
Reset values such as negative species concentrations.
vector< double > m_xnew
Work array used to hold the residual or the new solution.
virtual void saveStats()
Commit statistics for the current grid into m_stats and reset the staging counters.
unique_ptr< MultiNewton > m_newt
Newton iterator.
void getState(span< double > x) const
Get the converged steady-state solution after calling solve().
double m_jacobianAbsPerturb
Absolute perturbation of each component in finite difference Jacobian.
size_t size() const
Total solution vector length;.
vector< int > & transientMask()
Access the vector indicating which equations contain a transient term.
virtual double upperBound(size_t i) const =0
Get the upper bound for global component i in the state vector.
double rdt() const
Reciprocal of the time step.
virtual string componentName(size_t i) const
Get the name of the i-th component of the state vector.
virtual string componentTableLabel(size_t i) const
Get elements of the component name, aligned with the column headings given by componentTableHeader().
void factorizeJacobian()
Update the transient term of the Jacobian (forming and factorizing ) and record the elapsed wall-cloc...
virtual void initTimeInteg(double dt, span< const double > x)
Prepare for time stepping beginning with solution x and timestep dt.
AnyMap m_stats
Committed per-grid statistics.
double tsnorm(span< const double > x, span< double > r)
Transient max norm (infinity norm) of the residual evaluated using solution x and the current timeste...
void evalSSJacobian(span< const double > x)
Evaluate the steady-state Jacobian, accessible via linearSolver()
const AnyMap & solverStats()
Return solver statistics as a map of per-grid arrays.
double m_solveTime
Wall time [s] in linear solves.
size_t bandwidth() const
Jacobian bandwidth.
virtual double weightedNorm(span< const double > step) const =0
Compute the weighted norm of step.
double m_rdt
Reciprocal of time step.
virtual size_t gridSize() const
Value reported as grid_points in solver statistics.
double m_jacobianThreshold
Threshold for ignoring small elements in Jacobian.
void recordFactorization(double wallTime)
Record wall-clock time [s] spent factorizing the Jacobian.
void setMaxTimeStep(double tmax)
Set the maximum time step allowed during time stepping.
shared_ptr< SystemJacobian > m_jac
Jacobian evaluator.
void setInitialGuess(span< const double > x)
Set the initial guess. Should be called before solve().
shared_ptr< vector< double > > m_state
Solution vector.
double m_factorTime
Wall time [s] factorizing the Jacobian.
void setMinTimeStep(double tmin)
Set the minimum time step allowed during time stepping.
void setTimeStepGrowthStrategy(const string &strategy)
Set the strategy used to grow the timestep after a successful step that reuses the current Jacobian.
virtual void eval(span< const double > x, span< double > r, double rdt=-1.0, int count=1)=0
Evaluate the residual function.
vector< int > m_mask
Transient mask.
void setTimeStepCallback(Func1 *callback)
Set a function that will be called after each successful timestep.
Func1 * m_interrupt
Function called at the start of every call to eval.
virtual double lowerBound(size_t i) const =0
Get the lower bound for global component i in the state vector.
bool transient() const
True if transient mode.
void recordLinearSolve(double wallTime)
Record wall-clock time [s] spent in a linear solve.
void setMaxTimeStepCount(int nmax)
Set the maximum number of timeteps allowed before successful steady-state solve.
void solve(int loglevel=0)
Solve the steady-state problem, taking internal timesteps as necessary until the Newton solver can co...
double ssnorm(span< const double > x, span< double > r)
Steady-state max norm (infinity norm) of the residual evaluated using solution x.
void setTimeStepFactor(double tfactor)
Sets a factor by which the time step is reduced if the time stepping fails.
string timeStepGrowthStrategy() const
Get the configured timestep growth strategy.
void setTimeStep(double stepsize, span< const int > tsteps)
Set the number of time steps to try when the steady Newton solver is unsuccessful.
vector< int > m_steps
Array of number of steps to take after each unsuccessful steady-state solve before re-attempting the ...
double m_evaltime
Wall time [s] in standalone residual evals.
TimeStepGrowthStrategy m_tstep_growth_strategy
Selected strategy for successful-step growth.
size_t m_bw
Jacobian bandwidth.
double m_tfactor
Factor time step is multiplied by if time stepping fails ( < 1 )
bool m_jac_ok
If true, Jacobian is current.
double m_tstep
Initial timestep.
int maxTimeStepCount() const
Get the maximum number of timeteps allowed before successful steady-state solve.
int m_factorizations
Jacobian factorizations on the current grid.
void setTimeStepGrowthFactor(double tfactor)
Set the growth factor used after successful timesteps when the Jacobian is re-used.
int m_ts_jac_age
Maximum age of the Jacobian in time-stepping mode.
void setJacAge(int ss_age, int ts_age=-1)
Set the maximum number of steps that can be taken using the same Jacobian before it must be re-evalua...
virtual void writeDebugInfo(const string &header_suffix, const string &message, int loglevel, int attempt_counter)
Write solver debugging based on the specified log level.
double m_tmin
Minimum timestep size.
void setJacobianPerturbation(double relative, double absolute, double threshold)
Configure perturbations used to evaluate finite difference Jacobian.
double m_tmax
Maximum timestep size.
int m_ss_jac_age
Maximum age of the Jacobian in steady-state mode.
double m_gridTime
Total wall time [s] solving on the current grid.
int m_nevals
Standalone residual evaluations (not Jacobian fill)
virtual void evalJacobian(span< const double > x0)=0
Evaluates the Jacobian at x0 using finite differences.
virtual void clearStats()
Clear all saved solver statistics and reset the staging counters.
virtual void setSteadyMode()
Prepare to solve the steady-state problem.
virtual void clearDebugFile()
Delete debug output file that may be created by writeDebugInfo() when solving with high loglevel.
int m_attempt_counter
Counter used to manage the number of states stored in the debug log file generated by writeDebugInfo(...
double timeStepGrowthFactor() const
Get the successful-step time step growth factor.
void setLinearSolver(shared_ptr< SystemJacobian > solver)
Set the linear solver used to hold the Jacobian matrix and solve linear systems as part of each Newto...
int m_max_history
Constant that determines the maximum number of states stored in the debug log file generated by write...
Func1 * m_time_step_callback
User-supplied function called after each successful timestep.
virtual pair< string, string > componentTableHeader() const
Get header lines describing the column names included in a component label.
double m_jacobianRelPerturb
Relative perturbation of each component in finite difference Jacobian.
vector< double > m_xlast_ts
State vector after the last successful set of time steps.
bool steady() const
True if steady mode.
vector< double > m_work1
Work arrays used during Jacobian evaluation.
MultiNewton & newton()
Return a reference to the Newton iterator.
double m_tstep_growth
Growth factor for successful steps that reuse the Jacobian.
void setInterrupt(Func1 *interrupt)
Set a function that will be called every time eval is called.
Error thrown when time stepping cannot proceed and the steady-state solver should be given a chance t...
string getClass() const override
Method overridden by derived classes to indicate their type.
This file contains definitions of constants, types and terms that are used in internal routines and a...
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595