Cantera  2.1.2
AqueousKinetics.h
Go to the documentation of this file.
1 /**
2  * @file AqueousKinetics.h
3  *
4  * @ingroup chemkinetics
5  */
6 
7 // Copyright 2001 California Institute of Technology
8 
9 #ifndef CT_AQUEOUSKINETICS_H
10 #define CT_AQUEOUSKINETICS_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 
27 class ReactionData;
28 
29 /**
30  * Kinetics manager for elementary aqueous-phase chemistry. This
31  * kinetics manager implements standard mass-action reaction rate
32  * expressions for liquids
33  *
34  *
35  * Concentration
36  *
37  * @ingroup kinetics
38  * @deprecated Not actually implemented
39  */
40 class AqueousKinetics : public Kinetics
41 {
42 
43 public:
44 
45  //! @name Constructors
46  //! @{
47 
48  /// Constructor. Creates an empty reaction mechanism.
50 
51  AqueousKinetics(const AqueousKinetics& right);
52 
53  AqueousKinetics& operator=(const AqueousKinetics& right);
54 
55  //! Duplication routine for objects which inherit from Kinetics
56  /*!
57  * This virtual routine can be used to duplicate %Kinetics objects
58  * inherited from %Kinetics even if the application only has
59  * a pointer to %Kinetics to work with.
60  *
61  * These routines are basically wrappers around the derived copy constructor.
62  *
63  * @param tpVector Vector of shallow pointers to ThermoPhase objects. this is the
64  * m_thermo vector within this object
65  */
66  virtual Kinetics* duplMyselfAsKinetics(const std::vector<thermo_t*> & tpVector) const;
67  //@}
68 
69  virtual int type() const {
70  return cAqueousKinetics;
71  }
72 
73  virtual doublereal reactantStoichCoeff(size_t k, size_t i) const {
74  return m_rrxn[k][i];
75  }
76 
77  virtual doublereal productStoichCoeff(size_t k, size_t i) const {
78  return m_prxn[k][i];
79  }
80 
81  //! @name Reaction Rates Of Progress
82  //@{
83  virtual void getFwdRatesOfProgress(doublereal* fwdROP) {
84  updateROP();
85  std::copy(m_ropf.begin(), m_ropf.end(), fwdROP);
86  }
87 
88  virtual void getRevRatesOfProgress(doublereal* revROP) {
89  updateROP();
90  std::copy(m_ropr.begin(), m_ropr.end(), revROP);
91  }
92 
93  virtual void getNetRatesOfProgress(doublereal* netROP) {
94  updateROP();
95  std::copy(m_ropnet.begin(), m_ropnet.end(), netROP);
96  }
97 
98  virtual void getEquilibriumConstants(doublereal* kc);
99 
100  virtual void getDeltaGibbs(doublereal* deltaG);
101  virtual void getDeltaEnthalpy(doublereal* deltaH);
102  virtual void getDeltaEntropy(doublereal* deltaS);
103 
104  virtual void getDeltaSSGibbs(doublereal* deltaG);
105  virtual void getDeltaSSEnthalpy(doublereal* deltaH);
106  virtual void getDeltaSSEntropy(doublereal* deltaS);
107 
108  //! @}
109  //! @name Species Production Rates
110  //! @{
111 
112  virtual void getNetProductionRates(doublereal* net) {
113  updateROP();
114  m_rxnstoich.getNetProductionRates(m_kk, &m_ropnet[0], net);
115  }
116 
117  virtual void getCreationRates(doublereal* cdot) {
118  updateROP();
119  m_rxnstoich.getCreationRates(m_kk, &m_ropf[0], &m_ropr[0], cdot);
120  }
121 
122  virtual void getDestructionRates(doublereal* ddot) {
123  updateROP();
124  m_rxnstoich.getDestructionRates(m_kk, &m_ropf[0], &m_ropr[0], ddot);
125  }
126 
127  //! @}
128  //! @name Reaction Mechanism Informational Query Routines
129  //! @{
130 
131  virtual int reactionType(size_t i) const {
132  return m_index[i].first;
133  }
134 
135  virtual std::string reactionString(size_t i) const {
136  return m_rxneqn[i];
137  }
138 
139  virtual bool isReversible(size_t i) {
140  if (std::find(m_revindex.begin(), m_revindex.end(), i)
141  < m_revindex.end()) {
142  return true;
143  } else {
144  return false;
145  }
146  }
147 
148  virtual void getFwdRateConstants(doublereal* kfwd);
149  virtual void getRevRateConstants(doublereal* krev,
150  bool doIrreversible = false);
151 
152  //! @}
153  //! @name Reaction Mechanism Setup Routines
154  //! @{
155 
156  virtual void init();
157  virtual void addReaction(ReactionData& r);
158  virtual void finalize();
159  virtual bool ready() const;
160 
161  virtual void update_T();
162 
163  virtual void update_C();
164 
165  void updateROP();
166 
167  const std::vector<grouplist_t>& reactantGroups(size_t i) {
168  return m_rgroups[i];
169  }
170  const std::vector<grouplist_t>& productGroups(size_t i) {
171  return m_pgroups[i];
172  }
173 
174  /*!
175  * Update temperature-dependent portions of reaction rates and
176  * falloff functions.
177  */
178  void _update_rates_T();
179 
180  /*!
181  * Update properties that depend on concentrations. Currently only
182  * the enhanced collision partner concentrations are updated here.
183  */
184  void _update_rates_C();
185 
186  //@}
187 
188 protected:
189 
190  size_t m_nfall;
191 
192  Rate1<Arrhenius> m_rates;
193 
194  mutable std::map<size_t, std::pair<int, size_t> > m_index;
195 
196  std::vector<size_t> m_irrev;
197 
198  ReactionStoichMgr m_rxnstoich;
199 
200  std::vector<size_t> m_fwdOrder;
201 
202  size_t m_nirrev;
203  size_t m_nrev;
204 
205  std::map<size_t, std::vector<grouplist_t> > m_rgroups;
206  std::map<size_t, std::vector<grouplist_t> > m_pgroups;
207 
208  std::vector<int> m_rxntype;
209 
210  mutable std::vector<std::map<size_t, doublereal> > m_rrxn;
211  mutable std::vector<std::map<size_t, doublereal> > m_prxn;
212 
213  /**
214  * Difference between the input global reactants order
215  * and the input global products order. Changed to a double
216  * to account for the fact that we can have real-valued
217  * stoichiometries.
218  */
220  std::vector<size_t> m_revindex;
221 
222  std::vector<std::string> m_rxneqn;
223 
224  vector_fp m_conc;
225  vector_fp m_grt;
226 
227  //! @name Aqueous kinetics data
228  //!@{
229  vector_fp m_ropf;
230  vector_fp m_ropr;
231  vector_fp m_ropnet;
232  bool m_ROP_ok;
233 
234  doublereal m_temp;
235  vector_fp m_rfn;
236 
237  vector_fp m_rkcn;
238  //!@}
239 
240 private:
241 
242  size_t reactionNumber() {
243  return m_ii;
244  }
245  std::vector<std::map<int, doublereal> > m_stoich;
246 
247  void addElementaryReaction(ReactionData& r);
248 
249  void installReagents(const ReactionData& r);
250 
251  void installGroups(size_t irxn, const std::vector<grouplist_t>& r,
252  const std::vector<grouplist_t>& p);
253 
254  /**
255  * Update the equilibrium constants in molar units.
256  */
257  void updateKc();
258 
259  void registerReaction(size_t rxnNumber, int type, size_t loc) {
260  m_index[rxnNumber] = std::pair<int, size_t>(type, loc);
261  }
262  bool m_finalized;
263 };
264 }
265 
266 #endif
virtual void getNetProductionRates(size_t nsp, const doublereal *ropnet, doublereal *w)
Species net production rates.
Kinetics manager for elementary aqueous-phase chemistry.
virtual void init()
Prepare the class for the addition of reactions.
virtual void getDeltaEnthalpy(doublereal *deltaH)
Return the vector of values for the reactions change in enthalpy.
virtual void getDestructionRates(doublereal *ddot)
Species destruction rates [kmol/m^3/s or kmol/m^2/s].
virtual void getDestructionRates(size_t nSpecies, const doublereal *fwdRatesOfProgress, const doublereal *revRatesOfProgress, doublereal *destructionRates)
Species destruction rates.
virtual void getRevRatesOfProgress(doublereal *revROP)
Return the Reverse rates of progress of the reactions.
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
virtual void getCreationRates(size_t nSpecies, const doublereal *fwdRatesOfProgress, const doublereal *revRatesOfProgress, doublereal *creationRates)
Species creation rates.
Header file declaring class ReactionStoichMgr.
size_t m_kk
The number of species in all of the phases that participate in this kinetics mechanism.
Definition: Kinetics.h:891
virtual void getDeltaGibbs(doublereal *deltaG)
Return the vector of values for the reaction gibbs free energy change.
virtual void addReaction(ReactionData &r)
Add a single reaction to the mechanism.
AqueousKinetics(thermo_t *thermo=0)
Constructor. Creates an empty reaction mechanism.
virtual void getRevRateConstants(doublereal *krev, bool doIrreversible=false)
Return the reverse rate constants.
virtual void getDeltaSSEntropy(doublereal *deltaS)
Return the vector of values for the change in the standard state entropies for each reaction...
virtual std::string reactionString(size_t i) const
Return a string representing the reaction.
virtual void finalize()
Finish adding reactions and prepare for use.
virtual bool isReversible(size_t i)
True if reaction i has been declared to be reversible.
virtual void getEquilibriumConstants(doublereal *kc)
Return a vector of Equilibrium constants.
virtual void getCreationRates(doublereal *cdot)
Species creation rates [kmol/m^3/s or kmol/m^2/s].
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:101
virtual void getNetRatesOfProgress(doublereal *netROP)
Net rates of progress.
virtual doublereal reactantStoichCoeff(size_t k, size_t i) const
Stoichiometric coefficient of species k as a reactant in reaction i.
vector_fp m_dn
Difference between the input global reactants order and the input global products order...
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
Base class for kinetics managers and also contains the kineticsmgr module documentation (see Kinetics...
void updateKc()
Update the equilibrium constants in molar units.
virtual void getDeltaSSEnthalpy(doublereal *deltaH)
Return the vector of values for the change in the standard state enthalpies of reaction.
virtual int type() const
Identifies the kinetics manager type.
virtual void getNetProductionRates(doublereal *net)
Species net production rates [kmol/m^3/s or kmol/m^2/s].
virtual bool ready() const
Returns true if the kinetics manager has been properly initialized and finalized. ...
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 void getFwdRatesOfProgress(doublereal *fwdROP)
Return the forward rates of progress of the reactions.
size_t m_ii
Number of reactions in the mechanism.
Definition: Kinetics.h:887
virtual void getFwdRateConstants(doublereal *kfwd)
Return the forward rate constants.
virtual doublereal productStoichCoeff(size_t k, size_t i) const
Stoichiometric coefficient of species k as a product in reaction i.
virtual int reactionType(size_t i) const
Flag specifying the type of reaction.
virtual Kinetics * duplMyselfAsKinetics(const std::vector< thermo_t * > &tpVector) const
Duplication routine for objects which inherit from Kinetics.
virtual void getDeltaEntropy(doublereal *deltaS)
Return the vector of values for the reactions change in entropy.
virtual void getDeltaSSGibbs(doublereal *deltaG)
Return the vector of values for the reaction standard state gibbs free energy change.