[Kinetics] Move common Kinetics features up to the base class
This commit is contained in:
parent
e7236df51f
commit
d65dbe3da2
8 changed files with 61 additions and 136 deletions
|
|
@ -127,10 +127,6 @@ public:
|
|||
return getValue(m_index, i).first;
|
||||
}
|
||||
|
||||
virtual std::string reactionString(size_t i) const {
|
||||
return m_rxneqn[i];
|
||||
}
|
||||
|
||||
virtual bool isReversible(size_t i) {
|
||||
if (std::find(m_revindex.begin(), m_revindex.end(), i)
|
||||
< m_revindex.end()) {
|
||||
|
|
@ -159,13 +155,6 @@ public:
|
|||
|
||||
void updateROP();
|
||||
|
||||
const std::vector<grouplist_t>& reactantGroups(size_t i) {
|
||||
return m_rgroups[i];
|
||||
}
|
||||
const std::vector<grouplist_t>& productGroups(size_t i) {
|
||||
return m_pgroups[i];
|
||||
}
|
||||
|
||||
/*!
|
||||
* Update temperature-dependent portions of reaction rates and
|
||||
* falloff functions.
|
||||
|
|
@ -214,8 +203,6 @@ protected:
|
|||
vector_fp m_dn;
|
||||
std::vector<size_t> m_revindex;
|
||||
|
||||
std::vector<std::string> m_rxneqn;
|
||||
|
||||
vector_fp m_conc;
|
||||
vector_fp m_grt;
|
||||
|
||||
|
|
@ -243,9 +230,6 @@ private:
|
|||
|
||||
void installReagents(const ReactionData& r);
|
||||
|
||||
void installGroups(size_t irxn, const std::vector<grouplist_t>& r,
|
||||
const std::vector<grouplist_t>& p);
|
||||
|
||||
/**
|
||||
* Update the equilibrium constants in molar units.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -104,18 +104,6 @@ public:
|
|||
return getValue(m_index, i).first;
|
||||
}
|
||||
|
||||
virtual std::string reactionString(size_t i) const {
|
||||
return m_rxneqn[i];
|
||||
}
|
||||
|
||||
virtual std::string reactantString(size_t i) const {
|
||||
return m_reactantStrings[i];
|
||||
}
|
||||
|
||||
virtual std::string productString(size_t i) const {
|
||||
return m_productStrings[i];
|
||||
}
|
||||
|
||||
virtual bool isReversible(size_t i) {
|
||||
if (std::find(m_revindex.begin(), m_revindex.end(), i)
|
||||
< m_revindex.end()) {
|
||||
|
|
@ -141,13 +129,6 @@ public:
|
|||
|
||||
void updateROP();
|
||||
|
||||
const std::vector<grouplist_t>& reactantGroups(size_t i) {
|
||||
return m_rgroups[i];
|
||||
}
|
||||
const std::vector<grouplist_t>& productGroups(size_t i) {
|
||||
return m_pgroups[i];
|
||||
}
|
||||
|
||||
//! Update temperature-dependent portions of reaction rates and falloff
|
||||
//! functions.
|
||||
virtual void update_rates_T();
|
||||
|
|
@ -186,9 +167,6 @@ protected:
|
|||
size_t m_nirrev;
|
||||
size_t m_nrev;
|
||||
|
||||
std::map<size_t, std::vector<grouplist_t> > m_rgroups;
|
||||
std::map<size_t, std::vector<grouplist_t> > m_pgroups;
|
||||
|
||||
std::vector<int> m_rxntype;
|
||||
|
||||
std::vector<std::map<size_t, doublereal> > m_rrxn;
|
||||
|
|
@ -203,10 +181,6 @@ protected:
|
|||
vector_fp m_dn;
|
||||
std::vector<size_t> m_revindex;
|
||||
|
||||
std::vector<std::string> m_rxneqn;
|
||||
std::vector<std::string> m_reactantStrings;
|
||||
std::vector<std::string> m_productStrings;
|
||||
|
||||
//! @name Reaction rate data
|
||||
//!@{
|
||||
doublereal m_logp_ref;
|
||||
|
|
@ -244,10 +218,7 @@ private:
|
|||
void addPlogReaction(ReactionData& r);
|
||||
void addChebyshevReaction(ReactionData& r);
|
||||
|
||||
void installReagents(const ReactionData& r);
|
||||
|
||||
void installGroups(size_t irxn, const std::vector<grouplist_t>& r,
|
||||
const std::vector<grouplist_t>& p);
|
||||
virtual void installReagents(const ReactionData& r);
|
||||
|
||||
//! Update the equilibrium constants in molar units.
|
||||
void updateKc();
|
||||
|
|
|
|||
|
|
@ -219,10 +219,6 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual std::string reactionString(size_t i) const {
|
||||
return m_rxneqn[i];
|
||||
}
|
||||
|
||||
virtual void getFwdRateConstants(doublereal* kfwd);
|
||||
virtual void getRevRateConstants(doublereal* krev,
|
||||
bool doIrreversible = false);
|
||||
|
|
@ -531,13 +527,6 @@ public:
|
|||
std::vector<RxnMolChange*> rmcVector;
|
||||
|
||||
protected:
|
||||
/*!
|
||||
* Vector of strings of length m_ii, the number of
|
||||
* reactions, containing the string expressions for each reaction
|
||||
* (e.g., reactants <=> product1 + product2)
|
||||
*/
|
||||
std::vector<std::string> m_rxneqn;
|
||||
|
||||
//! Array of concentrations for each species in the kinetics mechanism
|
||||
/*!
|
||||
* An array of generalized concentrations \f$ C_k \f$ that are defined
|
||||
|
|
|
|||
|
|
@ -700,18 +700,18 @@ public:
|
|||
*
|
||||
* @param i reaction index
|
||||
*/
|
||||
virtual std::string reactionString(size_t i) const {
|
||||
throw NotImplementedError("Kinetics::reactionStd::String");
|
||||
const std::string& reactionString(size_t i) const {
|
||||
return m_rxneqn[i];
|
||||
}
|
||||
|
||||
//! Returns a string containing the reactants side of the reaction equation.
|
||||
virtual std::string reactantString(size_t i) const {
|
||||
throw NotImplementedError("Kinetics::reactionString");
|
||||
const std::string& reactantString(size_t i) const {
|
||||
return m_reactantStrings[i];
|
||||
}
|
||||
|
||||
//! Returns a string containing the products side of the reaction equation.
|
||||
virtual std::string productString(size_t i) const {
|
||||
throw NotImplementedError("Kinetics::productString");
|
||||
const std::string& productString(size_t i) const {
|
||||
return m_productStrings[i];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -785,22 +785,29 @@ public:
|
|||
virtual void finalize();
|
||||
|
||||
/**
|
||||
* Add a single reaction to the mechanism. This routine
|
||||
* must be called after init() and before finalize().
|
||||
* Add a single reaction to the mechanism. This routine
|
||||
* must be called after init() and before finalize(). Derived classes
|
||||
* should call the base class method in addition to handling their
|
||||
* own specialized behavior.
|
||||
*
|
||||
* @param r Reference to the ReactionData object for the reaction
|
||||
* to be added.
|
||||
*/
|
||||
virtual void addReaction(ReactionData& r) {
|
||||
throw NotImplementedError("Kinetics::addReaction");
|
||||
virtual void addReaction(ReactionData& r);
|
||||
|
||||
virtual void installReagents(const ReactionData& r) {
|
||||
throw NotImplementedError("Kinetics::installReagents");
|
||||
}
|
||||
|
||||
virtual void installGroups(size_t irxn, const std::vector<grouplist_t>& r,
|
||||
const std::vector<grouplist_t>& p);
|
||||
|
||||
virtual const std::vector<grouplist_t>& reactantGroups(size_t i) {
|
||||
return m_dummygroups;
|
||||
return m_rgroups[i];
|
||||
}
|
||||
|
||||
virtual const std::vector<grouplist_t>& productGroups(size_t i) {
|
||||
return m_dummygroups;
|
||||
return m_pgroups[i];
|
||||
}
|
||||
|
||||
//@}
|
||||
|
|
@ -949,9 +956,18 @@ protected:
|
|||
//! number of spatial dimensions of lowest-dimensional phase.
|
||||
size_t m_mindim;
|
||||
|
||||
//! Representation of each reaction equation
|
||||
std::vector<std::string> m_rxneqn;
|
||||
|
||||
//! Representation of the reactant side of each reaction equation
|
||||
std::vector<std::string> m_reactantStrings;
|
||||
|
||||
//! Representation of the product side of each reaction equation
|
||||
std::vector<std::string> m_productStrings;
|
||||
|
||||
private:
|
||||
//! Vector of group lists
|
||||
std::vector<grouplist_t> m_dummygroups;
|
||||
std::map<size_t, std::vector<grouplist_t> > m_rgroups;
|
||||
std::map<size_t, std::vector<grouplist_t> > m_pgroups;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,14 +63,11 @@ AqueousKinetics& AqueousKinetics::operator=(const AqueousKinetics& right)
|
|||
m_fwdOrder = right.m_fwdOrder;
|
||||
m_nirrev = right.m_nirrev;
|
||||
m_nrev = right.m_nrev;
|
||||
m_rgroups = right.m_rgroups;
|
||||
m_pgroups = right.m_pgroups;
|
||||
m_rxntype = right.m_rxntype;
|
||||
m_rrxn = right.m_rrxn;
|
||||
m_prxn = right.m_prxn;
|
||||
m_dn = right.m_dn;
|
||||
m_revindex = right.m_revindex;
|
||||
m_rxneqn = right.m_rxneqn;
|
||||
|
||||
m_ropf = right.m_ropf;
|
||||
m_ropr = right.m_ropr;
|
||||
|
|
@ -356,12 +353,7 @@ void AqueousKinetics::addReaction(ReactionData& r)
|
|||
if (r.reactionType == ELEMENTARY_RXN) {
|
||||
addElementaryReaction(r);
|
||||
}
|
||||
|
||||
// operations common to all reaction types
|
||||
installReagents(r);
|
||||
installGroups(reactionNumber(), r.rgroups, r.pgroups);
|
||||
incrementRxnCount();
|
||||
m_rxneqn.push_back(r.equation);
|
||||
Kinetics::addReaction(r);
|
||||
}
|
||||
|
||||
void AqueousKinetics::addElementaryReaction(ReactionData& r)
|
||||
|
|
@ -442,17 +434,6 @@ void AqueousKinetics::installReagents(const ReactionData& r)
|
|||
}
|
||||
}
|
||||
|
||||
void AqueousKinetics::installGroups(size_t irxn,
|
||||
const vector<grouplist_t>& r,
|
||||
const vector<grouplist_t>& p)
|
||||
{
|
||||
if (!r.empty()) {
|
||||
writelog("installing groups for reaction "+int2str(reactionNumber()));
|
||||
m_rgroups[reactionNumber()] = r;
|
||||
m_pgroups[reactionNumber()] = p;
|
||||
}
|
||||
}
|
||||
|
||||
void AqueousKinetics::init()
|
||||
{
|
||||
m_kk = thermo().nSpecies();
|
||||
|
|
|
|||
|
|
@ -74,16 +74,11 @@ GasKinetics& GasKinetics::operator=(const GasKinetics& right)
|
|||
m_fwdOrder = right.m_fwdOrder;
|
||||
m_nirrev = right.m_nirrev;
|
||||
m_nrev = right.m_nrev;
|
||||
m_rgroups = right.m_rgroups;
|
||||
m_pgroups = right.m_pgroups;
|
||||
m_rxntype = right.m_rxntype;
|
||||
m_rrxn = right.m_rrxn;
|
||||
m_prxn = right.m_prxn;
|
||||
m_dn = right.m_dn;
|
||||
m_revindex = right.m_revindex;
|
||||
m_rxneqn = right.m_rxneqn;
|
||||
m_reactantStrings = right.m_reactantStrings;
|
||||
m_productStrings = right.m_productStrings;
|
||||
|
||||
m_logp_ref = right.m_logp_ref;
|
||||
m_logc_ref = right.m_logc_ref;
|
||||
|
|
@ -498,12 +493,7 @@ void GasKinetics::addReaction(ReactionData& r)
|
|||
}
|
||||
|
||||
// operations common to all reaction types
|
||||
installReagents(r);
|
||||
installGroups(reactionNumber(), r.rgroups, r.pgroups);
|
||||
incrementRxnCount();
|
||||
m_rxneqn.push_back(r.equation);
|
||||
m_reactantStrings.push_back(r.reactantString);
|
||||
m_productStrings.push_back(r.productString);
|
||||
Kinetics::addReaction(r);
|
||||
m_rxntype.push_back(r.reactionType);
|
||||
}
|
||||
|
||||
|
|
@ -657,16 +647,6 @@ void GasKinetics::installReagents(const ReactionData& r)
|
|||
}
|
||||
}
|
||||
|
||||
void GasKinetics::installGroups(size_t irxn,
|
||||
const vector<grouplist_t>& r, const vector<grouplist_t>& p)
|
||||
{
|
||||
if (!r.empty()) {
|
||||
writelog("installing groups for reaction "+int2str(reactionNumber()));
|
||||
m_rgroups[reactionNumber()] = r;
|
||||
m_pgroups[reactionNumber()] = p;
|
||||
}
|
||||
}
|
||||
|
||||
void GasKinetics::init()
|
||||
{
|
||||
m_kk = thermo().nSpecies();
|
||||
|
|
|
|||
|
|
@ -129,7 +129,6 @@ InterfaceKinetics& InterfaceKinetics::operator=(const InterfaceKinetics& right)
|
|||
m_rrxn = right.m_rrxn;
|
||||
m_prxn = right.m_prxn;
|
||||
reactionType_ = right.reactionType_;
|
||||
m_rxneqn = right.m_rxneqn;
|
||||
m_conc = right.m_conc;
|
||||
m_actConc = right.m_actConc;
|
||||
m_mu0 = right.m_mu0;
|
||||
|
|
@ -888,25 +887,8 @@ void InterfaceKinetics::addReaction(ReactionData& r)
|
|||
*/
|
||||
addElementaryReaction(r);
|
||||
}
|
||||
/*
|
||||
* Add the reactants and products for m_ropnet;the current reaction
|
||||
* to the various stoichiometric coefficient arrays.
|
||||
*/
|
||||
installReagents(r);
|
||||
/*
|
||||
* Save the reaction and product groups, which are
|
||||
* part of the ReactionData class, in this class.
|
||||
* They aren't used for anything but reaction path
|
||||
* analysis.
|
||||
*/
|
||||
//installGroups(reactionNumber(), r.rgroups, r.pgroups);
|
||||
/*
|
||||
* Increase the internal number of reactions, m_ii, by one.
|
||||
* increase the size of m_perturb by one as well.
|
||||
*/
|
||||
incrementRxnCount();
|
||||
|
||||
m_rxneqn.push_back(r.equation);
|
||||
Kinetics::addReaction(r);
|
||||
|
||||
m_rxnPhaseIsReactant.push_back(std::vector<bool>(nPhases(), false));
|
||||
m_rxnPhaseIsProduct.push_back(std::vector<bool>(nPhases(), false));
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
// Copyright 2001-2004 California Institute of Technology
|
||||
|
||||
#include "cantera/kinetics/Kinetics.h"
|
||||
#include "cantera/kinetics/ReactionData.h"
|
||||
#include "cantera/base/stringUtils.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
@ -25,8 +26,7 @@ Kinetics::Kinetics() :
|
|||
m_phaseindex(),
|
||||
m_surfphase(npos),
|
||||
m_rxnphase(npos),
|
||||
m_mindim(4),
|
||||
m_dummygroups(0)
|
||||
m_mindim(4)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -43,8 +43,7 @@ Kinetics::Kinetics(const Kinetics& right) :
|
|||
m_phaseindex(),
|
||||
m_surfphase(npos),
|
||||
m_rxnphase(npos),
|
||||
m_mindim(4),
|
||||
m_dummygroups(0)
|
||||
m_mindim(4)
|
||||
{
|
||||
/*
|
||||
* Call the assignment operator
|
||||
|
|
@ -74,7 +73,11 @@ Kinetics& Kinetics::operator=(const Kinetics& right)
|
|||
m_surfphase = right.m_surfphase;
|
||||
m_rxnphase = right.m_rxnphase;
|
||||
m_mindim = right.m_mindim;
|
||||
m_dummygroups = right.m_dummygroups;
|
||||
m_rxneqn = right.m_rxneqn;
|
||||
m_reactantStrings = right.m_reactantStrings;
|
||||
m_productStrings = right.m_productStrings;
|
||||
m_rgroups = right.m_rgroups;
|
||||
m_pgroups = right.m_pgroups;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -289,4 +292,23 @@ void Kinetics::finalize()
|
|||
}
|
||||
}
|
||||
|
||||
void Kinetics::addReaction(ReactionData& r) {
|
||||
installReagents(r);
|
||||
installGroups(nReactions(), r.rgroups, r.pgroups);
|
||||
incrementRxnCount();
|
||||
m_rxneqn.push_back(r.equation);
|
||||
m_reactantStrings.push_back(r.reactantString);
|
||||
m_productStrings.push_back(r.productString);
|
||||
}
|
||||
|
||||
void Kinetics::installGroups(size_t irxn, const vector<grouplist_t>& r,
|
||||
const vector<grouplist_t>& p)
|
||||
{
|
||||
if (!r.empty()) {
|
||||
writelog("installing groups for reaction "+int2str(irxn));
|
||||
m_rgroups[irxn] = r;
|
||||
m_pgroups[irxn] = p;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue