Cantera  2.1.2
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 "cantera/base/utilities.h"
11 #include "RxnRates.h"
12 
13 #include "cantera/base/ct_defs.h"
16 
17 namespace Cantera
18 {
19 
20 /**
21  * This rate coefficient manager supports one parameterization of
22  * the rate constant of any type.
23  */
24 template<class R>
25 class Rate1
26 {
27 
28 public:
29 
30  Rate1() {}
31  virtual ~Rate1() {}
32 
33  /**
34  * Install a rate coefficient calculator.
35  * @param rxnNumber the reaction number
36  * @param rdata rate coefficient specification for the reaction
37  */
38  size_t install(size_t rxnNumber, const ReactionData& rdata) {
39  /*
40  * Check to see if the current reaction rate type is the same as the
41  * type of this class. If not, throw an error condition.
42  */
43  if (rdata.rateCoeffType != R::type())
44  throw CanteraError("Rate1::install",
45  "incorrect rate coefficient type: "+int2str(rdata.rateCoeffType) + ". Was Expecting type: "+ int2str(R::type()));
46 
47  // Install a rate calculator and return the index of the calculator.
48  m_rxn.push_back(rxnNumber);
49  m_rates.push_back(R(rdata));
50  return m_rates.size() - 1;
51  }
52 
53  /**
54  * Update the concentration-dependent parts of the rate
55  * coefficient, if any. Used by class SurfaceArrhenius to
56  * compute coverage-dependent * modifications to the Arrhenius
57  * parameters. The array c should contain whatever data the
58  * particular rate coefficient class needs to update its
59  * rates. Note that this method does not return anything. To
60  * get the updated rates, method update must be called after
61  * the call to update_C.
62  */
63  void update_C(const doublereal* c) {
64  for (size_t i = 0; i != m_rates.size(); i++) {
65  m_rates[i].update_C(c);
66  }
67  }
68 
69  /**
70  * Write the rate coefficients into array values. Each
71  * calculator writes one entry in values, at the location
72  * specified by the reaction number when it was
73  * installed. Note that nothing will be done for reactions
74  * that have constant rates. The array values should be
75  * preloaded with the constant rate coefficients.
76  */
77  void update(doublereal T, doublereal logT, doublereal* values) {
78  doublereal recipT = 1.0/T;
79  for (size_t i = 0; i != m_rates.size(); i++) {
80  values[m_rxn[i]] = m_rates[i].updateRC(logT, recipT);
81  }
82  }
83 
84  size_t nReactions() const {
85  return m_rates.size();
86  }
87 
88 protected:
89  std::vector<R> m_rates;
90  std::vector<size_t> m_rxn;
91 };
92 
93 }
94 
95 #endif
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
Definition: stringUtils.cpp:40
Various templated functions that carry out common vector operations (see Templated Utility Functions)...
This rate coefficient manager supports one parameterization of the rate constant of any type...
Definition: RateCoeffMgr.h:25
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
void update_C(const doublereal *c)
Update the concentration-dependent parts of the rate coefficient, if any.
Definition: RateCoeffMgr.h:63
Intermediate class which stores data about a reaction and its rate parameterization before adding the...
Definition: ReactionData.h:16
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:68
size_t install(size_t rxnNumber, const ReactionData &rdata)
Install a rate coefficient calculator.
Definition: RateCoeffMgr.h:38
void update(doublereal T, doublereal logT, doublereal *values)
Write the rate coefficients into array values.
Definition: RateCoeffMgr.h:77
int rateCoeffType
Type of the rate coefficient for the forward rate constant.
Definition: ReactionData.h:86
Contains declarations for string manipulation functions within Cantera.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...