Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RateCoeffMgr.h
Go to the documentation of this file.
1 /**
2  * @file RateCoeffMgr.h
3  */
4 // Copyright 2001 California Institute of Technology
5 
6 
7 #ifndef CT_RATECOEFF_MGR_H
8 #define CT_RATECOEFF_MGR_H
9 
10 #include "RxnRates.h"
11 
12 namespace Cantera
13 {
14 
15 /**
16  * This rate coefficient manager supports one parameterization of
17  * the rate constant of any type.
18  */
19 template<class R>
20 class Rate1
21 {
22 
23 public:
24 
25  Rate1() {}
26  virtual ~Rate1() {}
27 
28  /**
29  * Install a rate coefficient calculator.
30  * @param rxnNumber the reaction number
31  * @param rdata rate coefficient specification for the reaction
32  */
33  size_t install(size_t rxnNumber, const ReactionData& rdata) {
34  /*
35  * Check to see if the current reaction rate type is the same as the
36  * type of this class. If not, throw an error condition.
37  */
38  if (rdata.rateCoeffType != R::type())
39  throw CanteraError("Rate1::install",
40  "incorrect rate coefficient type: "+int2str(rdata.rateCoeffType) + ". Was Expecting type: "+ int2str(R::type()));
41 
42  // Install a rate calculator and return the index of the calculator.
43  m_rxn.push_back(rxnNumber);
44  m_rates.push_back(R(rdata));
45  m_indices[rxnNumber] = m_rxn.size() - 1;
46  return m_rates.size() - 1;
47  }
48 
49  /**
50  * Install a rate coefficient calculator.
51  * @param rxnNumber the reaction number
52  * @param rate rate coefficient specification for the reaction
53  */
54  void install(size_t rxnNumber, const R& rate) {
55  m_rxn.push_back(rxnNumber);
56  m_rates.push_back(rate);
57  m_indices[rxnNumber] = m_rxn.size() - 1;
58  }
59 
60  //! Replace an existing rate coefficient calculator
61  void replace(size_t rxnNumber, const R& rate) {
62  size_t i = m_indices[rxnNumber];
63  m_rates[i] = rate;
64  }
65 
66  /**
67  * Update the concentration-dependent parts of the rate
68  * coefficient, if any. Used by class SurfaceArrhenius to
69  * compute coverage-dependent * modifications to the Arrhenius
70  * parameters. The array c should contain whatever data the
71  * particular rate coefficient class needs to update its
72  * rates. Note that this method does not return anything. To
73  * get the updated rates, method update must be called after
74  * the call to update_C.
75  */
76  void update_C(const doublereal* c) {
77  for (size_t i = 0; i != m_rates.size(); i++) {
78  m_rates[i].update_C(c);
79  }
80  }
81 
82  /**
83  * Write the rate coefficients into array values. Each
84  * calculator writes one entry in values, at the location
85  * specified by the reaction number when it was
86  * installed. Note that nothing will be done for reactions
87  * that have constant rates. The array values should be
88  * preloaded with the constant rate coefficients.
89  */
90  void update(doublereal T, doublereal logT, doublereal* values) {
91  doublereal recipT = 1.0/T;
92  for (size_t i = 0; i != m_rates.size(); i++) {
93  values[m_rxn[i]] = m_rates[i].updateRC(logT, recipT);
94  }
95  }
96 
97  size_t nReactions() const {
98  return m_rates.size();
99  }
100 
101 protected:
102  std::vector<R> m_rates;
103  std::vector<size_t> m_rxn;
104 
105  //! map reaction number to index in m_rxn / m_rates
106  std::map<size_t, size_t> m_indices;
107 };
108 
109 }
110 
111 #endif
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
Definition: stringUtils.cpp:39
void install(size_t rxnNumber, const R &rate)
Install a rate coefficient calculator.
Definition: RateCoeffMgr.h:54
std::map< size_t, size_t > m_indices
map reaction number to index in m_rxn / m_rates
Definition: RateCoeffMgr.h:106
This rate coefficient manager supports one parameterization of the rate constant of any type...
Definition: RateCoeffMgr.h:20
void update_C(const doublereal *c)
Update the concentration-dependent parts of the rate coefficient, if any.
Definition: RateCoeffMgr.h:76
Intermediate class which stores data about a reaction and its rate parameterization before adding the...
Definition: ReactionData.h:22
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:99
size_t install(size_t rxnNumber, const ReactionData &rdata)
Install a rate coefficient calculator.
Definition: RateCoeffMgr.h:33
void update(doublereal T, doublereal logT, doublereal *values)
Write the rate coefficients into array values.
Definition: RateCoeffMgr.h:90
int rateCoeffType
Type of the rate coefficient for the forward rate constant.
Definition: ReactionData.h:147
void replace(size_t rxnNumber, const R &rate)
Replace an existing rate coefficient calculator.
Definition: RateCoeffMgr.h:61