Cantera  3.1.0a1
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 
11 #include "cantera/base/ct_defs.h"
12 
13 namespace Cantera
14 {
15 
16 class ReactionRate;
17 class ThermoPhase;
18 class 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 {
29 public:
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 number of species and reactions
46  //! @param nSpecies number of species
47  //! @param nReactions number of reactions
48  //! @param nPhases number of phases
49  virtual void resize(size_t nSpecies, size_t nReactions, size_t nPhases) = 0;
50 
51  //! Evaluate all rate constants handled by the evaluator
52  //! @param kf array of rate constants
53  virtual void getRateConstants(double* kf) = 0;
54 
55  //! Evaluate all rate constant temperature derivatives handled by the evaluator;
56  //! which are multiplied with the array of rate-of-progress variables.
57  //! Depending on the implementation of a rate object, either an exact derivative or
58  //! a numerical approximation may be used.
59  //! @param[in,out] rop array of rop, which is modified by the method;
60  //! contains rop on input, and d(rop)/dT on output
61  //! @param kf array of forward rate constants (numerical derivative only)
62  //! @param deltaT relative temperature perturbation (numerical derivative only)
63  virtual void processRateConstants_ddT(double* rop,
64  const double* kf,
65  double deltaT) = 0;
66 
67  //! Evaluate all rate constant pressure derivatives handled by the evaluator;
68  //! which are multiplied with the array of rate-of-progress variables.
69  //! @param[in,out] rop array of rop, which is modified by the method;
70  //! contains rop on input, and d(rop)/dP on output
71  //! @param kf array of forward rate constants
72  //! @param deltaP relative pressure perturbation
73  virtual void processRateConstants_ddP(double* rop,
74  const double* kf,
75  double deltaP) = 0;
76 
77  //! Evaluate all rate constant third-body derivatives handled by the evaluator;
78  //! which are multiplied with the array of rate-of-progress variables.
79  //! @param[in,out] rop array of rop, which is modified by the method;
80  //! contains rop on input, and d(rop)/dM on output
81  //! @param kf array of forward rate constants
82  //! @param deltaM relative perturbation of third-body concentrations
83  //! @param overwrite if `true`, rop entries not affected by M are set to zero
84  virtual void processRateConstants_ddM(double* rop,
85  const double* kf,
86  double deltaM,
87  bool overwrite=true) = 0;
88 
89  //! Update common reaction rate data based on temperature.
90  //! Only used in conjunction with evalSingle and ReactionRate::eval
91  //! @param T temperature [K]
92  virtual void update(double T) = 0;
93 
94  //! Update common reaction rate data based on temperature and extra parameter.
95  //! Only used in conjunction with evalSingle and ReactionRate::eval
96  //! @param T temperature [K]
97  //! @param extra extra parameter (depends on parameterization)
98  virtual void update(double T, double extra) = 0;
99 
100  //! Update common reaction rate data based on temperature and extra parameter.
101  //! Only used in conjunction with evalSingle and ReactionRate::eval
102  //! @param T temperature [K]
103  //! @param extra extra vector parameter (depends on parameterization)
104  //! @warning This method is an experimental part of the %Cantera API and
105  //! may be changed or removed without notice.
106  virtual void update(double T, const vector<double>& extra) = 0;
107 
108  //! Update data common to reaction rates of a specific type.
109  //! This update mechanism is used by Kinetics reaction rate evaluators.
110  //! @param phase object representing reacting phase
111  //! @param kin object representing kinetics
112  //! @returns flag indicating whether reaction rates need to be re-evaluated
113  virtual bool update(const ThermoPhase& phase, const Kinetics& kin) = 0;
114 
115  //! Get the rate for a single reaction. Used to implement ReactionRate::eval,
116  //! which allows for the evaluation of a reaction rate expression outside of
117  //! Kinetics reaction rate evaluators. Mainly used for testing purposes.
118  virtual double evalSingle(ReactionRate& rate) = 0;
119 };
120 
121 } // end namespace Cantera
122 
123 #endif
Public interface for kinetics managers.
Definition: Kinetics.h:125
An abstract base class for evaluating all reactions of a particular type.
Definition: MultiRateBase.h:28
virtual void processRateConstants_ddM(double *rop, 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 void processRateConstants_ddP(double *rop, const double *kf, double deltaP)=0
Evaluate all rate constant pressure derivatives handled by the evaluator; which are multiplied with t...
virtual void processRateConstants_ddT(double *rop, const double *kf, double deltaT)=0
Evaluate all rate constant temperature derivatives handled by the evaluator; which are multiplied wit...
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 update(double T, const vector< double > &extra)=0
Update common reaction rate data based on temperature and extra parameter.
virtual void getRateConstants(double *kf)=0
Evaluate all rate constants handled by the evaluator.
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 add(size_t rxn_index, ReactionRate &rate)=0
Add reaction rate object to the evaluator.
virtual void update(double T, double extra)=0
Update common reaction rate data based on temperature and extra parameter.
virtual void resize(size_t nSpecies, size_t nReactions, size_t nPhases)=0
Update number of species and reactions.
Abstract base class for reaction rate definitions; this base class is used by user-facing APIs to acc...
Definition: ReactionRate.h:49
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:390
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:564