Cantera  2.0
Reaction.h
Go to the documentation of this file.
1 /**
2  * @file Reaction.h
3  *
4  */
5 
6 // Copyright 2001 California Institute of Technology
7 
8 
9 #ifndef CKR_REACTION_H
10 #define CKR_REACTION_H
11 
12 #include <string>
13 #include <vector>
14 #include <map>
15 #include <ostream>
16 
17 #include "ckr_defs.h"
18 #include "ckr_utils.h"
19 #include "RxnSpecies.h"
20 
21 namespace ckr
22 {
23 
24 
25 /** @name Reaction Types
26  */
27 
28 //@{
29 const int Elementary = 2000; ///< elementary, pressure-independent reaction
30 const int ThreeBody = 2001; ///< three-body reaction
31 const int Falloff = 2002; ///< falloff reaction
32 const int ChemAct = 2003; ///< chemical activation reaction
33 //@}
34 
35 /**
36  * Reaction rate coefficient class. For simplicity, the RateCoeff
37  * class has public members representing the parameters of all rate
38  * coefficient types supported by Chemkin. The 'type' attribute
39  * specifies the rate coefficient type.
40  */
41 class RateCoeff
42 {
43 public:
44 
45  /**
46  * Constructor. Construct a default rate coefficient object. The
47  * type is set to Arrhenius, and all parameter values are set to
48  * zero.
49  */
50  RateCoeff() : A(0.0), n(0.0), E(0.0),
51  B(0.0), C(0.0), type(Arrhenius) {}
52 
53  /**
54  * Copy constructor
55  */
56  RateCoeff(const RateCoeff& k) : A(k.A), n(k.n), E(k.E),
57  B(k.B), C(k.C), type(k.type), b(k.b) {}
58 
59  /// Destructor. Does nothing.
61 
62  RateCoeff& operator=(const RateCoeff& k) {
63  if (this == &k) {
64  return *this;
65  }
66  A = k.A;
67  n = k.n;
68  E = k.E;
69  B = k.B;
70  C = k.C;
71  type = k.type;
72  b = k.b;
73  return *this;
74  }
75 
76  // Modified Arrhenius parameters, common to all types.
77  double A; ///< pre-exponential factor (all types)
78  double n; ///< temperature exponent (all types)
79  double E; ///< activation energy (all types)
80 
81  // Landau-Teller parameters
82  double B; ///< Landau-Teller B parameter
83  double C; ///< Landau-Teller C parameter
84 
85  int type; ///< rate coefficient type
86 
87  // Coefficients for the special forms allowed by Chemkin-III
88  vector_fp b; ///< coefficients for JAN or FIT1 form
89 
90 };
91 
92 
93 //////////////////////////////////////////////////////////////////////////
94 
95 //! Specifies the Units for all reactions
96 /**
97  * The default units are Cal per gmol for the activivation units
98  * and the default number type is assumed to be gmol.
99  */
101 {
102 public:
103  ReactionUnits() :
104  ActEnergy(ckr::Cal_per_Mole),
105  Quantity(ckr::Moles) { }
106 
107  int ActEnergy; ///< Activation energy unit flag
108  int Quantity; ///< Moles or molecules unit flag
109 };
110 
111 
112 //////////////////////////////////////////////////////////////////////////
113 
114 
115 /// A class for reactions.
116 
117 // Note: if you add data items to this class, be sure to update
118 // the copy constructor and the assignment operator !
119 
120 class Reaction
121 {
122 public:
123 
124  /// a list of auxiliary data values
125  typedef vector_fp auxdata;
126 
127  /// Construct an empty Reaction object
129  isFalloffRxn(false),
130  isChemActRxn(false),
131  isThreeBodyRxn(false),
132  isReversible(false),
133  isDuplicate(false),
134  duplicate(0),
135  thirdBody("<none>"),
136  number(0),
137  falloffType(Lindemann) {}
138 
139  /// Copy constructor
140  Reaction(const Reaction& r) : type(r.type),
146  duplicate(r.duplicate),
147  thirdBody(r.thirdBody),
148  number(r.number),
149  reactants(r.reactants),
150  fwdOrder(r.fwdOrder),
151  products(r.products),
152  e3b(r.e3b),
153  kf(r.kf),
154  kf_aux(r.kf_aux),
155  krev(r.krev),
156  falloffType(r.falloffType),
157  falloffParameters(r.falloffParameters),
159  lines(r.lines), comment(r.comment) {}
160 
161  /// Destructor
162  virtual ~Reaction() {}
163 
164  Reaction& operator=(const Reaction& r);
165 
166  int type; ///< Reaction type.
167 
168  bool isFalloffRxn; ///< True if reaction is a falloff reaction.
169  bool isChemActRxn; ///< True if reaction is a chemical activation reaction.
170  bool isThreeBodyRxn; ///< True if reaction is a three-body reaction.
171  bool isReversible; ///< True if reaction is reversible.
172  bool isDuplicate; ///< True if reaction is declared to be a duplicate;
173 
174  /**
175  * reaction number this one is a duplicate to (declared or not).
176  * If the reaction is not a duplicate, the value is zero.
177  */
179 
180  /**
181  * For pressure-dependent reactions (including three-body ones)
182  * this string contains either "M" if all species may act as
183  * third body collision partners, or a species name if only
184  * one species does.
185  */
186  std::string thirdBody;
187 
188  /// Reaction number.
189  int number;
190 
191  /**
192  * list of species that participate as reactants,
193  * and their stoichiometric coefficients
194  */
195  std::vector<RxnSpecies> reactants;
196 
197  mutable std::map<std::string, double> fwdOrder;
198 
199  /**
200  * list of species that participate as products,
201  * and their stoichiometric coefficients
202  */
203  std::vector<RxnSpecies> products;
204 
205 
206  /**
207  * map from species names to enhanced third-body collision efficiencies
208  */
209  mutable std::map<std::string, double> e3b;
210 
211  /**
212  * Forward rate coefficient. For falloff reactions, this is the
213  * high-pressure rate coefficient, and for chemical activation
214  * reactions it is the low-pressure one.
215  */
217 
218  /**
219  * For pressure-dependent reactions, the rate coefficient for the
220  * opposite pressure limit as kf (
221  */
223 
224  /// Reverse rate coefficient. Empty unless REV auxiliary data given.
226 
227 
228  int falloffType;
229  vector_fp falloffParameters;
230 
231  /**
232  * auxiliary data not handled elsewhere.
233  */
234  mutable std::map<std::string, auxdata> otherAuxData;
235 
236  /**
237  * input file lines
238  */
239  std::vector<std::string> lines;
240 
241  /**
242  * comments
243  */
244  std::vector<std::string> comment;
245 
246  // methods
247 
248  double stoichCoefficient(const std::string& s) const;
249  bool operator==(const Reaction& r) const;
250  void write(std::ostream& s) const;
251 
252 };
253 
254 /// a list of Reaction objects
255 typedef std::vector<Reaction> reactionList;
256 
257 Reaction forwardReaction(const Reaction& rxn);
258 Reaction reverseReaction(const Reaction& rxn);
259 }
260 
261 #endif