Skip to content

Commit

Permalink
move the function from InterfaceKinetics to Kinetics
Browse files Browse the repository at this point in the history
  • Loading branch information
12Chao committed Oct 25, 2021
1 parent 563b5f3 commit d6bf509
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
2 changes: 0 additions & 2 deletions include/cantera/kinetics/InterfaceKinetics.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,6 @@ class InterfaceKinetics : public Kinetics
*/
int phaseStability(const size_t iphase) const;

virtual double rxn_enthalpy(const Composition& reactants, const Composition& products);

protected:
//! Build a SurfaceArrhenius object from a Reaction, taking into account
//! the possible sticking coefficient form and coverage dependencies
Expand Down
4 changes: 1 addition & 3 deletions include/cantera/kinetics/Kinetics.h
Original file line number Diff line number Diff line change
Expand Up @@ -873,9 +873,7 @@ class Kinetics
m_root = root;
}

virtual double rxn_enthalpy(const Composition& reactants, const Composition& products){
return 0;
};
virtual double reactionEnthalpy(const Composition& reactants, const Composition& products);
protected:
//! Cache for saved calculations within each Kinetics object.
ValueCache m_cache;
Expand Down
19 changes: 0 additions & 19 deletions src/kinetics/InterfaceKinetics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,23 +953,4 @@ void InterfaceKinetics::applyStickingCorrection(double T, double* kf)
}
}

double InterfaceKinetics::rxn_enthalpy(const Composition& reactants, const Composition& products)
{
for (size_t n = 0; n < nPhases(); n++) {
thermo(n).getPartialMolarEnthalpies(m_grt.data() + m_start[n]);
}
double rxn_deltaH = 0;
for (auto iter = products.begin(); iter != products.end(); ++iter) {
int k = kineticsSpeciesIndex(iter->first);
double stoich = iter->second;
rxn_deltaH += m_grt.data()[k] * stoich;
}
for (auto iter = reactants.begin(); iter != reactants.end(); ++iter) {
int k = kineticsSpeciesIndex(iter->first);
double stoich = iter->second;
rxn_deltaH -= m_grt.data()[k] * stoich;
}
return rxn_deltaH;
}

}
20 changes: 20 additions & 0 deletions src/kinetics/Kinetics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,4 +633,24 @@ shared_ptr<const Reaction> Kinetics::reaction(size_t i) const
return m_reactions[i];
}

double Kinetics::reactionEnthalpy(const Composition& reactants, const Composition& products)
{
vector_fp hk(nTotalSpecies());
for (size_t n = 0; n < nPhases(); n++) {
thermo(n).getPartialMolarEnthalpies(&hk[m_start[n]]);
}
double rxn_deltaH = 0;
for (const auto& product : products) {
size_t k = kineticsSpeciesIndex(product.first);
double stoich = product.second;
rxn_deltaH += hk[k] * stoich;
}
for (const auto& reactant : reactants) {
size_t k = kineticsSpeciesIndex(reactant.first);
double stoich = reactant.second;
rxn_deltaH -= hk[k] * stoich;
}
return rxn_deltaH;
}

}

0 comments on commit d6bf509

Please sign in to comment.