Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Kinetics.h
Go to the documentation of this file.
1 /**
2  * @file Kinetics.h
3  * Base class for kinetics managers and also contains the kineticsmgr
4  * module documentation (see \ref kineticsmgr and class
5  * \link Cantera::Kinetics Kinetics\endlink).
6  */
7 
8 // Copyright 2001-2004 California Institute of Technology
9 
10 #ifndef CT_KINETICS_H
11 #define CT_KINETICS_H
12 
14 #include "StoichManager.h"
16 #include "cantera/base/global.h"
17 #include "cantera/base/smart_ptr.h"
18 
19 namespace Cantera
20 {
21 
22 // forward references
23 class ReactionData;
24 class Reaction;
25 
26 /**
27  * @defgroup chemkinetics Chemical Kinetics
28  */
29 
30 /// @defgroup kineticsmgr Kinetics Managers
31 /// @section kinmodman Models and Managers
32 ///
33 /// A kinetics manager is a C++ class that implements a kinetics
34 /// model; a kinetics model is a set of mathematical equation
35 /// describing how various kinetic quantities are to be computed --
36 /// reaction rates, species production rates, etc. Many different
37 /// kinetics models might be defined to handle different types of
38 /// kinetic processes. For example, one kinetics model might use
39 /// expressions valid for elementary reactions in ideal gas
40 /// mixtures. It might, for example, require the reaction orders
41 /// to be integral and equal to the forward stoichiometric
42 /// coefficients, require that each reaction be reversible with a
43 /// reverse rate satisfying detailed balance, include
44 /// pressure-dependent unimolecular reactions, etc. Another
45 /// kinetics model might be designed for heterogeneous chemistry
46 /// at interfaces, and might allow empirical reaction orders,
47 /// coverage-dependent activation energies, irreversible
48 /// reactions, and include effects of potential differences across
49 /// the interface on reaction rates.
50 ///
51 /// A kinetics manager implements a kinetics model. Since the
52 /// model equations may be complex and expensive to evaluate, a
53 /// kinetics manager may adopt various strategies to 'manage' the
54 /// computation and evaluate the expressions efficiently. For
55 /// example, if there are rate coefficients or other quantities
56 /// that depend only on temperature, a manager class may choose to
57 /// store these quantities internally, and re-evaluate them only
58 /// when the temperature has actually changed. Or a manager
59 /// designed for use with reaction mechanisms with a few repeated
60 /// activation energies might precompute the terms \f$ exp(-E/RT)
61 /// \f$, instead of evaluating the exponential repeatedly for each
62 /// reaction. There are many other possible 'management styles',
63 /// each of which might be better suited to some reaction
64 /// mechanisms than others.
65 ///
66 /// But however a manager structures the internal computation, the
67 /// tasks the manager class must perform are, for the most part,
68 /// the same. It must be able to compute reaction rates, species
69 /// production rates, equilibrium constants, etc. Therefore, all
70 /// kinetics manager classes should have a common set of public
71 /// methods, but differ in how they implement these methods.
72 ///
73 /// A kinetics manager computes reaction rates of progress,
74 /// species production rates, equilibrium constants, and similar
75 /// quantities for a reaction mechanism. All kinetics manager
76 /// classes derive from class Kinetics, which defines a common
77 /// public interface for all kinetics managers. Each derived class
78 /// overloads the virtual methods of Kinetics to implement a
79 /// particular kinetics model.
80 ///
81 /// For example, class GasKinetics implements reaction rate
82 /// expressions appropriate for homogeneous reactions in ideal gas
83 /// mixtures, and class InterfaceKinetics implements expressions
84 /// appropriate for heterogeneous mechanisms at interfaces,
85 /// including how to handle reactions involving charged species of
86 /// phases with different electric potentials --- something that
87 /// class GasKinetics doesn't deal with at all.
88 ///
89 /// Many of the methods of class Kinetics write into arrays the
90 /// values of some quantity for each species, for example the net
91 /// production rate. These methods always write the results into
92 /// flat arrays, ordered by phase in the order the phase was
93 /// added, and within a phase in the order the species were added
94 /// to the phase (which is the same ordering as in the input
95 /// file). Example: suppose a heterogeneous mechanism involves
96 /// three phases -- a bulk phase 'a', another bulk phase 'b', and
97 /// the surface phase 'a:b' at the a/b interface. Phase 'a'
98 /// contains 12 species, phase 'b' contains 3, and at the
99 /// interface there are 5 adsorbed species defined in phase
100 /// 'a:b'. Then methods like getNetProductionRates(doublereal* net)
101 /// will write and output array of length 20, beginning at the location
102 /// pointed to by 'net'. The first 12 values will be the net production
103 /// rates for all 12 species of phase 'a' (even if some do not participate
104 /// in the reactions), the next 3 will be for phase 'b', and finally the
105 /// net production rates for the surface species will occupy the last
106 /// 5 locations.
107 /// @ingroup chemkinetics
108 
109 
110 //! Public interface for kinetics managers.
111 /*!
112  * This class serves as a base class to derive 'kinetics
113  * managers', which are classes that manage homogeneous chemistry
114  * within one phase, or heterogeneous chemistry at one
115  * interface. The virtual methods of this class are meant to be
116  * overloaded in subclasses. The non-virtual methods perform
117  * generic functions and are implemented in Kinetics. They should
118  * not be overloaded. Only those methods required by a subclass
119  * need to be overloaded; the rest will throw exceptions if
120  * called.
121  *
122  * When the nomenclature "kinetics species index" is used below,
123  * this means that the species index ranges over all species in
124  * all phases handled by the kinetics manager.
125  *
126  * @ingroup kineticsmgr
127  */
128 class Kinetics
129 {
130 
131 public:
132  /**
133  * @name Constructors and General Information about Mechanism
134  */
135  //@{
136 
137  /// Default constructor.
138  Kinetics();
139 
140  /// Destructor.
141  virtual ~Kinetics();
142 
143  //!Copy Constructor for the Kinetics object.
144  Kinetics(const Kinetics&);
145 
146  //! Assignment operator
147  /*!
148  * @param right Reference to Kinetics object to be copied into the
149  * current one.
150  */
151  Kinetics& operator=(const Kinetics& right);
152 
153  //! Duplication routine for objects which inherit from Kinetics
154  /*!
155  * This function can be used to duplicate objects derived from Kinetics
156  * even if the application only has a pointer to Kinetics to work with.
157  *
158  * These routines are basically wrappers around the derived copy
159  * constructor.
160  *
161  * @param tpVector Vector of pointers to ThermoPhase objects. this is the
162  * #m_thermo vector within this object
163  */
164  virtual Kinetics* duplMyselfAsKinetics(const std::vector<thermo_t*> & tpVector) const;
165 
166  //! Reassign the pointers within the Kinetics object
167  /*!
168  * This type or routine is necessary because the Kinetics object doesn't
169  * own the ThermoPhase objects. After a duplication, we need to point to
170  * different ThermoPhase objects.
171  *
172  * We check that the ThermoPhase objects are aligned in the same order and have
173  * the following identical properties to the ones that they are replacing:
174  *
175  * - ThermoPhase::id()
176  * - ThermoPhase::eosType()
177  * - ThermoPhase::nSpecies()
178  *
179  * @param tpVector Vector of pointers to ThermoPhase objects. this is the
180  * #m_thermo vector within this object
181  */
182  virtual void assignShallowPointers(const std::vector<thermo_t*> & tpVector);
183 
184  //! Identifies the kinetics manager type.
185  /*!
186  * Each class derived from Kinetics should overload this method to
187  * return a unique integer. Standard values are defined in file
188  * mix_defs.h.
189  */
190  virtual int type() const;
191 
192  //! Number of reactions in the reaction mechanism.
193  size_t nReactions() const {
194  return m_ii;
195  }
196 
197  //! Check that the specified reaction index is in range
198  //! Throws an exception if i is greater than nReactions()
199  void checkReactionIndex(size_t m) const;
200 
201  //! Check that an array size is at least nReactions()
202  //! Throws an exception if ii is less than nReactions(). Used before calls
203  //! which take an array pointer.
204  void checkReactionArraySize(size_t ii) const;
205 
206  //! Check that the specified species index is in range
207  //! Throws an exception if k is greater than nSpecies()-1
208  void checkSpeciesIndex(size_t k) const;
209 
210  //! Check that an array size is at least nSpecies()
211  //! Throws an exception if kk is less than nSpecies(). Used before calls
212  //! which take an array pointer.
213  void checkSpeciesArraySize(size_t mm) const;
214 
215  //@}
216  //! @name Information/Lookup Functions about Phases and Species
217  //@{
218 
219  /**
220  * The number of phases participating in the reaction
221  * mechanism. For a homogeneous reaction mechanism, this will
222  * always return 1, but for a heterogeneous mechanism it will
223  * return the total number of phases in the mechanism.
224  */
225  size_t nPhases() const {
226  return m_thermo.size();
227  }
228 
229  //! Check that the specified phase index is in range
230  //! Throws an exception if m is greater than nPhases()
231  void checkPhaseIndex(size_t m) const;
232 
233  //! Check that an array size is at least nPhases()
234  //! Throws an exception if mm is less than nPhases(). Used before calls
235  //! which take an array pointer.
236  void checkPhaseArraySize(size_t mm) const;
237 
238  /**
239  * Return the phase index of a phase in the list of phases
240  * defined within the object.
241  *
242  * @param ph std::string name of the phase
243  *
244  * If a -1 is returned, then the phase is not defined in
245  * the Kinetics object.
246  */
247  size_t phaseIndex(const std::string& ph) {
248  if (m_phaseindex.find(ph) == m_phaseindex.end()) {
249  return npos;
250  } else {
251  return m_phaseindex[ph] - 1;
252  }
253  }
254 
255  /**
256  * This returns the integer index of the phase which has ThermoPhase type
257  * cSurf. For heterogeneous mechanisms, this identifies the one surface
258  * phase. For homogeneous mechanisms, this returns -1.
259  */
260  size_t surfacePhaseIndex() {
261  return m_surfphase;
262  }
263 
264  /**
265  * Phase where the reactions occur. For heterogeneous mechanisms, one of
266  * the phases in the list of phases represents the 2D interface or 1D edge
267  * at which the reactions take place. This method returns the index of the
268  * phase with the smallest spatial dimension (1, 2, or 3) among the list
269  * of phases. If there is more than one, the index of the first one is
270  * returned. For homogeneous mechanisms, the value 0 is returned.
271  */
273  return m_rxnphase;
274  }
275 
276  /**
277  * This method returns a reference to the nth ThermoPhase object defined
278  * in this kinetics mechanism. It is typically used so that member
279  * functions of the ThermoPhase object may be called. For homogeneous
280  * mechanisms, there is only one object, and this method can be called
281  * without an argument to access it.
282  *
283  * @param n Index of the ThermoPhase being sought.
284  */
285  thermo_t& thermo(size_t n=0) {
286  return *m_thermo[n];
287  }
288  const thermo_t& thermo(size_t n=0) const {
289  return *m_thermo[n];
290  }
291 
292  /**
293  * The total number of species in all phases participating in the kinetics
294  * mechanism. This is useful to dimension arrays for use in calls to
295  * methods that return the species production rates, for example.
296  */
297  size_t nTotalSpecies() const {
298  return m_kk;
299  }
300 
301  /**
302  * The location of species k of phase n in species arrays.
303  * Kinetics manager classes return species production rates in
304  * flat arrays, with the species of each phases following one
305  * another, in the order the phases were added. This method
306  * is useful to find the value for a particular species of a
307  * particular phase in arrays returned from methods like
308  * getCreationRates that return an array of species-specific
309  * quantities.
310  *
311  * Example: suppose a heterogeneous mechanism involves three
312  * phases. The first contains 12 species, the second 26, and
313  * the third 3. Then species arrays must have size at least
314  * 41, and positions 0 - 11 are the values for the species in
315  * the first phase, positions 12 - 37 are the values for the
316  * species in the second phase, etc. Then
317  * kineticsSpeciesIndex(7, 0) = 7, kineticsSpeciesIndex(4, 1)
318  * = 16, and kineticsSpeciesIndex(2, 2) = 40.
319  *
320  * @param k species index
321  * @param n phase index for the species
322  */
323  size_t kineticsSpeciesIndex(size_t k, size_t n) const {
324  return m_start[n] + k;
325  }
326 
327  //! Return the name of the kth species in the kinetics manager.
328  /*!
329  * k is an integer from 0 to ktot - 1, where ktot is the number of
330  * species in the kinetics manager, which is the sum of the number of
331  * species in all phases participating in the kinetics manager. If k is
332  * out of bounds, the string "<unknown>" is returned.
333  *
334  * @param k species index
335  */
336  std::string kineticsSpeciesName(size_t k) const;
337 
338  /**
339  * This routine will look up a species number based on the input
340  * std::string nm. The lookup of species will occur for all phases
341  * listed in the kinetics object.
342  *
343  * return
344  * - If a match is found, the position in the species list is returned.
345  * - If no match is found, the value -1 is returned.
346  *
347  * @param nm Input string name of the species
348  */
349  size_t kineticsSpeciesIndex(const std::string& nm) const;
350 
351  /**
352  * This routine will look up a species number based on the input
353  * std::string nm. The lookup of species will occur in the specified
354  * phase of the object, or all phases if ph is "<any>".
355  *
356  * return
357  * - If a match is found, the position in the species list is returned.
358  * - If no match is found, the value npos (-1) is returned.
359  *
360  * @param nm Input string name of the species
361  * @param ph Input string name of the phase.
362  */
363  size_t kineticsSpeciesIndex(const std::string& nm,
364  const std::string& ph) const;
365 
366  /**
367  * This function looks up the name of a species and returns a
368  * reference to the ThermoPhase object of the phase where the species
369  * resides. Will throw an error if the species doesn't match.
370  *
371  * @param nm String containing the name of the species.
372  */
373  thermo_t& speciesPhase(const std::string& nm);
374 
375  /**
376  * This function takes as an argument the kineticsSpecies index
377  * (i.e., the list index in the list of species in the kinetics
378  * manager) and returns the species' owning ThermoPhase object.
379  *
380  * @param k Species index
381  */
382  thermo_t& speciesPhase(size_t k) {
383  return thermo(speciesPhaseIndex(k));
384  }
385 
386  /**
387  * This function takes as an argument the kineticsSpecies index (i.e., the
388  * list index in the list of species in the kinetics manager) and returns
389  * the index of the phase owning the species.
390  *
391  * @param k Species index
392  */
393  size_t speciesPhaseIndex(size_t k);
394 
395  //! @}
396  //! @name Reaction Rates Of Progress
397  //! @{
398 
399  //! Return the forward rates of progress of the reactions
400  /*!
401  * Forward rates of progress. Return the forward rates of
402  * progress in array fwdROP, which must be dimensioned at
403  * least as large as the total number of reactions.
404  *
405  * @param fwdROP Output vector containing forward rates
406  * of progress of the reactions. Length: m_ii.
407  */
408  virtual void getFwdRatesOfProgress(doublereal* fwdROP);
409 
410  //! Return the Reverse rates of progress of the reactions
411  /*!
412  * Return the reverse rates of progress in array revROP, which must be
413  * dimensioned at least as large as the total number of reactions.
414  *
415  * @param revROP Output vector containing reverse rates
416  * of progress of the reactions. Length: m_ii.
417  */
418  virtual void getRevRatesOfProgress(doublereal* revROP);
419 
420  /**
421  * Net rates of progress. Return the net (forward - reverse) rates of
422  * progress in array netROP, which must be dimensioned at least as large
423  * as the total number of reactions.
424  *
425  * @param netROP Output vector of the net ROP. Length: m_ii.
426  */
427  virtual void getNetRatesOfProgress(doublereal* netROP);
428 
429  //! Return a vector of Equilibrium constants.
430  /*!
431  * Return the equilibrium constants of the reactions in concentration
432  * units in array kc, which must be dimensioned at least as large as the
433  * total number of reactions.
434  *
435  * \f[
436  * Kc_i = exp [ \Delta G_{ss,i} ] prod(Cs_k) exp(\sum_k \nu_{k,i} F \phi_n) ]
437  * \f]
438  *
439  * @param kc Output vector containing the equilibrium constants.
440  * Length: m_ii.
441  */
442  virtual void getEquilibriumConstants(doublereal* kc) {
443  throw NotImplementedError("Kinetics::getEquilibriumConstants");
444  }
445 
446  /**
447  * Change in species properties. Given an array of molar species
448  * property values \f$ z_k, k = 1, \dots, K \f$, return the
449  * array of reaction values
450  * \f[
451  * \Delta Z_i = \sum_k \nu_{k,i} z_k, i = 1, \dots, I.
452  * \f]
453  * For example, if this method is called with the array of
454  * standard-state molar Gibbs free energies for the species,
455  * then the values returned in array \c deltaProperty would be
456  * the standard-state Gibbs free energies of reaction for each
457  * reaction.
458  *
459  * @param property Input vector of property value. Length: m_kk.
460  * @param deltaProperty Output vector of deltaRxn. Length: m_ii.
461  */
462  virtual void getReactionDelta(const doublereal* property,
463  doublereal* deltaProperty);
464 
465  /**
466  * Given an array of species properties 'g', return in array 'dg' the
467  * change in this quantity in the reversible reactions. Array 'g' must
468  * have a length at least as great as the number of species, and array
469  * 'dg' must have a length as great as the total number of reactions.
470  * This method only computes 'dg' for the reversible reactions, and the
471  * entries of 'dg' for the irreversible reactions are unaltered. This is
472  * primarily designed for use in calculating reverse rate coefficients
473  * from thermochemistry for reversible reactions.
474  */
475  virtual void getRevReactionDelta(const doublereal* g, doublereal* dg);
476 
477  //! Return the vector of values for the reaction Gibbs free energy change.
478  /*!
479  * (virtual from Kinetics.h)
480  * These values depend upon the concentration of the solution.
481  *
482  * units = J kmol-1
483  *
484  * @param deltaG Output vector of deltaG's for reactions Length: m_ii.
485  */
486  virtual void getDeltaGibbs(doublereal* deltaG) {
487  throw NotImplementedError("Kinetics::getDeltaGibbs");
488  }
489 
490  //! Return the vector of values for the reaction electrochemical free
491  //! energy change.
492  /*!
493  * These values depend upon the concentration of the solution and the
494  * voltage of the phases
495  *
496  * units = J kmol-1
497  *
498  * @param deltaM Output vector of deltaM's for reactions Length: m_ii.
499  */
500  virtual void getDeltaElectrochemPotentials(doublereal* deltaM) {
501  throw NotImplementedError("Kinetics::getDeltaElectrochemPotentials");
502  }
503 
504  /**
505  * Return the vector of values for the reactions change in enthalpy.
506  * These values depend upon the concentration of the solution.
507  *
508  * units = J kmol-1
509  *
510  * @param deltaH Output vector of deltaH's for reactions Length: m_ii.
511  */
512  virtual void getDeltaEnthalpy(doublereal* deltaH) {
513  throw NotImplementedError("Kinetics::getDeltaEnthalpy");
514  }
515 
516  /**
517  * Return the vector of values for the reactions change in entropy. These
518  * values depend upon the concentration of the solution.
519  *
520  * units = J kmol-1 Kelvin-1
521  *
522  * @param deltaS Output vector of deltaS's for reactions Length: m_ii.
523  */
524  virtual void getDeltaEntropy(doublereal* deltaS) {
525  throw NotImplementedError("Kinetics::getDeltaEntropy");
526  }
527 
528  /**
529  * Return the vector of values for the reaction standard state
530  * Gibbs free energy change. These values don't depend upon
531  * the concentration of the solution.
532  *
533  * units = J kmol-1
534  *
535  * @param deltaG Output vector of ss deltaG's for reactions Length: m_ii.
536  */
537  virtual void getDeltaSSGibbs(doublereal* deltaG) {
538  throw NotImplementedError("Kinetics::getDeltaSSGibbs");
539  }
540 
541  /**
542  * Return the vector of values for the change in the standard
543  * state enthalpies of reaction. These values don't depend
544  * upon the concentration of the solution.
545  *
546  * units = J kmol-1
547  *
548  * @param deltaH Output vector of ss deltaH's for reactions Length: m_ii.
549  */
550  virtual void getDeltaSSEnthalpy(doublereal* deltaH) {
551  throw NotImplementedError("Kinetics::getDeltaSSEnthalpy");
552  }
553 
554  /**
555  * Return the vector of values for the change in the standard
556  * state entropies for each reaction. These values don't
557  * depend upon the concentration of the solution.
558  *
559  * units = J kmol-1 Kelvin-1
560  *
561  * @param deltaS Output vector of ss deltaS's for reactions Length: m_ii.
562  */
563  virtual void getDeltaSSEntropy(doublereal* deltaS) {
564  throw NotImplementedError("Kinetics::getDeltaSSEntropy");
565  }
566 
567  //! @}
568  //! @name Species Production Rates
569  //! @{
570 
571  /**
572  * Species creation rates [kmol/m^3/s or kmol/m^2/s]. Return the species
573  * creation rates in array cdot, which must be dimensioned at least as
574  * large as the total number of species in all phases. @see nTotalSpecies.
575  *
576  * @param cdot Output vector of creation rates. Length: m_kk.
577  */
578  virtual void getCreationRates(doublereal* cdot);
579 
580  /**
581  * Species destruction rates [kmol/m^3/s or kmol/m^2/s]. Return the
582  * species destruction rates in array ddot, which must be dimensioned at
583  * least as large as the total number of species. @see nTotalSpecies.
584  *
585  * @param ddot Output vector of destruction rates. Length: m_kk.
586  */
587  virtual void getDestructionRates(doublereal* ddot);
588 
589  /**
590  * Species net production rates [kmol/m^3/s or kmol/m^2/s]. Return
591  * the species net production rates (creation - destruction)
592  * in array wdot, which must be dimensioned at least as large
593  * as the total number of species. @see nTotalSpecies.
594  *
595  * @param wdot Output vector of net production rates. Length: m_kk.
596  */
597  virtual void getNetProductionRates(doublereal* wdot);
598 
599  //! @}
600  //! @name Reaction Mechanism Informational Query Routines
601  //! @{
602 
603  /**
604  * Stoichiometric coefficient of species k as a reactant in reaction i.
605  *
606  * @param k kinetic species index
607  * @param i reaction index
608  */
609  virtual double reactantStoichCoeff(size_t k, size_t i) const;
610  /**
611  * Stoichiometric coefficient of species k as a product in reaction i.
612  *
613  * @param k kinetic species index
614  * @param i reaction index
615  */
616  virtual double productStoichCoeff(size_t k, size_t i) const;
617 
618  //! Reactant order of species k in reaction i.
619  /*!
620  * This is the nominal order of the activity concentration in
621  * determining the forward rate of progress of the reaction
622  *
623  * @param k kinetic species index
624  * @param i reaction index
625  */
626  virtual doublereal reactantOrder(size_t k, size_t i) const {
627  throw NotImplementedError("Kinetics::reactantOrder");
628  }
629 
630  //! product Order of species k in reaction i.
631  /*!
632  * This is the nominal order of the activity concentration of species k in
633  * determining the reverse rate of progress of the reaction i
634  *
635  * For irreversible reactions, this will all be zero.
636  *
637  * @param k kinetic species index
638  * @param i reaction index
639  */
640  virtual doublereal productOrder(int k, int i) const {
641  throw NotImplementedError("Kinetics::productOrder");
642  }
643 
644  //! Get the vector of activity concentrations used in the kinetics object
645  /*!
646  * @param[out] conc Vector of activity concentrations. Length is equal
647  * to the number of species in the kinetics object
648  */
649  virtual void getActivityConcentrations(doublereal* const conc) {
650  throw NotImplementedError("Kinetics::getActivityConcentrations");
651  }
652 
653  /**
654  * Returns a read-only reference to the vector of reactant
655  * index numbers for reaction i.
656  *
657  * @param i reaction index
658  * @deprecated To be removed after Cantera 2.2.
659  */
660  virtual const std::vector<size_t>& reactants(size_t i) const {
661  warn_deprecated("Kinetics::reactants",
662  "To be removed after Cantera 2.2.");
663  return m_reactants[i];
664  }
665 
666  /**
667  * Returns a read-only reference to the vector of product
668  * index numbers for reaction i.
669  *
670  * @param i reaction index
671  * @deprecated To be removed after Cantera 2.2.
672  */
673  virtual const std::vector<size_t>& products(size_t i) const {
674  warn_deprecated("Kinetics::products",
675  "To be removed after Cantera 2.2.");
676  return m_products[i];
677  }
678 
679  /**
680  * Flag specifying the type of reaction. The legal values and
681  * their meaning are specific to the particular kinetics
682  * manager.
683  *
684  * @param i reaction index
685  */
686  virtual int reactionType(size_t i) const {
687  return m_rxntype[i];
688  }
689 
690  /**
691  * True if reaction i has been declared to be reversible. If
692  * isReversible(i) is false, then the reverse rate of progress
693  * for reaction i is always zero.
694  *
695  * @param i reaction index
696  */
697  virtual bool isReversible(size_t i) {
698  throw NotImplementedError("Kinetics::isReversible");
699  }
700 
701  /**
702  * Return a string representing the reaction.
703  *
704  * @param i reaction index
705  */
706  const std::string& reactionString(size_t i) const {
707  return m_rxneqn[i];
708  }
709 
710  //! Returns a string containing the reactants side of the reaction equation.
711  const std::string& reactantString(size_t i) const {
712  return m_reactantStrings[i];
713  }
714 
715  //! Returns a string containing the products side of the reaction equation.
716  const std::string& productString(size_t i) const {
717  return m_productStrings[i];
718  }
719 
720  /**
721  * Return the forward rate constants
722  *
723  * length is the number of reactions. units depends on many issues.
724  *
725  * @param kfwd Output vector containing the forward reaction rate
726  * constants. Length: m_ii.
727  */
728  virtual void getFwdRateConstants(doublereal* kfwd) {
729  throw NotImplementedError("Kinetics::getFwdRateConstants");
730  }
731 
732  /**
733  * Return the reverse rate constants.
734  *
735  * length is the number of reactions. units depends on many issues. Note,
736  * this routine will return rate constants for irreversible reactions if
737  * the default for doIrreversible is overridden.
738  *
739  * @param krev Output vector of reverse rate constants.
740  * @param doIrreversible boolean indicating whether irreversible reactions
741  * should be included.
742  */
743  virtual void getRevRateConstants(doublereal* krev,
744  bool doIrreversible = false) {
745  throw NotImplementedError("Kinetics::getFwdRateConstants");
746  }
747 
748  //! @}
749  //! @name Reaction Mechanism Construction
750  //! @{
751 
752  //! Add a phase to the kinetics manager object.
753  /*!
754  * This must be done before the function init() is called or before any
755  * reactions are input. The following fields are updated:
756  *
757  * - #m_start -> vector of integers, containing the starting position of
758  * the species for each phase in the kinetics mechanism.
759  * - #m_surfphase -> index of the surface phase.
760  * - #m_thermo -> vector of pointers to ThermoPhase phases that
761  * participate in the kinetics mechanism.
762  * - #m_phaseindex -> map containing the std::string id of each
763  * ThermoPhase phase as a key and the index of the phase within the
764  * kinetics manager object as the value.
765  *
766  * @param thermo Reference to the ThermoPhase to be added.
767  */
768  virtual void addPhase(thermo_t& thermo);
769 
770  /**
771  * Prepare the class for the addition of reactions. This method is called
772  * by importKinetics() after all phases have been added but before any
773  * reactions have been. The base class method does nothing, but derived
774  * classes may use this to perform any initialization (allocating arrays,
775  * etc.) that requires knowing the phases and species, but before any
776  * reactions are added.
777  */
778  virtual void init() {}
779 
780  /**
781  * Finish adding reactions and prepare for use. This method is called by
782  * importKinetics() after all reactions have been entered into the
783  * mechanism and before the mechanism is used to calculate reaction rates.
784  * The base class method does nothing, but derived classes may use this to
785  * perform any initialization (allocating arrays, etc.) that must be done
786  * after the reactions are entered.
787  */
788  virtual void finalize();
789 
790  /**
791  * Add a single reaction to the mechanism. This routine
792  * must be called after init() and before finalize(). Derived classes
793  * should call the base class method in addition to handling their
794  * own specialized behavior.
795  *
796  * @param r Reference to the ReactionData object for the reaction
797  * to be added.
798  */
799  virtual void addReaction(ReactionData& r);
800 
801  /**
802  * Add a single reaction to the mechanism. Derived classes should call the
803  * base class method in addition to handling their own specialized behavior.
804  *
805  * @param r Pointer to the Reaction object to be added.
806  * @return `true` if the reaction is added or `false` if it was skipped
807  */
808  virtual bool addReaction(shared_ptr<Reaction> r);
809 
810  /**
811  * Modify the rate expression associated with a reaction. The
812  * stoichiometric equation, type of the reaction, reaction orders, third
813  * body efficiencies, reversibility, etc. must be unchanged.
814  *
815  * @param i Index of the reaction to be modified
816  * @param rNew Reaction with the new rate expressions
817  */
818  virtual void modifyReaction(size_t i, shared_ptr<Reaction> rNew);
819 
820  /**
821  * Return the Reaction object for reaction *i*.
822  */
823  shared_ptr<Reaction> reaction(size_t i);
824 
825  //! Determine behavior when adding a new reaction that contains species not
826  //! defined in any of the phases associated with this kinetics manager. If
827  //! set to true, the reaction will silently be ignored. If false, (the
828  //! default) an exception will be raised.
829  void skipUndeclaredSpecies(bool skip) {
831  }
832 
833  //! Determine behavior when adding a new reaction that contains third-body
834  //! efficiencies for species not defined in any of the phases associated
835  //! with this kinetics manager. If set to true, the given third-body
836  //! efficiency will be ignored. If false, (the default) an exception will be
837  //! raised.
838  void skipUndeclaredThirdBodies(bool skip) {
840  }
841 
842  //! @deprecated To be removed after Cantera 2.2. No longer called as part
843  //! of addReaction.
844  virtual void installReagents(const ReactionData& r) {
845  throw NotImplementedError("Kinetics::installReagents");
846  }
847 
848  virtual void installGroups(size_t irxn, const std::vector<grouplist_t>& r,
849  const std::vector<grouplist_t>& p);
850 
851  virtual const std::vector<grouplist_t>& reactantGroups(size_t i) {
852  return m_rgroups[i];
853  }
854 
855  virtual const std::vector<grouplist_t>& productGroups(size_t i) {
856  return m_pgroups[i];
857  }
858 
859  //@}
860  //! @name Altering Reaction Rates
861  /*!
862  * These methods alter reaction rates. They are designed primarily for
863  * carrying out sensitivity analysis, but may be used for any purpose
864  * requiring dynamic alteration of rate constants. For each reaction, a
865  * real-valued multiplier may be defined that multiplies the reaction rate
866  * coefficient. The multiplier may be set to zero to completely remove a
867  * reaction from the mechanism.
868  */
869  //@{
870 
871  //! The current value of the multiplier for reaction i.
872  /*!
873  * @param i index of the reaction
874  */
875  doublereal multiplier(size_t i) const {
876  return m_perturb[i];
877  }
878 
879  //! Set the multiplier for reaction i to f.
880  /*!
881  * @param i index of the reaction
882  * @param f value of the multiplier.
883  */
884  virtual void setMultiplier(size_t i, doublereal f) {
885  m_perturb[i] = f;
886  }
887 
888  //@}
889 
890  /**
891  * Increment the number of reactions in the mechanism by one.
892  * @todo Should be protected?
893  */
895  m_ii++;
896  m_perturb.push_back(1.0);
897  }
898 
899  /**
900  * Returns true if the kinetics manager has been properly
901  * initialized and finalized.
902  */
903  virtual bool ready() const {
904  return false;
905  }
906 
907  //! Check for duplicate reactions.
908  /**
909  * If `throw_err` is true, then an exception will be thrown if any unmarked
910  * duplicate reactions are found. Otherwise, the indices of the first pair
911  * of duplicate reactions found will be returned. If no duplicate reactions
912  * are found, returns `(npos, npos)`.
913  */
914  virtual std::pair<size_t, size_t> checkDuplicates(bool throw_err=true) const;
915 
916  /*!
917  * Takes as input an array of properties for all species in the mechanism
918  * and copies those values belonging to a particular phase to the output
919  * array.
920  * @param data Input data array.
921  * @param phase Pointer to one of the phase objects participating in this
922  * reaction mechanism
923  * @param phase_data Output array where the values for the the specified
924  * phase are to be written.
925  */
926  void selectPhase(const doublereal* data, const thermo_t* phase,
927  doublereal* phase_data);
928 
929 protected:
930  //! Cache for saved calculations within each Kinetics object.
932 
933  // Update internal rate-of-progress variables #m_ropf and #m_ropr.
934  virtual void updateROP() {
935  throw NotImplementedError("Kinetics::updateROP");
936  }
937 
938  //! Check whether `r1` and `r2` represent duplicate stoichiometries
939  //! This function returns a ratio if two reactions are duplicates of
940  //! one another, and 0.0 otherwise.
941  /*!
942  * `r1` and `r2` are maps of species key to stoichiometric coefficient, one
943  * for each reaction, where the species key is `1+k` for reactants and
944  * `-1-k` for products and `k` is the species index.
945  *
946  * @return 0.0 if the stoichiometries are not multiples of one another
947  * Otherwise, it returns the ratio of the stoichiometric coefficients.
948  *
949  * @ingroup kineticsmgr
950  */
951  double checkDuplicateStoich(std::map<int, double>& r1,
952  std::map<int, double>& r2) const;
953 
954  //! Check that the specified reaction is balanced (same number of atoms for
955  //! each element in the reactants and products). Raises an exception if the
956  //! reaction is not balanced.
957  void checkReactionBalance(const Reaction& R);
958 
959  //! @name Stoichiometry management
960  /*!
961  * These objects and functions handle turning reaction extents into species
962  * production rates and also handle turning thermo properties into reaction
963  * thermo properties.
964  */
965  //@{
966 
967  //! Stoichiometry manager for the reactants for each reaction
968  StoichManagerN m_reactantStoich;
969 
970  //! Stoichiometry manager for the products of reversible reactions
971  StoichManagerN m_revProductStoich;
972 
973  //! Stoichiometry manager for the products of irreversible reactions
974  StoichManagerN m_irrevProductStoich;
975  //@}
976 
977  //! Number of reactions in the mechanism
978  size_t m_ii;
979 
980  //! The number of species in all of the phases
981  //! that participate in this kinetics mechanism.
982  size_t m_kk;
983 
984  /// Vector of perturbation factors for each reaction's rate of
985  /// progress vector. It is initialized to one.
987 
988  //! Vector of Reaction objects represented by this Kinetics manager
989  std::vector<shared_ptr<Reaction> > m_reactions;
990 
991  /**
992  * This is a vector of vectors containing the reactants for
993  * each reaction. The outer vector is over the number of
994  * reactions, m_ii. The inner vector is a list of species
995  * indices. If the stoichiometric coefficient for a reactant
996  * is greater than one, then the reactant is listed
997  * contiguously in the vector a number of times equal to its
998  * stoichiometric coefficient.
999  * NOTE: These vectors will be wrong if there are real
1000  * stoichiometric coefficients in the expression.
1001  * @deprecated To be removed after Cantera 2.2.
1002  */
1003  std::vector<std::vector<size_t> > m_reactants;
1004 
1005  /**
1006  * This is a vector of vectors containing the products for
1007  * each reaction. The outer vector is over the number of
1008  * reactions, m_ii. The inner vector is a list of species
1009  * indices. If the stoichiometric coefficient for a product is
1010  * greater than one, then the reactant is listed contiguously
1011  * in the vector a number of times equal to its stoichiometric
1012  * coefficient.
1013  * NOTE: These vectors will be wrong if there are real
1014  * stoichiometric coefficients in the expression.
1015  * @deprecated To be removed after Cantera 2.2.
1016  */
1017  std::vector<std::vector<size_t> > m_products;
1018 
1019  //! m_rrxn is a vector of maps, containing the reactant
1020  //! stoichiometric coefficient information
1021  /*!
1022  * m_rrxn has a length equal to the total number of species in the
1023  * kinetics object. For each species, there exists a map, with the
1024  * reaction number being the key, and the reactant stoichiometric
1025  * coefficient for the species being the value.
1026  */
1027  std::vector<std::map<size_t, doublereal> > m_rrxn;
1028 
1029  //! m_prxn is a vector of maps, containing the reactant
1030  //! stoichiometric coefficient information
1031  /**
1032  * m_prxn is a vector of maps. m_prxn has a length equal to the total
1033  * number of species in the kinetics object. For each species, there
1034  * exists a map, with the reaction number being the key, and the product
1035  * stoichiometric coefficient for the species being the value.
1036  */
1037  std::vector<std::map<size_t, doublereal> > m_prxn;
1038 
1039  std::vector<int> m_rxntype;
1040 
1041  //! m_thermo is a vector of pointers to ThermoPhase objects that are
1042  //! involved with this kinetics operator
1043  /*!
1044  * For homogeneous kinetics applications, this vector
1045  * will only have one entry. For interfacial reactions, this
1046  * vector will consist of multiple entries; some of them will
1047  * be surface phases, and the other ones will be bulk phases.
1048  * The order that the objects are listed determines the order
1049  * in which the species comprising each phase are listed in
1050  * the source term vector, originating from the reaction
1051  * mechanism.
1052  *
1053  * Note that this kinetics object doesn't own these ThermoPhase objects
1054  * and is not responsible for creating or deleting them.
1055  */
1056  std::vector<thermo_t*> m_thermo;
1057 
1058  /**
1059  * m_start is a vector of integers specifying the beginning position
1060  * for the species vector for the n'th phase in the kinetics
1061  * class.
1062  */
1063  std::vector<size_t> m_start;
1064 
1065  /**
1066  * Mapping of the phase id, i.e., the id attribute in the XML
1067  * phase element to the position of the phase within the
1068  * kinetics object. Positions start with the value of 1. The
1069  * member function, phaseIndex() decrements by one before
1070  * returning the index value, so that missing phases return
1071  * -1.
1072  */
1073  std::map<std::string, size_t> m_phaseindex;
1074 
1075  //! Index in the list of phases of the one surface phase.
1076  size_t m_surfphase;
1077 
1078  //! Phase Index where reactions are assumed to be taking place
1079  /*!
1080  * We calculate this by assuming that the phase with the lowest
1081  * dimensionality is the phase where reactions are taking place.
1082  */
1083  size_t m_rxnphase;
1084 
1085  //! number of spatial dimensions of lowest-dimensional phase.
1086  size_t m_mindim;
1087 
1088  //! Representation of each reaction equation
1089  std::vector<std::string> m_rxneqn;
1090 
1091  //! Representation of the reactant side of each reaction equation
1092  std::vector<std::string> m_reactantStrings;
1093 
1094  //! Representation of the product side of each reaction equation
1095  std::vector<std::string> m_productStrings;
1096 
1097  //! Forward rate constant for each reaction
1099 
1100  //! Reciprocal of the equilibrium constant in concentration units
1102 
1103  //! Forward rate-of-progress for each reaction
1105 
1106  //! Reverse rate-of-progress for each reaction
1108 
1109  //! Net rate-of-progress for each reaction
1111 
1112  //! @see skipUndeclaredSpecies()
1114 
1115  //! @see skipUndeclaredThirdBodies()
1117 
1118 private:
1119  std::map<size_t, std::vector<grouplist_t> > m_rgroups;
1120  std::map<size_t, std::vector<grouplist_t> > m_pgroups;
1121 };
1122 
1123 }
1124 
1125 #endif
virtual void modifyReaction(size_t i, shared_ptr< Reaction > rNew)
Modify the rate expression associated with a reaction.
Definition: Kinetics.cpp:773
virtual void getDeltaElectrochemPotentials(doublereal *deltaM)
Return the vector of values for the reaction electrochemical free energy change.
Definition: Kinetics.h:500
const std::string & reactionString(size_t i) const
Return a string representing the reaction.
Definition: Kinetics.h:706
virtual void installReagents(const ReactionData &r)
Definition: Kinetics.h:844
StoichManagerN m_irrevProductStoich
Stoichiometry manager for the products of irreversible reactions.
Definition: Kinetics.h:974
StoichManagerN m_revProductStoich
Stoichiometry manager for the products of reversible reactions.
Definition: Kinetics.h:971
const std::string & reactantString(size_t i) const
Returns a string containing the reactants side of the reaction equation.
Definition: Kinetics.h:711
vector_fp m_ropr
Reverse rate-of-progress for each reaction.
Definition: Kinetics.h:1107
std::vector< thermo_t * > m_thermo
m_thermo is a vector of pointers to ThermoPhase objects that are involved with this kinetics operator...
Definition: Kinetics.h:1056
void incrementRxnCount()
Increment the number of reactions in the mechanism by one.
Definition: Kinetics.h:894
std::vector< std::vector< size_t > > m_reactants
This is a vector of vectors containing the reactants for each reaction.
Definition: Kinetics.h:1003
virtual void assignShallowPointers(const std::vector< thermo_t * > &tpVector)
Reassign the pointers within the Kinetics object.
Definition: Kinetics.cpp:140
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:213
virtual void getRevRateConstants(doublereal *krev, bool doIrreversible=false)
Return the reverse rate constants.
Definition: Kinetics.h:743
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:285
virtual void getDeltaEntropy(doublereal *deltaS)
Return the vector of values for the reactions change in entropy.
Definition: Kinetics.h:524
size_t m_kk
The number of species in all of the phases that participate in this kinetics mechanism.
Definition: Kinetics.h:982
std::vector< size_t > m_start
m_start is a vector of integers specifying the beginning position for the species vector for the n'th...
Definition: Kinetics.h:1063
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:165
virtual void getNetRatesOfProgress(doublereal *netROP)
Net rates of progress.
Definition: Kinetics.cpp:450
virtual Kinetics * duplMyselfAsKinetics(const std::vector< thermo_t * > &tpVector) const
Duplication routine for objects which inherit from Kinetics.
Definition: Kinetics.cpp:85
virtual void getDeltaSSEntropy(doublereal *deltaS)
Return the vector of values for the change in the standard state entropies for each reaction...
Definition: Kinetics.h:563
virtual bool isReversible(size_t i)
True if reaction i has been declared to be reversible.
Definition: Kinetics.h:697
std::string kineticsSpeciesName(size_t k) const
Return the name of the kth species in the kinetics manager.
Definition: Kinetics.cpp:359
std::vector< std::string > m_reactantStrings
Representation of the reactant side of each reaction equation.
Definition: Kinetics.h:1092
void selectPhase(const doublereal *data, const thermo_t *phase, doublereal *phase_data)
Definition: Kinetics.cpp:345
virtual const std::vector< size_t > & products(size_t i) const
Returns a read-only reference to the vector of product index numbers for reaction i...
Definition: Kinetics.h:673
virtual void getDeltaSSGibbs(doublereal *deltaG)
Return the vector of values for the reaction standard state Gibbs free energy change.
Definition: Kinetics.h:537
size_t nTotalSpecies() const
The total number of species in all phases participating in the kinetics mechanism.
Definition: Kinetics.h:297
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:78
virtual void getFwdRateConstants(doublereal *kfwd)
Return the forward rate constants.
Definition: Kinetics.h:728
doublereal multiplier(size_t i) const
The current value of the multiplier for reaction i.
Definition: Kinetics.h:875
Kinetics()
Default constructor.
Definition: Kinetics.cpp:19
virtual void getRevReactionDelta(const doublereal *g, doublereal *dg)
Given an array of species properties 'g', return in array 'dg' the change in this quantity in the rev...
Definition: Kinetics.cpp:466
vector_fp m_ropnet
Net rate-of-progress for each reaction.
Definition: Kinetics.h:1110
This file contains definitions for utility functions and text for modules, inputfiles, logs, textlogs, (see Input File Handling, Diagnostic Output, and Writing messages to the screen).
size_t reactionPhaseIndex()
Phase where the reactions occur.
Definition: Kinetics.h:272
virtual doublereal reactantOrder(size_t k, size_t i) const
Reactant order of species k in reaction i.
Definition: Kinetics.h:626
virtual void getEquilibriumConstants(doublereal *kc)
Return a vector of Equilibrium constants.
Definition: Kinetics.h:442
virtual void getDestructionRates(doublereal *ddot)
Species destruction rates [kmol/m^3/s or kmol/m^2/s].
Definition: Kinetics.cpp:490
virtual void getCreationRates(doublereal *cdot)
Species creation rates [kmol/m^3/s or kmol/m^2/s].
Definition: Kinetics.cpp:475
virtual void getDeltaGibbs(doublereal *deltaG)
Return the vector of values for the reaction Gibbs free energy change.
Definition: Kinetics.h:486
virtual void getNetProductionRates(doublereal *wdot)
Species net production rates [kmol/m^3/s or kmol/m^2/s].
Definition: Kinetics.cpp:501
vector_fp m_ropf
Forward rate-of-progress for each reaction.
Definition: Kinetics.h:1104
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:97
virtual void init()
Prepare the class for the addition of reactions.
Definition: Kinetics.h:778
void checkPhaseIndex(size_t m) const
Check that the specified phase index is in range Throws an exception if m is greater than nPhases() ...
Definition: Kinetics.cpp:112
std::vector< std::string > m_rxneqn
Representation of each reaction equation.
Definition: Kinetics.h:1089
size_t surfacePhaseIndex()
This returns the integer index of the phase which has ThermoPhase type cSurf.
Definition: Kinetics.h:260
virtual std::pair< size_t, size_t > checkDuplicates(bool throw_err=true) const
Check for duplicate reactions.
Definition: Kinetics.cpp:168
void checkReactionBalance(const Reaction &R)
Check that the specified reaction is balanced (same number of atoms for each element in the reactants...
Definition: Kinetics.cpp:298
ValueCache m_cache
Cache for saved calculations within each Kinetics object.
Definition: Kinetics.h:931
size_t nPhases() const
The number of phases participating in the reaction mechanism.
Definition: Kinetics.h:225
std::vector< std::map< size_t, doublereal > > m_prxn
m_prxn is a vector of maps, containing the reactant stoichiometric coefficient information ...
Definition: Kinetics.h:1037
vector_fp m_rfn
Forward rate constant for each reaction.
Definition: Kinetics.h:1098
StoichManagerN m_reactantStoich
Stoichiometry manager for the reactants for each reaction.
Definition: Kinetics.h:968
thermo_t & speciesPhase(const std::string &nm)
This function looks up the name of a species and returns a reference to the ThermoPhase object of the...
Definition: Kinetics.cpp:402
bool m_skipUndeclaredThirdBodies
Definition: Kinetics.h:1116
void checkSpeciesArraySize(size_t mm) const
Check that an array size is at least nSpecies() Throws an exception if kk is less than nSpecies()...
Definition: Kinetics.cpp:133
virtual void getRevRatesOfProgress(doublereal *revROP)
Return the Reverse rates of progress of the reactions.
Definition: Kinetics.cpp:444
void checkSpeciesIndex(size_t k) const
Check that the specified species index is in range Throws an exception if k is greater than nSpecies(...
Definition: Kinetics.cpp:126
vector_fp m_perturb
Vector of perturbation factors for each reaction's rate of progress vector.
Definition: Kinetics.h:986
Public interface for kinetics managers.
Definition: Kinetics.h:128
Intermediate class which stores data about a reaction and its rate parameterization before adding the...
Definition: ReactionData.h:22
virtual doublereal productOrder(int k, int i) const
product Order of species k in reaction i.
Definition: Kinetics.h:640
Intermediate class which stores data about a reaction and its rate parameterization so that it can be...
Definition: Reaction.h:20
std::map< std::string, size_t > m_phaseindex
Mapping of the phase id, i.e., the id attribute in the XML phase element to the position of the phase...
Definition: Kinetics.h:1073
double checkDuplicateStoich(std::map< int, double > &r1, std::map< int, double > &r2) const
Check whether r1 and r2 represent duplicate stoichiometries This function returns a ratio if two reac...
Definition: Kinetics.cpp:258
std::vector< std::map< size_t, doublereal > > m_rrxn
m_rrxn is a vector of maps, containing the reactant stoichiometric coefficient information ...
Definition: Kinetics.h:1027
virtual void getDeltaEnthalpy(doublereal *deltaH)
Return the vector of values for the reactions change in enthalpy.
Definition: Kinetics.h:512
Kinetics & operator=(const Kinetics &right)
Assignment operator.
Definition: Kinetics.cpp:41
size_t kineticsSpeciesIndex(size_t k, size_t n) const
The location of species k of phase n in species arrays.
Definition: Kinetics.h:323
vector_fp m_rkcn
Reciprocal of the equilibrium constant in concentration units.
Definition: Kinetics.h:1101
virtual const std::vector< size_t > & reactants(size_t i) const
Returns a read-only reference to the vector of reactant index numbers for reaction i...
Definition: Kinetics.h:660
std::vector< shared_ptr< Reaction > > m_reactions
Vector of Reaction objects represented by this Kinetics manager.
Definition: Kinetics.h:989
virtual void getActivityConcentrations(doublereal *const conc)
Get the vector of activity concentrations used in the kinetics object.
Definition: Kinetics.h:649
size_t m_mindim
number of spatial dimensions of lowest-dimensional phase.
Definition: Kinetics.h:1086
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:157
thermo_t & speciesPhase(size_t k)
This function takes as an argument the kineticsSpecies index (i.e., the list index in the list of spe...
Definition: Kinetics.h:382
void checkReactionIndex(size_t m) const
Check that the specified reaction index is in range Throws an exception if i is greater than nReactio...
Definition: Kinetics.cpp:98
size_t speciesPhaseIndex(size_t k)
This function takes as an argument the kineticsSpecies index (i.e., the list index in the list of spe...
Definition: Kinetics.cpp:417
std::vector< std::vector< size_t > > m_products
This is a vector of vectors containing the products for each reaction.
Definition: Kinetics.h:1017
std::vector< std::string > m_productStrings
Representation of the product side of each reaction equation.
Definition: Kinetics.h:1095
void checkReactionArraySize(size_t ii) const
Check that an array size is at least nReactions() Throws an exception if ii is less than nReactions()...
Definition: Kinetics.cpp:105
size_t m_ii
Number of reactions in the mechanism.
Definition: Kinetics.h:978
size_t nReactions() const
Number of reactions in the reaction mechanism.
Definition: Kinetics.h:193
virtual int type() const
Identifies the kinetics manager type.
Definition: Kinetics.cpp:93
size_t m_surfphase
Index in the list of phases of the one surface phase.
Definition: Kinetics.h:1076
virtual double reactantStoichCoeff(size_t k, size_t i) const
Stoichiometric coefficient of species k as a reactant in reaction i.
Definition: Kinetics.cpp:428
virtual void getDeltaSSEnthalpy(doublereal *deltaH)
Return the vector of values for the change in the standard state enthalpies of reaction.
Definition: Kinetics.h:550
shared_ptr< Reaction > reaction(size_t i)
Return the Reaction object for reaction i.
Definition: Kinetics.cpp:797
virtual void setMultiplier(size_t i, doublereal f)
Set the multiplier for reaction i to f.
Definition: Kinetics.h:884
size_t m_rxnphase
Phase Index where reactions are assumed to be taking place.
Definition: Kinetics.h:1083
virtual void getFwdRatesOfProgress(doublereal *fwdROP)
Return the forward rates of progress of the reactions.
Definition: Kinetics.cpp:438
virtual int reactionType(size_t i) const
Flag specifying the type of reaction.
Definition: Kinetics.h:686
virtual void finalize()
Finish adding reactions and prepare for use.
Definition: Kinetics.cpp:548
Header file for class ThermoPhase, the base class for phases with thermodynamic properties, and the text for the Module thermoprops (see Thermodynamic Properties and class ThermoPhase).
virtual void addPhase(thermo_t &thermo)
Add a phase to the kinetics manager object.
Definition: Kinetics.cpp:513
virtual ~Kinetics()
Destructor.
Definition: Kinetics.cpp:31
const std::string & productString(size_t i) const
Returns a string containing the products side of the reaction equation.
Definition: Kinetics.h:716
void checkPhaseArraySize(size_t mm) const
Check that an array size is at least nPhases() Throws an exception if mm is less than nPhases()...
Definition: Kinetics.cpp:119
virtual double productStoichCoeff(size_t k, size_t i) const
Stoichiometric coefficient of species k as a product in reaction i.
Definition: Kinetics.cpp:433
bool m_skipUndeclaredSpecies
Definition: Kinetics.h:1113
virtual void getReactionDelta(const doublereal *property, doublereal *deltaProperty)
Change in species properties.
Definition: Kinetics.cpp:456
void skipUndeclaredThirdBodies(bool skip)
Determine behavior when adding a new reaction that contains third-body efficiencies for species not d...
Definition: Kinetics.h:838
virtual void addReaction(ReactionData &r)
Add a single reaction to the mechanism.
Definition: Kinetics.cpp:557
size_t phaseIndex(const std::string &ph)
Return the phase index of a phase in the list of phases defined within the object.
Definition: Kinetics.h:247
void skipUndeclaredSpecies(bool skip)
Determine behavior when adding a new reaction that contains species not defined in any of the phases ...
Definition: Kinetics.h:829
virtual bool ready() const
Returns true if the kinetics manager has been properly initialized and finalized. ...
Definition: Kinetics.h:903