1 /**
2  *  @file RateCoeffMgr.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_RATECOEFF_MGR_H
9 #define CT_RATECOEFF_MGR_H
10 
11 #include "RxnRates.h"
12 
13 namespace Cantera
14 {
15 
16 /**
17  * This rate coefficient manager supports one parameterization of
18  * the rate constant of any type.
19  */
20 template<class R>
21 class Rate1
22 {
23 public:
Rate1()24     Rate1() {}
~Rate1()25     virtual ~Rate1() {}
26 
27     /**
28      * Install a rate coefficient calculator.
29      * @param rxnNumber the reaction number
30      * @param rate rate coefficient specification for the reaction
31      */
install(size_t rxnNumber,const R & rate)32     void install(size_t rxnNumber, const R& rate) {
33         m_rxn.push_back(rxnNumber);
34         m_rates.push_back(rate);
35         m_indices[rxnNumber] = m_rxn.size() - 1;
36     }
37 
38     //! Replace an existing rate coefficient calculator
replace(size_t rxnNumber,const R & rate)39     void replace(size_t rxnNumber, const R& rate) {
40         size_t i = m_indices[rxnNumber];
41         m_rates[i] = rate;
42     }
43 
44     /**
45      * Update the concentration-dependent parts of the rate coefficient, if any.
46      * Used by class SurfaceArrhenius to compute coverage-dependent
47      * modifications to the Arrhenius parameters. The array c should contain
48      * whatever data the particular rate coefficient class needs to update its
49      * rates. Note that this method does not return anything. To get the
50      * updated rates, method update must be called after the call to update_C.
51      */
update_C(const doublereal * c)52     void update_C(const doublereal* c) {
53         for (size_t i = 0; i != m_rates.size(); i++) {
54             m_rates[i].update_C(c);
55         }
56     }
57 
58     /**
59      * Write the rate coefficients into array values. Each calculator writes one
60      * entry in values, at the location specified by the reaction number when it
61      * was installed. Note that nothing will be done for reactions that have
62      * constant rates. The array values should be preloaded with the constant
63      * rate coefficients.
64      */
update(doublereal T,doublereal logT,doublereal * values)65     void update(doublereal T, doublereal logT, doublereal* values) {
66         doublereal recipT = 1.0/T;
67         for (size_t i = 0; i != m_rates.size(); i++) {
68             values[m_rxn[i]] = m_rates[i].updateRC(logT, recipT);
69         }
70     }
71 
updateBlowersMasel(double T,double logT,double * values,double * deltaH)72     void updateBlowersMasel(double T, double logT, double* values, double* deltaH) {
73         double recipT = 1.0/T;
74         for (size_t i=0; i != m_rates.size(); i++) {
75             values[m_rxn[i]] = m_rates[i].updateRC(logT, recipT, deltaH[m_rxn[i]]);
76         }
77     }
78 
nReactions()79     size_t nReactions() const {
80         return m_rates.size();
81     }
82 
83     //! Return effective preexponent for the specified reaction.
84     /*!
85      *  Returns effective preexponent, accounting for surface coverage
86      *  dependencies. Used in InterfaceKinetics.
87      *
88      *  @param irxn Reaction number in the kinetics mechanism
89      *  @return Effective preexponent
90      */
effectivePreExponentialFactor(size_t irxn)91     double effectivePreExponentialFactor(size_t irxn) {
92         return m_rates[irxn].preExponentialFactor();
93     }
94 
95     //! Return effective activation energy for the specified reaction.
96     /*!
97      *  Returns effective activation energy, accounting for surface coverage
98      *  dependencies. Used in InterfaceKinetics.
99      *
100      *  @param irxn Reaction number in the kinetics mechanism
101      *  @return Effective activation energy divided by the gas constant
102      */
effectiveActivationEnergy_R(size_t irxn)103     double effectiveActivationEnergy_R(size_t irxn) {
104         return m_rates[irxn].activationEnergy_R();
105     }
106 
107     //! Return effective temperature exponent for the specified  reaction.
108     /*!
109      *  Returns effective temperature exponent, accounting for surface coverage
110      *  dependencies. Used in InterfaceKinetics. Current parameterization in
111      *  SurfaceArrhenius does not change this parameter with the change in
112      *  surface coverages.
113      *
114      *  @param irxn Reaction number in the kinetics mechanism
115      *  @return Effective temperature exponent
116      */
effectiveTemperatureExponent(size_t irxn)117     double effectiveTemperatureExponent(size_t irxn) {
118         return m_rates[irxn].temperatureExponent();
119     }
120 
121 protected:
122     std::vector<R> m_rates;
123     std::vector<size_t> m_rxn;
124 
125     //! map reaction number to index in m_rxn / m_rates
126     std::map<size_t, size_t> m_indices;
127 };
128 
129 }
130 
131 #endif
132