Cantera  3.3.0a1
Loading...
Searching...
No Matches
ReactorNet.h
Go to the documentation of this file.
1//! @file ReactorNet.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_REACTORNET_H
7#define CT_REACTORNET_H
8
9#include "Reactor.h"
12
13namespace Cantera
14{
15
16class Array2D;
17class Integrator;
18class SystemJacobian;
19
20//! A class representing a network of connected reactors.
21/*!
22 * This class is used to integrate the governing equations for a network of reactors
23 * that are time dependent (Reactor, ConstPressureReactor) connected by various
24 * means, for example Wall, MassFlowController, Valve, or PressureController; or
25 * reactors dependent on a single spatial variable (FlowReactor).
26 *
27 * @ingroup zerodGroup
28 */
29class ReactorNet : public FuncEval
30{
31public:
32 ReactorNet();
33 //! Create reactor network containing single reactor.
34 //! @since New in %Cantera 3.2.
35 ReactorNet(shared_ptr<ReactorBase> reactor);
36 //! Create reactor network from multiple reactors.
37 //! @since New in %Cantera 3.2.
38 ReactorNet(vector<shared_ptr<ReactorBase>>& reactors);
39 ~ReactorNet() override;
40 ReactorNet(const ReactorNet&) = delete;
41 ReactorNet& operator=(const ReactorNet&) = delete;
42
43 //! @name Methods to set up a simulation
44 //! @{
45
46 //! Set the type of linear solver used in the integration.
47 //! @param linSolverType type of linear solver. Default type: "DENSE"
48 //! Other options include: "DIAG", "DENSE", "GMRES", "BAND"
49 void setLinearSolverType(const string& linSolverType="DENSE");
50
51 //! Set preconditioner used by the linear solver
52 //! @param preconditioner preconditioner object used for the linear solver
53 void setPreconditioner(shared_ptr<SystemJacobian> preconditioner);
54
55 //! Set the initial value of the independent variable (typically time).
56 //! Default = 0.0 s. Restarts integration from this value using the current mixture
57 //! state as the initial condition.
58 void setInitialTime(double time);
59
60 //! Get the initial value of the independent variable (typically time).
61 /*!
62 * @since New in %Cantera 3.0.
63 */
64 double getInitialTime() const {
65 return m_initial_time;
66 }
67
68 //! Get the maximum integrator step.
69 double maxTimeStep() const {
70 return m_maxstep;
71 }
72
73 //! Set the maximum integrator step.
74 void setMaxTimeStep(double maxstep);
75
76 //! Set the maximum number of error test failures permitted by the CVODES
77 //! integrator in a single step.
78 void setMaxErrTestFails(int nmax);
79
80 //! Set the relative and absolute tolerances for the integrator.
81 void setTolerances(double rtol, double atol);
82
83 //! Set the relative and absolute tolerances for integrating the
84 //! sensitivity equations.
85 void setSensitivityTolerances(double rtol, double atol);
86
87 //! Current value of the simulation time [s], for reactor networks that are solved
88 //! in the time domain.
89 double time();
90
91 //! Current position [m] along the length of the reactor network, for reactors that
92 //! are solved as a function of space.
93 double distance();
94
95 //! Relative tolerance.
96 double rtol() {
97 return m_rtol;
98 }
99
100 //! Absolute integration tolerance
101 double atol() {
102 return m_atols;
103 }
104
105 //! Relative sensitivity tolerance
106 double rtolSensitivity() const {
107 return m_rtolsens;
108 }
109
110 //! Absolute sensitivity tolerance
111 double atolSensitivity() const {
112 return m_atolsens;
113 }
114
115 //! Problem type of integrator
116 string linearSolverType() const;
117
118 //! Returns the maximum number of internal integration steps the
119 //! integrator will take before reaching the next output point
120 int maxSteps();
121
122 //! @}
123
124 /**
125 * Advance the state of all reactors in the independent variable (time or space).
126 * Take as many internal steps as necessary to reach *t*.
127 * @param t Time/distance to advance to (s or m).
128 */
129 void advance(double t);
130
131 /**
132 * Advance the state of all reactors in the independent variable (time or space).
133 * Take as many internal steps as necessary towards *t*. If *applylimit* is true,
134 * the advance step will be automatically reduced if needed to stay within limits
135 * (set by setAdvanceLimit).
136 * Returns the time/distance at the end of integration.
137 * @param t Time/distance to advance to (s or m).
138 * @param applylimit Limit advance step (boolean).
139 */
140 double advance(double t, bool applylimit);
141
142 //! Advance the state of all reactors with respect to the independent variable
143 //! (time or space). Returns the new value of the independent variable [s or m].
144 double step();
145
146 //! Solve directly for the steady-state solution.
147 //!
148 //! This approach is generally more efficient than time marching to the
149 //! steady-state, but imposes a few limitations:
150 //!
151 //! - The volume of control volume reactor types (such as Reactor and
152 //! IdealGasMoleReactor) must be constant; no moving walls can be used.
153 //! - The mass of constant pressure reactor types (such as ConstPressureReactor and
154 //! IdealGasConstPressureReactor) must be constant; if flow devices are used,
155 //! inlet and outlet flows must be balanced.
156 //! - The solver is currently not compatible with the ConstPressureMoleReactor or
157 //! IdealGasConstPressureMoleReactor classes.
158 //! - Only ideal gas reactor types can be used for when the energy equation is
159 //! disabled (fixed temperature simulations).
160 //! - Reacting surfaces are not yet supported.
161 //!
162 //! @param loglevel Print information about solver progress to aid in understanding
163 //! cases where the solver fails to converge. Higher levels are more verbose.
164 //! - 0: No logging.
165 //! - 1: Basic info about each steady-state attempt and round of time stepping.
166 //! - 2: Adds details about each time step and steady-state Newton iteration.
167 //! - 3: Adds details about Newton iterations for each time step.
168 //! - 4: Adds details about state variables that are limiting steady-state
169 //! Newton step sizes.
170 //! - 5: Adds details about state variables that are limiting time-stepping
171 //! Newton step sizes.
172 //! - 6: Print current state vector after different solver stages
173 //! - 7: Print current residual vector after different solver stages
174 //!
175 //! @see SteadyStateSystem, MultiNewton
176 //! @since New in %Cantera 3.2.
177 void solveSteady(int loglevel=0);
178
179 //! Get the Jacobian used by the steady-state solver.
180 //!
181 //! @param rdt Reciprocal of the pseudo-timestep [1/s]. Default of 0.0 returns the
182 //! steady-state Jacobian.
183 //! @since New in %Cantera 3.2.
184 Eigen::SparseMatrix<double> steadyJacobian(double rdt=0.0);
185
186 //! Return a reference to the *n*-th reactor in this network. The reactor
187 //! indices are determined by the order in which the reactors were added
188 //! to the reactor network.
189 Reactor& reactor(int n) {
190 return *m_reactors[n];
191 }
192
193 //! Returns `true` if verbose logging output is enabled.
194 bool verbose() const {
195 return m_verbose;
196 }
197
198 //! Enable or disable verbose logging while setting up and integrating the
199 //! reactor network.
200 void setVerbose(bool v = true) {
201 m_verbose = v;
202 suppressErrors(!m_verbose);
203 }
204
205 //! Return a reference to the integrator. Only valid after adding at least one
206 //! reactor to the network.
208
209 //! Update the state of all the reactors in the network to correspond to
210 //! the values in the solution vector *y*.
211 void updateState(double* y);
212
213 //! Return the sensitivity of the *k*-th solution component with respect to
214 //! the *p*-th sensitivity parameter.
215 /*!
216 * The sensitivity coefficient @f$ S_{ki} @f$ of solution variable @f$ y_k
217 * @f$ with respect to sensitivity parameter @f$ p_i @f$ is defined as:
218 *
219 * @f[ S_{ki} = \frac{1}{y_k} \frac{\partial y_k}{\partial p_i} @f]
220 *
221 * For reaction sensitivities, the parameter is a multiplier on the forward
222 * rate constant (and implicitly on the reverse rate constant for
223 * reversible reactions) which has a nominal value of 1.0, and the
224 * sensitivity is nondimensional.
225 *
226 * For species enthalpy sensitivities, the parameter is a perturbation to
227 * the molar enthalpy of formation, such that the dimensions of the
228 * sensitivity are kmol/J.
229 */
230 double sensitivity(size_t k, size_t p);
231
232 //! Return the sensitivity of the component named *component* with respect to
233 //! the *p*-th sensitivity parameter.
234 //! @copydetails ReactorNet::sensitivity(size_t, size_t)
235 double sensitivity(const string& component, size_t p, int reactor=0) {
236 size_t k = globalComponentIndex(component, reactor);
237 return sensitivity(k, p);
238 }
239
240 //! Evaluate the Jacobian matrix for the reactor network.
241 /*!
242 * @param[in] t Time/distance at which to evaluate the Jacobian
243 * @param[in] y Global state vector at *t*
244 * @param[out] ydot Derivative of the state vector evaluated at *t*, with respect
245 * to *t*.
246 * @param[in] p sensitivity parameter vector (unused?)
247 * @param[out] j Jacobian matrix, size neq() by neq().
248 */
249 void evalJacobian(double t, double* y,
250 double* ydot, double* p, Array2D* j);
251
252 // overloaded methods of class FuncEval
253 size_t neq() const override {
254 return m_nv;
255 }
256
257 size_t nReactors() const {
258 return m_reactors.size();
259 }
260
261 void eval(double t, double* y, double* ydot, double* p) override;
262
263 //! eval coupling for IDA / DAEs
264 void evalDae(double t, double* y, double* ydot, double* p,
265 double* residual) override;
266
267 void getState(double* y) override;
268 void getStateDae(double* y, double* ydot) override;
269
270 //! Return k-th derivative at the current state of the system
271 virtual void getDerivative(int k, double* dky);
272
273 void getConstraints(double* constraints) override;
274
275 size_t nparams() const override {
276 return m_sens_params.size();
277 }
278
279 //! Return the index corresponding to the component named *component* in the
280 //! reactor with index *reactor* in the global state vector for the
281 //! reactor network.
282 size_t globalComponentIndex(const string& component, size_t reactor=0);
283
284 //! Return the name of the i-th component of the global state vector. The
285 //! name returned includes both the name of the reactor and the specific
286 //! component, for example `'reactor1: CH4'`.
287 string componentName(size_t i) const;
288
289 //! Get the upper bound on the i-th component of the global state vector.
290 double upperBound(size_t i) const;
291
292 //! Get the lower bound on the i-th component of the global state vector.
293 double lowerBound(size_t i) const;
294
295 //! Reset physically or mathematically problematic values, such as negative species
296 //! concentrations.
297 //!
298 //! This method is used within solveSteady() if certain errors are encountered.
299 //!
300 //! @param[inout] y current state vector, to be updated; length neq()
301 void resetBadValues(double* y);
302
303 //! Used by Reactor and Wall objects to register the addition of
304 //! sensitivity parameters so that the ReactorNet can keep track of the
305 //! order in which sensitivity parameters are added.
306 //! @param name A name describing the parameter, for example the reaction string
307 //! @param value The nominal value of the parameter
308 //! @param scale A scaling factor to be applied to the sensitivity
309 //! coefficient
310 //! @returns the index of this parameter in the vector of sensitivity
311 //! parameters (global across all reactors)
312 size_t registerSensitivityParameter(const string& name, double value, double scale);
313
314 //! The name of the p-th sensitivity parameter added to this ReactorNet.
315 const string& sensitivityParameterName(size_t p) const {
316 return m_paramNames.at(p);
317 }
318
319 //! Initialize the reactor network. Called automatically the first time
320 //! advance or step is called.
321 void initialize();
322
323 //! Reinitialize the integrator. Used to solve a new problem (different
324 //! initial conditions) but with the same configuration of the reactor
325 //! network. Can be called manually, or automatically after calling
326 //! setInitialTime or modifying a reactor's contents.
327 void reinitialize();
328
329 //! Called to trigger integrator reinitialization before further
330 //! integration.
332 m_integrator_init = false;
333 }
334
335 //! Set the maximum number of internal integration steps the
336 //! integrator will take before reaching the next output point
337 //! @param nmax The maximum number of steps, setting this value
338 //! to zero disables this option.
339 virtual void setMaxSteps(int nmax);
340
341 //! Set absolute step size limits during advance
342 void setAdvanceLimits(const double* limits);
343
344 //! Check whether ReactorNet object uses advance limits
345 bool hasAdvanceLimits() const;
346
347 //! Retrieve absolute step size limits during advance
348 bool getAdvanceLimits(double* limits) const;
349
350 void preconditionerSetup(double t, double* y, double gamma) override;
351
352 void preconditionerSolve(double* rhs, double* output) override;
353
354 //! Get solver stats from integrator
355 AnyMap solverStats() const;
356
357 //! Set derivative settings of all reactors
358 //! @param settings the settings map propagated to all reactors and kinetics objects
359 virtual void setDerivativeSettings(AnyMap& settings);
360
361 //! Root finding is enabled only while enforcing advance limits
362 size_t nRootFunctions() const override;
363
364 //! Evaluate the advance-limit root function used to stop integration once a limit
365 //! is met.
366 //!
367 //! When limits are active, this sets `gout[0]` to
368 //! `1 - max_i(|y[i]-y_base[i]| / limit[i])` so a zero indicates a component has
369 //! reached its limit; otherwise `gout[0]` is positive.
370 void evalRootFunctions(double t, const double* y, double* gout) override;
371
372protected:
373 //! Add the reactor *r* to this reactor network.
374 //! @since Changed in %Cantera 3.2. Previous version used a reference.
375 void addReactor(shared_ptr<ReactorBase> reactor);
376
377 //! Check that preconditioning is supported by all reactors in the network
378 virtual void checkPreconditionerSupported() const;
379
380 void updatePreconditioner(double gamma) override;
381
382 //! Create reproducible names for reactors and walls/connectors.
383 void updateNames(Reactor& r);
384
385 //! Estimate a future state based on current derivatives.
386 //! The function is intended for internal use by ReactorNet::advance
387 //! and deliberately not exposed in external interfaces.
388 virtual void getEstimate(double time, int k, double* yest);
389
390 //! Returns the order used for last solution step of the ODE integrator
391 //! The function is intended for internal use by ReactorNet::advance
392 //! and deliberately not exposed in external interfaces.
393 virtual int lastOrder() const;
394
395 vector<Reactor*> m_reactors;
396 map<string, int> m_counts; //!< Map used for default name generation
397 unique_ptr<Integrator> m_integ;
398
399 //! The independent variable in the system. May be either time or space depending
400 //! on the type of reactors in the network.
401 double m_time = 0.0;
402
403 //! The initial value of the independent variable in the system.
404 double m_initial_time = 0.0;
405
406 bool m_init = false;
407 bool m_integrator_init = false; //!< True if integrator initialization is current
408 size_t m_nv = 0;
409
410 //! m_start[n] is the starting point in the state vector for reactor n
411 vector<size_t> m_start;
412
413 vector<double> m_atol;
414 double m_rtol = 1.0e-9;
415 double m_rtolsens = 1.0e-4;
416 double m_atols = 1.0e-15;
417 double m_atolsens = 1.0e-6;
418 shared_ptr<SystemJacobian> m_precon;
419 string m_linearSolverType;
420
421 //! Maximum integrator internal timestep. Default of 0.0 means infinity.
422 double m_maxstep = 0.0;
423
424 bool m_verbose = false;
425
426 //! Indicates whether time or space is the independent variable
428
429 //! Names corresponding to each sensitivity parameter
430 vector<string> m_paramNames;
431
432 vector<double> m_ydot;
433 vector<double> m_yest;
434 vector<double> m_advancelimits;
435 //! Base state used for evaluating advance limits during a single advance()
436 //! call when root-finding is enabled
437 vector<double> m_ybase;
438 //! Base time corresponding to #m_ybase
439 double m_ybase_time = 0.0;
440 //! Indicates whether the advance-limit root check is active for the
441 //! current call to `advance(t, applylimit=true)`
443 //! m_LHS is a vector representing the coefficients on the
444 //! "left hand side" of each governing equation
445 vector<double> m_LHS;
446 vector<double> m_RHS;
447};
448
449
450//! Adapter class to enable using the SteadyStateSystem solver with ReactorNet.
451//!
452//! @see ReactorNet::solveSteady
453//! @since New in %Cantera 3.2.
455{
456public:
457 SteadyReactorSolver(ReactorNet* net, double* x0);
458 void eval(double* x, double* r, double rdt=-1.0, int count=1) override;
459 void initTimeInteg(double dt, double* x) override;
460 void evalJacobian(double* x0) override;
461 double weightedNorm(const double* step) const override;
462 string componentName(size_t i) const override;
463 double upperBound(size_t i) const override;
464 double lowerBound(size_t i) const override;
465 void resetBadValues(double* x) override;
466 void writeDebugInfo(const string& header_suffix, const string& message,
467 int loglevel, int attempt_counter) override;
468
469private:
470 ReactorNet* m_net = nullptr;
471
472 //! Initial value of each state variable
473 vector<double> m_initialState;
474
475 //! Indices of variables that are held constant in the time-stepping mode of the
476 //! steady-state solver.
477 vector<size_t> m_algebraic;
478};
479
480
481/**
482 * Create a reactor network containing one or more coupled reactors.
483 * Wall and FlowDevice objects should be installed prior to calling newReactorNet().
484 * @param[in] reactors A vector of shared pointers to the reactors to be linked
485 * together.
486 * @since New in %Cantera 3.2.
487 */
488shared_ptr<ReactorNet> newReactorNet(vector<shared_ptr<ReactorBase>>& reactors);
489
490}
491
492#endif
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:431
A class for 2D arrays stored in column-major (Fortran-compatible) form.
Definition Array.h:32
Virtual base class for ODE/DAE right-hand-side function evaluators.
Definition FuncEval.h:32
bool suppressErrors() const
Get current state of error suppression.
Definition FuncEval.h:188
vector< double > m_sens_params
Values for the problem parameters for which sensitivities are computed This is the array which is per...
Definition FuncEval.h:203
Abstract base class for ODE system integrators.
Definition Integrator.h:44
A class representing a network of connected reactors.
Definition ReactorNet.h:30
void setLinearSolverType(const string &linSolverType="DENSE")
Set the type of linear solver used in the integration.
void preconditionerSetup(double t, double *y, double gamma) override
Evaluate the setup processes for the Jacobian preconditioner.
double step()
Advance the state of all reactors with respect to the independent variable (time or space).
virtual int lastOrder() const
Returns the order used for last solution step of the ODE integrator The function is intended for inte...
const string & sensitivityParameterName(size_t p) const
The name of the p-th sensitivity parameter added to this ReactorNet.
Definition ReactorNet.h:315
void eval(double t, double *y, double *ydot, double *p) override
Evaluate the right-hand-side ODE function.
double m_ybase_time
Base time corresponding to m_ybase.
Definition ReactorNet.h:439
size_t nparams() const override
Number of sensitivity parameters.
Definition ReactorNet.h:275
void initialize()
Initialize the reactor network.
void advance(double t)
Advance the state of all reactors in the independent variable (time or space).
size_t neq() const override
Number of equations.
Definition ReactorNet.h:253
vector< size_t > m_start
m_start[n] is the starting point in the state vector for reactor n
Definition ReactorNet.h:411
vector< double > m_LHS
m_LHS is a vector representing the coefficients on the "left hand side" of each governing equation
Definition ReactorNet.h:445
double m_initial_time
The initial value of the independent variable in the system.
Definition ReactorNet.h:404
void evalJacobian(double t, double *y, double *ydot, double *p, Array2D *j)
Evaluate the Jacobian matrix for the reactor network.
double time()
Current value of the simulation time [s], for reactor networks that are solved in the time domain.
double getInitialTime() const
Get the initial value of the independent variable (typically time).
Definition ReactorNet.h:64
void setNeedsReinit()
Called to trigger integrator reinitialization before further integration.
Definition ReactorNet.h:331
void getConstraints(double *constraints) override
Given a vector of length neq(), mark which variables should be considered algebraic constraints.
double m_time
The independent variable in the system.
Definition ReactorNet.h:401
AnyMap solverStats() const
Get solver stats from integrator.
Reactor & reactor(int n)
Return a reference to the n-th reactor in this network.
Definition ReactorNet.h:189
void addReactor(shared_ptr< ReactorBase > reactor)
Add the reactor r to this reactor network.
bool m_limit_check_active
Indicates whether the advance-limit root check is active for the current call to advance(t,...
Definition ReactorNet.h:442
map< string, int > m_counts
Map used for default name generation.
Definition ReactorNet.h:396
double upperBound(size_t i) const
Get the upper bound on the i-th component of the global state vector.
virtual void setMaxSteps(int nmax)
Set the maximum number of internal integration steps the integrator will take before reaching the nex...
string componentName(size_t i) const
Return the name of the i-th component of the global state vector.
void evalRootFunctions(double t, const double *y, double *gout) override
Evaluate the advance-limit root function used to stop integration once a limit is met.
size_t nRootFunctions() const override
Root finding is enabled only while enforcing advance limits.
void getStateDae(double *y, double *ydot) override
Fill in the vectors y and ydot with the current state of the system.
void setInitialTime(double time)
Set the initial value of the independent variable (typically time).
virtual void getDerivative(int k, double *dky)
Return k-th derivative at the current state of the system.
void setMaxErrTestFails(int nmax)
Set the maximum number of error test failures permitted by the CVODES integrator in a single step.
size_t registerSensitivityParameter(const string &name, double value, double scale)
Used by Reactor and Wall objects to register the addition of sensitivity parameters so that the React...
double maxTimeStep() const
Get the maximum integrator step.
Definition ReactorNet.h:69
double m_maxstep
Maximum integrator internal timestep. Default of 0.0 means infinity.
Definition ReactorNet.h:422
double distance()
Current position [m] along the length of the reactor network, for reactors that are solved as a funct...
double atolSensitivity() const
Absolute sensitivity tolerance.
Definition ReactorNet.h:111
void setSensitivityTolerances(double rtol, double atol)
Set the relative and absolute tolerances for integrating the sensitivity equations.
int maxSteps()
Returns the maximum number of internal integration steps the integrator will take before reaching the...
virtual void setDerivativeSettings(AnyMap &settings)
Set derivative settings of all reactors.
double sensitivity(size_t k, size_t p)
Return the sensitivity of the k-th solution component with respect to the p-th sensitivity parameter.
void updateNames(Reactor &r)
Create reproducible names for reactors and walls/connectors.
void updateState(double *y)
Update the state of all the reactors in the network to correspond to the values in the solution vecto...
void getState(double *y) override
Fill in the vector y with the current state of the system.
void setAdvanceLimits(const double *limits)
Set absolute step size limits during advance.
double rtol()
Relative tolerance.
Definition ReactorNet.h:96
bool verbose() const
Returns true if verbose logging output is enabled.
Definition ReactorNet.h:194
size_t globalComponentIndex(const string &component, size_t reactor=0)
Return the index corresponding to the component named component in the reactor with index reactor in ...
void solveSteady(int loglevel=0)
Solve directly for the steady-state solution.
bool m_timeIsIndependent
Indicates whether time or space is the independent variable.
Definition ReactorNet.h:427
double atol()
Absolute integration tolerance.
Definition ReactorNet.h:101
bool hasAdvanceLimits() const
Check whether ReactorNet object uses advance limits.
vector< double > m_ybase
Base state used for evaluating advance limits during a single advance() call when root-finding is ena...
Definition ReactorNet.h:437
double sensitivity(const string &component, size_t p, int reactor=0)
Return the sensitivity of the component named component with respect to the p-th sensitivity paramete...
Definition ReactorNet.h:235
void setMaxTimeStep(double maxstep)
Set the maximum integrator step.
double rtolSensitivity() const
Relative sensitivity tolerance.
Definition ReactorNet.h:106
double lowerBound(size_t i) const
Get the lower bound on the i-th component of the global state vector.
void evalDae(double t, double *y, double *ydot, double *p, double *residual) override
eval coupling for IDA / DAEs
virtual void checkPreconditionerSupported() const
Check that preconditioning is supported by all reactors in the network.
bool m_integrator_init
True if integrator initialization is current.
Definition ReactorNet.h:407
void reinitialize()
Reinitialize the integrator.
Integrator & integrator()
Return a reference to the integrator.
bool getAdvanceLimits(double *limits) const
Retrieve absolute step size limits during advance.
void setVerbose(bool v=true)
Enable or disable verbose logging while setting up and integrating the reactor network.
Definition ReactorNet.h:200
Eigen::SparseMatrix< double > steadyJacobian(double rdt=0.0)
Get the Jacobian used by the steady-state solver.
string linearSolverType() const
Problem type of integrator.
void updatePreconditioner(double gamma) override
Update the preconditioner based on already computed jacobian values.
void setPreconditioner(shared_ptr< SystemJacobian > preconditioner)
Set preconditioner used by the linear solver.
void preconditionerSolve(double *rhs, double *output) override
Evaluate the linear system Ax=b where A is the preconditioner.
vector< string > m_paramNames
Names corresponding to each sensitivity parameter.
Definition ReactorNet.h:430
void resetBadValues(double *y)
Reset physically or mathematically problematic values, such as negative species concentrations.
void setTolerances(double rtol, double atol)
Set the relative and absolute tolerances for the integrator.
virtual void getEstimate(double time, int k, double *yest)
Estimate a future state based on current derivatives.
Class Reactor is a general-purpose class for stirred reactors.
Definition Reactor.h:47
Adapter class to enable using the SteadyStateSystem solver with ReactorNet.
Definition ReactorNet.h:455
double weightedNorm(const double *step) const override
Compute the weighted norm of step.
vector< double > m_initialState
Initial value of each state variable.
Definition ReactorNet.h:473
string componentName(size_t i) const override
Get the name of the i-th component of the state vector.
double upperBound(size_t i) const override
Get the upper bound for global component i in the state vector.
vector< size_t > m_algebraic
Indices of variables that are held constant in the time-stepping mode of the steady-state solver.
Definition ReactorNet.h:477
void evalJacobian(double *x0) override
Evaluates the Jacobian at x0 using finite differences.
void resetBadValues(double *x) override
Reset values such as negative species concentrations.
void writeDebugInfo(const string &header_suffix, const string &message, int loglevel, int attempt_counter) override
Write solver debugging based on the specified log level.
void eval(double *x, double *r, double rdt=-1.0, int count=1) override
Evaluate the residual function.
void initTimeInteg(double dt, double *x) override
Prepare for time stepping beginning with solution x and timestep dt.
double lowerBound(size_t i) const override
Get the lower bound for global component i in the state vector.
Base class for representing a system of differential-algebraic equations and solving for its steady-s...
double rdt() const
Reciprocal of the time step.
void scale(InputIter begin, InputIter end, OutputIter out, S scale_factor)
Multiply elements of an array by a scale factor.
Definition utilities.h:104
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
shared_ptr< ReactorNet > newReactorNet(vector< shared_ptr< ReactorBase > > &reactors)
Create a reactor network containing one or more coupled reactors.