Cantera  4.0.0a1
Loading...
Searching...
No Matches
MultiRateBase.h
Go to the documentation of this file.
1/**
2 * @file MultiRateBase.h
3 */
4
5// This file is part of Cantera. See License.txt in the top-level directory or
6// at https://cantera.org/license.txt for license and copyright information.
7
8#ifndef CT_MULTIRATEBASE_H
9#define CT_MULTIRATEBASE_H
10
12
13namespace Cantera
14{
15
16class ReactionRate;
17class ThermoPhase;
18class Kinetics;
19
20//! An abstract base class for evaluating all reactions of a particular type.
21/**
22 * Because this class has no template parameters, the Kinetics object can store all of
23 * these rate coefficient evaluators as a `vector<shared_ptr<MultiRateBase>>`. All of
24 * the actual implementation for this capability is done in the MultiRate class.
25 * @ingroup rateEvaluators
26 */
28{
29public:
30 virtual ~MultiRateBase() {}
31
32 //! Identifier of reaction rate type
33 virtual string type() = 0;
34
35 //! Add reaction rate object to the evaluator
36 //! @param rxn_index index of reaction
37 //! @param rate reaction rate object
38 virtual void add(size_t rxn_index, ReactionRate& rate) = 0;
39
40 //! Replace reaction rate object handled by the evaluator
41 //! @param rxn_index index of reaction
42 //! @param rate reaction rate object
43 virtual bool replace(size_t rxn_index, ReactionRate& rate) = 0;
44
45 //! Update array sizes that depend on number of species, reactions or phases
46 //! @since Changed in %Cantera 4.0 to take a Kinetics object as argument instead of
47 //! specific array sizes.
48 virtual void resize(Kinetics& kin) = 0;
49
50 //! Evaluate all rate constants handled by the evaluator
51 //! @param kf array of rate constants
52 virtual void getRateConstants(span<double> kf) = 0;
53
54 //! For certain reaction types that do not follow mass action kinetics (for example,
55 //! Butler-Volmer), calculate modifications to the forward and reverse rate
56 //! constants.
57 //! @param[in, out] kf On input, contains the rate constants as computed by
58 //! getRateConstants(). The output value is updated by the reactant
59 //! StoichManagerN to determine the forward rates of progress.
60 //! @param[in, out] kr On input, contains the reverse rate constants computed from
61 //! the forward rate constants and the equilibrium constants. The output value
62 //! is updated by the product StoichManagerN to determine the reverse rates of
63 //! progress.
64 //! @since New in %Cantera 3.2
65 virtual void modifyRateConstants(span<double> kf, span<double> kr) = 0;
66
67 //! Evaluate all rate constant temperature derivatives handled by the evaluator;
68 //! which are multiplied with the array of rate-of-progress variables.
69 //! Depending on the implementation of a rate object, either an exact derivative or
70 //! a numerical approximation may be used.
71 //! @param[in,out] rop array of rop, which is modified by the method;
72 //! contains rop on input, and d(rop)/dT on output
73 //! @param kf array of forward rate constants (numerical derivative only)
74 //! @param deltaT relative temperature perturbation (numerical derivative only)
75 virtual void processRateConstants_ddT(span<double> rop, span<const double> kf,
76 double deltaT) = 0;
77
78 //! Evaluate all rate constant pressure derivatives handled by the evaluator;
79 //! which are multiplied with the array of rate-of-progress variables.
80 //! @param[in,out] rop array of rop, which is modified by the method;
81 //! contains rop on input, and d(rop)/dP on output
82 //! @param kf array of forward rate constants
83 //! @param deltaP relative pressure perturbation
84 virtual void processRateConstants_ddP(span<double> rop, span<const double> kf,
85 double deltaP) = 0;
86
87 //! Evaluate all rate constant third-body derivatives handled by the evaluator;
88 //! which are multiplied with the array of rate-of-progress variables.
89 //! @param[in,out] rop array of rop, which is modified by the method;
90 //! contains rop on input, and d(rop)/dM on output
91 //! @param kf array of forward rate constants
92 //! @param deltaM relative perturbation of third-body concentrations
93 //! @param overwrite if `true`, rop entries not affected by M are set to zero
94 virtual void processRateConstants_ddM(span<double> rop, span<const double> kf,
95 double deltaM, bool overwrite=true) = 0;
96
97 //! Update common reaction rate data based on temperature.
98 //! Only used in conjunction with evalSingle and ReactionRate::eval
99 //! @param T temperature [K]
100 virtual void update(double T) = 0;
101
102 //! Update common reaction rate data based on temperature and extra parameter.
103 //! Only used in conjunction with evalSingle and ReactionRate::eval
104 //! @param T temperature [K]
105 //! @param extra extra parameter (depends on parameterization)
106 virtual void update(double T, double extra) = 0;
107
108 //! Update common reaction rate data based on temperature and extra parameter.
109 //! Only used in conjunction with evalSingle and ReactionRate::eval
110 //! @param T temperature [K]
111 //! @param extra extra vector parameter (depends on parameterization)
112 //! @warning This method is an experimental part of the %Cantera API and
113 //! may be changed or removed without notice.
114 virtual void update(double T, span<const double> extra) = 0;
115
116 //! Update data common to reaction rates of a specific type.
117 //! This update mechanism is used by Kinetics reaction rate evaluators.
118 //! @param phase object representing reacting phase
119 //! @param kin object representing kinetics
120 //! @returns flag indicating whether reaction rates need to be re-evaluated
121 virtual bool update(const ThermoPhase& phase, const Kinetics& kin) = 0;
122
123 //! Get the rate for a single reaction. Used to implement ReactionRate::eval,
124 //! which allows for the evaluation of a reaction rate expression outside of
125 //! Kinetics reaction rate evaluators. Mainly used for testing purposes.
126 virtual double evalSingle(ReactionRate& rate) = 0;
127};
128
129} // end namespace Cantera
130
131#endif
Public interface for kinetics managers.
Definition Kinetics.h:126
An abstract base class for evaluating all reactions of a particular type.
virtual bool update(const ThermoPhase &phase, const Kinetics &kin)=0
Update data common to reaction rates of a specific type.
virtual double evalSingle(ReactionRate &rate)=0
Get the rate for a single reaction.
virtual void getRateConstants(span< double > kf)=0
Evaluate all rate constants handled by the evaluator.
virtual void processRateConstants_ddM(span< double > rop, span< const double > kf, double deltaM, bool overwrite=true)=0
Evaluate all rate constant third-body derivatives handled by the evaluator; which are multiplied with...
virtual string type()=0
Identifier of reaction rate type.
virtual bool replace(size_t rxn_index, ReactionRate &rate)=0
Replace reaction rate object handled by the evaluator.
virtual void update(double T)=0
Update common reaction rate data based on temperature.
virtual void processRateConstants_ddT(span< double > rop, span< const double > kf, double deltaT)=0
Evaluate all rate constant temperature derivatives handled by the evaluator; which are multiplied wit...
virtual void add(size_t rxn_index, ReactionRate &rate)=0
Add reaction rate object to the evaluator.
virtual void modifyRateConstants(span< double > kf, span< double > kr)=0
For certain reaction types that do not follow mass action kinetics (for example, Butler-Volmer),...
virtual void update(double T, double extra)=0
Update common reaction rate data based on temperature and extra parameter.
virtual void resize(Kinetics &kin)=0
Update array sizes that depend on number of species, reactions or phases.
virtual void update(double T, span< const double > extra)=0
Update common reaction rate data based on temperature and extra parameter.
virtual void processRateConstants_ddP(span< double > rop, span< const double > kf, double deltaP)=0
Evaluate all rate constant pressure derivatives handled by the evaluator; which are multiplied with t...
Abstract base class for reaction rate definitions; this base class is used by user-facing APIs to acc...
Base class for a phase with thermodynamic properties.
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