Cantera  2.1.2
GasKinetics.h
Go to the documentation of this file.
1 /**
2  * @file GasKinetics.h
3  *
4  * @ingroup chemkinetics
5  */
6 
7 // Copyright 2001 California Institute of Technology
8 
9 #ifndef CT_GASKINETICS_H
10 #define CT_GASKINETICS_H
11 
13 #include "Kinetics.h"
14 
15 #include "cantera/base/utilities.h"
16 
17 #include "ReactionStoichMgr.h"
18 #include "ThirdBodyMgr.h"
19 #include "FalloffMgr.h"
20 #include "RateCoeffMgr.h"
21 
22 namespace Cantera
23 {
24 
25 // forward references
26 class Enhanced3BConc;
27 class ReactionData;
28 
29 /**
30  * Kinetics manager for elementary gas-phase chemistry. This
31  * kinetics manager implements standard mass-action reaction rate
32  * expressions for low-density gases.
33  * @ingroup kinetics
34  */
35 class GasKinetics : public Kinetics
36 {
37 public:
38  //! @name Constructors and General Information
39  //! @{
40 
41  //! Constructor.
42  /*!
43  * @param thermo Pointer to the gas ThermoPhase (optional)
44  */
46 
47  //! Copy Constructor
48  GasKinetics(const GasKinetics& right);
49 
50  //! Assignment operator
51  GasKinetics& operator=(const GasKinetics& right);
52 
53  virtual Kinetics* duplMyselfAsKinetics(const std::vector<thermo_t*> & tpVector) const;
54 
55  virtual int type() const {
56  return cGasKinetics;
57  }
58 
59  virtual doublereal reactantStoichCoeff(size_t k, size_t i) const {
60  return m_rrxn[k][i];
61  }
62 
63  virtual doublereal productStoichCoeff(size_t k, size_t i) const {
64  return m_prxn[k][i];
65  }
66 
67  //! @}
68  //! @name Reaction Rates Of Progress
69  //! @{
70 
71  virtual void getFwdRatesOfProgress(doublereal* fwdROP) {
72  updateROP();
73  std::copy(m_ropf.begin(), m_ropf.end(), fwdROP);
74  }
75 
76  virtual void getRevRatesOfProgress(doublereal* revROP) {
77  updateROP();
78  std::copy(m_ropr.begin(), m_ropr.end(), revROP);
79  }
80 
81  virtual void getNetRatesOfProgress(doublereal* netROP) {
82  updateROP();
83  std::copy(m_ropnet.begin(), m_ropnet.end(), netROP);
84  }
85 
86  virtual void getEquilibriumConstants(doublereal* kc);
87  virtual void getDeltaGibbs(doublereal* deltaG);
88  virtual void getDeltaEnthalpy(doublereal* deltaH);
89  virtual void getDeltaEntropy(doublereal* deltaS);
90 
91  virtual void getDeltaSSGibbs(doublereal* deltaG);
92  virtual void getDeltaSSEnthalpy(doublereal* deltaH);
93  virtual void getDeltaSSEntropy(doublereal* deltaS);
94 
95  //! @}
96  //! @name Species Production Rates
97  //! @{
98 
99  virtual void getNetProductionRates(doublereal* net);
100  virtual void getCreationRates(doublereal* cdot);
101  virtual void getDestructionRates(doublereal* ddot);
102 
103  //! @}
104  //! @name Reaction Mechanism Informational Query Routines
105  //! @{
106 
107  virtual int reactionType(size_t i) const {
108  return m_index[i].first;
109  }
110 
111  virtual std::string reactionString(size_t i) const {
112  return m_rxneqn[i];
113  }
114 
115  virtual bool isReversible(size_t i) {
116  if (std::find(m_revindex.begin(), m_revindex.end(), i)
117  < m_revindex.end()) {
118  return true;
119  } else {
120  return false;
121  }
122  }
123 
124  virtual void getFwdRateConstants(doublereal* kfwd);
125 
126  virtual void getRevRateConstants(doublereal* krev,
127  bool doIrreversible = false);
128 
129  //! @}
130  //! @name Reaction Mechanism Setup Routines
131  //! @{
132  virtual void init();
133  virtual void addReaction(ReactionData& r);
134  virtual void finalize();
135  virtual bool ready() const;
136  //@}
137 
138  void updateROP();
139 
140  const std::vector<grouplist_t>& reactantGroups(size_t i) {
141  return m_rgroups[i];
142  }
143  const std::vector<grouplist_t>& productGroups(size_t i) {
144  return m_pgroups[i];
145  }
146 
147  //! Update temperature-dependent portions of reaction rates and falloff
148  //! functions.
149  virtual void update_rates_T();
150 
151  //! Update properties that depend on concentrations.
152  //! Currently the enhanced collision partner concentrations are updated
153  //! here, as well as the pressure-dependent portion of P-log and Chebyshev
154  //! reactions.
155  virtual void update_rates_C();
156 
157 protected:
158  size_t m_nfall;
159 
160  std::vector<size_t> m_fallindx;
161 
162  Rate1<Arrhenius> m_falloff_low_rates;
163  Rate1<Arrhenius> m_falloff_high_rates;
164  Rate1<Arrhenius> m_rates;
165 
166  mutable std::map<size_t, std::pair<int, size_t> > m_index;
167 
168  FalloffMgr m_falloffn;
169 
170  ThirdBodyMgr<Enhanced3BConc> m_3b_concm;
171  ThirdBodyMgr<Enhanced3BConc> m_falloff_concm;
172 
173  std::vector<size_t> m_irrev;
174 
175  Rate1<Plog> m_plog_rates;
176  Rate1<ChebyshevRate> m_cheb_rates;
177 
178  ReactionStoichMgr m_rxnstoich;
179 
180  std::vector<size_t> m_fwdOrder;
181 
182  size_t m_nirrev;
183  size_t m_nrev;
184 
185  std::map<size_t, std::vector<grouplist_t> > m_rgroups;
186  std::map<size_t, std::vector<grouplist_t> > m_pgroups;
187 
188  std::vector<int> m_rxntype;
189 
190  mutable std::vector<std::map<size_t, doublereal> > m_rrxn;
191  mutable std::vector<std::map<size_t, doublereal> > m_prxn;
192 
193  /**
194  * Difference between the input global reactants order
195  * and the input global products order. Changed to a double
196  * to account for the fact that we can have real-valued
197  * stoichiometries.
198  */
200  std::vector<size_t> m_revindex;
201 
202  std::vector<std::string> m_rxneqn;
203 
204  //! @name Reaction rate data
205  //!@{
206  doublereal m_logp_ref;
207  doublereal m_logc_ref;
208  doublereal m_logStandConc;
209  vector_fp m_ropf;
210  vector_fp m_ropr;
211  vector_fp m_ropnet;
212  vector_fp m_rfn_low;
213  vector_fp m_rfn_high;
214  bool m_ROP_ok;
215 
216  doublereal m_temp;
217  doublereal m_pres; //!< Last pressure at which rates were evaluated
218  vector_fp m_rfn;
219  vector_fp falloff_work;
220  vector_fp concm_3b_values;
221  vector_fp concm_falloff_values;
222  vector_fp m_rkcn;
223  //!@}
224 
225  vector_fp m_conc;
226  void processFalloffReactions();
227  vector_fp m_grt;
228 
229 private:
230  size_t reactionNumber() {
231  return m_ii;
232  }
233  std::vector<std::map<int, doublereal> > m_stoich;
234 
235  void addElementaryReaction(ReactionData& r);
236  void addThreeBodyReaction(ReactionData& r);
237  void addFalloffReaction(ReactionData& r);
238  void addPlogReaction(ReactionData& r);
239  void addChebyshevReaction(ReactionData& r);
240 
241  void installReagents(const ReactionData& r);
242 
243  void installGroups(size_t irxn, const std::vector<grouplist_t>& r,
244  const std::vector<grouplist_t>& p);
245 
246  //! Update the equilibrium constants in molar units.
247  void updateKc();
248 
249  void registerReaction(size_t rxnNumber, int type_, size_t loc) {
250  m_index[rxnNumber] = std::pair<int, size_t>(type_, loc);
251  }
252  bool m_finalized;
253 };
254 }
255 
256 #endif
virtual std::string reactionString(size_t i) const
Return a string representing the reaction.
Definition: GasKinetics.h:111
vector_fp m_dn
Difference between the input global reactants order and the input global products order...
Definition: GasKinetics.h:199
Various templated functions that carry out common vector operations (see Templated Utility Functions)...
thermo_t & thermo(size_t n=0)
This method returns a reference to the nth ThermoPhase object defined in this kinetics mechanism...
Definition: Kinetics.h:288
Header file declaring class ReactionStoichMgr.
virtual void getFwdRateConstants(doublereal *kfwd)
Return the forward rate constants.
virtual void getDeltaSSEntropy(doublereal *deltaS)
Return the vector of values for the change in the standard state entropies for each reaction...
virtual void getRevRatesOfProgress(doublereal *revROP)
Return the Reverse rates of progress of the reactions.
Definition: GasKinetics.h:76
virtual void init()
Prepare the class for the addition of reactions.
virtual void getNetProductionRates(doublereal *net)
Species net production rates [kmol/m^3/s or kmol/m^2/s].
Kinetics manager for elementary gas-phase chemistry.
Definition: GasKinetics.h:35
virtual void update_rates_T()
Update temperature-dependent portions of reaction rates and falloff functions.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:101
virtual void getEquilibriumConstants(doublereal *kc)
Return a vector of Equilibrium constants.
virtual bool ready() const
Returns true if the kinetics manager has been properly initialized and finalized. ...
virtual void getDestructionRates(doublereal *ddot)
Species destruction rates [kmol/m^3/s or kmol/m^2/s].
virtual void getDeltaEntropy(doublereal *deltaS)
Return the vector of values for the reactions change in entropy.
virtual void getDeltaSSEnthalpy(doublereal *deltaH)
Return the vector of values for the change in the standard state enthalpies of reaction.
virtual void getCreationRates(doublereal *cdot)
Species creation rates [kmol/m^3/s or kmol/m^2/s].
virtual doublereal reactantStoichCoeff(size_t k, size_t i) const
Stoichiometric coefficient of species k as a reactant in reaction i.
Definition: GasKinetics.h:59
void updateKc()
Update the equilibrium constants in molar units.
Public interface for kinetics managers.
Definition: Kinetics.h:131
Intermediate class which stores data about a reaction and its rate parameterization before adding the...
Definition: ReactionData.h:16
virtual doublereal productStoichCoeff(size_t k, size_t i) const
Stoichiometric coefficient of species k as a product in reaction i.
Definition: GasKinetics.h:63
GasKinetics(thermo_t *thermo=0)
Constructor.
Definition: GasKinetics.cpp:21
Base class for kinetics managers and also contains the kineticsmgr module documentation (see Kinetics...
virtual void getFwdRatesOfProgress(doublereal *fwdROP)
Return the forward rates of progress of the reactions.
Definition: GasKinetics.h:71
virtual Kinetics * duplMyselfAsKinetics(const std::vector< thermo_t * > &tpVector) const
Duplication routine for objects which inherit from Kinetics.
virtual bool isReversible(size_t i)
True if reaction i has been declared to be reversible.
Definition: GasKinetics.h:115
virtual void getNetRatesOfProgress(doublereal *netROP)
Net rates of progress.
Definition: GasKinetics.h:81
virtual void getRevRateConstants(doublereal *krev, bool doIrreversible=false)
Return the reverse rate constants.
virtual void update_rates_C()
Update properties that depend on concentrations.
GasKinetics & operator=(const GasKinetics &right)
Assignment operator.
Definition: GasKinetics.cpp:57
virtual void getDeltaSSGibbs(doublereal *deltaG)
Return the vector of values for the reaction standard state gibbs free energy change.
virtual void getDeltaGibbs(doublereal *deltaG)
Return the vector of values for the reaction gibbs free energy change.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:165
virtual int type() const
Identifies the kinetics manager type.
Definition: GasKinetics.h:55
virtual void addReaction(ReactionData &r)
Add a single reaction to the mechanism.
doublereal m_pres
Last pressure at which rates were evaluated.
Definition: GasKinetics.h:217
size_t m_ii
Number of reactions in the mechanism.
Definition: Kinetics.h:887
virtual void getDeltaEnthalpy(doublereal *deltaH)
Return the vector of values for the reactions change in enthalpy.
virtual int reactionType(size_t i) const
Flag specifying the type of reaction.
Definition: GasKinetics.h:107
virtual void finalize()
Finish adding reactions and prepare for use.