Skip to content

Commit

Permalink
[Kinetics] Eliminate unnecessary m_rrxn and m_prxn variables
Browse files Browse the repository at this point in the history
This information can be extracted from the Reaction objects as-needed.
  • Loading branch information
speth committed Jul 20, 2015
1 parent ca90c67 commit f623e44
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 34 deletions.
20 changes: 0 additions & 20 deletions include/cantera/kinetics/Kinetics.h
Original file line number Diff line number Diff line change
Expand Up @@ -938,26 +938,6 @@ class Kinetics
//! Vector of Reaction objects represented by this Kinetics manager
std::vector<shared_ptr<Reaction> > m_reactions;

//! m_rrxn is a vector of maps, containing the reactant
//! stoichiometric coefficient information
/*!
* m_rrxn has a length equal to the total number of species in the
* kinetics object. For each species, there exists a map, with the
* reaction number being the key, and the reactant stoichiometric
* coefficient for the species being the value.
*/
std::vector<std::map<size_t, doublereal> > m_rrxn;

//! m_prxn is a vector of maps, containing the reactant
//! stoichiometric coefficient information
/**
* m_prxn is a vector of maps. m_prxn has a length equal to the total
* number of species in the kinetics object. For each species, there
* exists a map, with the reaction number being the key, and the product
* stoichiometric coefficient for the species being the value.
*/
std::vector<std::map<size_t, doublereal> > m_prxn;

std::vector<int> m_rxntype;

//! m_thermo is a vector of pointers to ThermoPhase objects that are
Expand Down
8 changes: 4 additions & 4 deletions include/cantera/thermo/ShomatePoly.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ class ShomatePoly : public SpeciesThermoInterpType
* - `t[4] = log(t)`
* - `t[5] = 1.0/t;
*
* @param tt Vector of temperature polynomials
* @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
* @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
* @param s_R Vector of Dimensionless entropies. (length m_kk).
* @param[in] tt Array of evaluated temperature functions
* @param[out] cp_R Dimensionless heat capacity
* @param[out] h_RT Dimensionless enthalpy
* @param[out] s_R Dimensionless entropy
*/
virtual void updateProperties(const doublereal* tt,
doublereal* cp_R, doublereal* h_RT,
Expand Down
2 changes: 0 additions & 2 deletions src/kinetics/BulkKinetics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ void BulkKinetics::modifyElementaryReaction(size_t i, ElementaryReaction& rNew)
void BulkKinetics::init()
{
m_kk = thermo().nSpecies();
m_rrxn.resize(m_kk);
m_prxn.resize(m_kk);
m_conc.resize(m_kk);
m_grt.resize(m_kk);
}
Expand Down
2 changes: 0 additions & 2 deletions src/kinetics/InterfaceKinetics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -952,8 +952,6 @@ void InterfaceKinetics::init()
for (size_t n = 0; n < nPhases(); n++) {
m_kk += thermo(n).nSpecies();
}
m_rrxn.resize(m_kk);
m_prxn.resize(m_kk);
m_actConc.resize(m_kk);
m_conc.resize(m_kk);
m_mu0.resize(m_kk);
Expand Down
10 changes: 4 additions & 6 deletions src/kinetics/Kinetics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ Kinetics& Kinetics::operator=(const Kinetics& right)
m_kk = right.m_kk;
m_perturb = right.m_perturb;
m_reactions = right.m_reactions;
m_rrxn = right.m_rrxn;
m_prxn = right.m_prxn;
m_rxntype = right.m_rxntype;

m_thermo = right.m_thermo; // DANGER -> shallow pointer copy
Expand Down Expand Up @@ -422,12 +420,14 @@ size_t Kinetics::speciesPhaseIndex(size_t k)

double Kinetics::reactantStoichCoeff(size_t kSpec, size_t irxn) const
{
return getValue(m_rrxn[kSpec], irxn, 0.0);
return getValue(m_reactions[irxn]->reactants, kineticsSpeciesName(kSpec),
0.0);
}

double Kinetics::productStoichCoeff(size_t kSpec, size_t irxn) const
{
return getValue(m_prxn[kSpec], irxn, 0.0);
return getValue(m_reactions[irxn]->products, kineticsSpeciesName(kSpec),
0.0);
}

void Kinetics::getFwdRatesOfProgress(doublereal* fwdROP)
Expand Down Expand Up @@ -607,7 +607,6 @@ bool Kinetics::addReaction(shared_ptr<Reaction> r)
size_t k = kineticsSpeciesIndex(iter->first);
rk.push_back(k);
rstoich.push_back(iter->second);
m_rrxn[k][irxn] = iter->second;
}

for (Composition::const_iterator iter = r->products.begin();
Expand All @@ -616,7 +615,6 @@ bool Kinetics::addReaction(shared_ptr<Reaction> r)
size_t k = kineticsSpeciesIndex(iter->first);
pk.push_back(k);
pstoich.push_back(iter->second);
m_prxn[k][irxn] = iter->second;
}

// The default order for each reactant is its stoichiometric coefficient,
Expand Down

0 comments on commit f623e44

Please sign in to comment.