From 9bba4579e8ca683e96ef2ad7b254e9e33e42009e Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Wed, 26 May 2010 18:13:34 +0000 Subject: [PATCH] Added two new functions productOrder getActivityConcentrations --- Cantera/src/kinetics/InterfaceKinetics.cpp | 11 ++++++++ Cantera/src/kinetics/InterfaceKinetics.h | 7 +++++ Cantera/src/kinetics/Kinetics.h | 30 ++++++++++++++++++++-- Cantera/src/kinetics/ReactionStoichMgr.h | 22 +++++++--------- 4 files changed, 55 insertions(+), 15 deletions(-) diff --git a/Cantera/src/kinetics/InterfaceKinetics.cpp b/Cantera/src/kinetics/InterfaceKinetics.cpp index fb910a367..2ed047f16 100644 --- a/Cantera/src/kinetics/InterfaceKinetics.cpp +++ b/Cantera/src/kinetics/InterfaceKinetics.cpp @@ -296,6 +296,17 @@ namespace Cantera { } + // Get the vector of activity concentrations used in the kinetics object + /* + * @param conc (output) Vector of activity concentrations. Length is + * equal to the number of species in the kinetics object + */ + void InterfaceKinetics::getActivityConcentrations(doublereal * const conc) { + _update_rates_C(); + copy(m_conc.begin(), m_conc.end(), conc); + } + + /** * Update the equilibrium constants in molar units for all * reversible reactions. Irreversible reactions have their diff --git a/Cantera/src/kinetics/InterfaceKinetics.h b/Cantera/src/kinetics/InterfaceKinetics.h index 05e4bc73f..0bb06030c 100644 --- a/Cantera/src/kinetics/InterfaceKinetics.h +++ b/Cantera/src/kinetics/InterfaceKinetics.h @@ -324,6 +324,13 @@ namespace Cantera { return m_index[i].first; } + //! Get the vector of activity concentrations used in the kinetics object + /*! + * @param conc (output) Vector of activity concentrations. Length is + * equal to the number of species in the kinetics object + */ + virtual void getActivityConcentrations(doublereal * const conc); + //! Return the charge transfer rxn Beta parameter for the ith reaction /*! * Returns the beta parameter for a charge transfer reaction. This diff --git a/Cantera/src/kinetics/Kinetics.h b/Cantera/src/kinetics/Kinetics.h index 33b63263b..f99b0a186 100644 --- a/Cantera/src/kinetics/Kinetics.h +++ b/Cantera/src/kinetics/Kinetics.h @@ -654,8 +654,10 @@ namespace Cantera { return -1.0; } - /** - * reactant Order of species k in reaction i. + //! Reactant order of species k in reaction i. + /*! + * This is the nominal order of the activity concentration in + * determining the forward rate of progress of the reaction * * @param k kinetic species index * @param i reaction index @@ -665,6 +667,30 @@ namespace Cantera { return -1.0; } + //! product Order of species k in reaction i. + /*! + * This is the nominal order of the activity concentration of species k in + * determining the reverse rate of progress of the reaction i + * + * For irreversible reactions, this will all be zero. + * + * @param k kinetic species index + * @param i reaction index + */ + virtual doublereal productOrder(int k, int i) const { + err("productOrder"); + return -1.0; + } + + //! Get the vector of activity concentrations used in the kinetics object + /*! + * @param conc (output) Vector of activity concentrations. Length is + * equal to the number of species in the kinetics object + */ + virtual void getActivityConcentrations(doublereal * const conc) { + err("getActivityConcentrations"); + } + /** * Returns a read-only reference to the vector of reactant * index numbers for reaction i. diff --git a/Cantera/src/kinetics/ReactionStoichMgr.h b/Cantera/src/kinetics/ReactionStoichMgr.h index eba12e5d5..1ccd6b588 100644 --- a/Cantera/src/kinetics/ReactionStoichMgr.h +++ b/Cantera/src/kinetics/ReactionStoichMgr.h @@ -26,8 +26,8 @@ namespace Cantera { * user programs. * * Class ReactionStoichMgr handles the calculation of quantities involving - * the stoichiometry of a set of reactions. The reactions must have integer - * stoichiometric coefficients. Specifically, its methods compute + * the stoichiometry of a set of reactions. The reactions may have integer + * or non-integer stoichiometric coefficients. Specifically, its methods compute * - species creation rates * - species destruction rates * - species net production rates @@ -97,7 +97,7 @@ namespace Cantera { * @param reversible true if the reaction is reversible, false otherwise */ virtual void add(int rxn, const vector_int& reactants, const vector_int& products, - bool reversible); + bool reversible); /** * Add a reaction with specified, possibly non-integral, reaction orders. @@ -112,11 +112,7 @@ namespace Cantera { * species with index in the corresponding location in 'reactants.' * */ - // void add(int rxn, const vector_int& reactants, const vector_int& products, - // bool reversible, const vector_fp& fwdOrder); - - - virtual void add(int rxn, const ReactionData& r); + virtual void add(int rxn, const ReactionData& r); /** * Species creation rates. @@ -144,7 +140,7 @@ namespace Cantera { * Note that the stoichiometric coefficient matrices are very sparse, integer * matrices. */ - virtual void getDestructionRates(int nSpecies, + virtual void getDestructionRates(int nSpecies, const doublereal* fwdRatesOfProgress, const doublereal* revRatesOfProgress, doublereal* destructionRates); @@ -164,7 +160,7 @@ namespace Cantera { * W = (N_r - N_p) Q_{\rm net}, * \f] */ - virtual void getNetProductionRates(int nsp, const doublereal* ropnet, doublereal* w); + virtual void getNetProductionRates(int nsp, const doublereal* ropnet, doublereal* w); @@ -205,7 +201,7 @@ namespace Cantera { * calculating reveerse rate coefficients from thermochemistry * for reversible reactions. */ - virtual void getRevReactionDelta(int nr, const doublereal* g, doublereal* dg); + virtual void getRevReactionDelta(int nr, const doublereal* g, doublereal* dg); /** @@ -217,7 +213,7 @@ namespace Cantera { * * Here \f$ o_{k,i} \f$ is the reaction order of species k in reaction i. */ - virtual void multiplyReactants(const doublereal* C, doublereal* R); + virtual void multiplyReactants(const doublereal* C, doublereal* R); /** @@ -229,7 +225,7 @@ namespace Cantera { * Here \f$ \nu^{(p)}_{k,i} \f$ is the product stoichiometric coefficient * of species k in reaction i. */ - virtual void multiplyRevProducts(const doublereal* c, doublereal* r); + virtual void multiplyRevProducts(const doublereal* c, doublereal* r); virtual void write(std::string filename);