本文整理汇总了C++中Kinetics::speciesPhase方法的典型用法代码示例。如果您正苦于以下问题:C++ Kinetics::speciesPhase方法的具体用法?C++ Kinetics::speciesPhase怎么用?C++ Kinetics::speciesPhase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kinetics
的用法示例。
在下文中一共展示了Kinetics::speciesPhase方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkElectrochemReaction
bool checkElectrochemReaction(const XML_Node& p, Kinetics& kin, const XML_Node& r)
{
// If other phases are involved in the reaction mechanism, they must be
// listed in a 'phaseArray' child element. Homogeneous mechanisms do not
// need to include a phaseArray element.
vector<string> phase_ids;
if (p.hasChild("phaseArray")) {
const XML_Node& pa = p.child("phaseArray");
getStringArray(pa, phase_ids);
}
phase_ids.push_back(p["id"]);
// Get reaction product and reactant information
Composition reactants = parseCompString(r.child("reactants").value());
Composition products = parseCompString(r.child("products").value());
// If the reaction has undeclared species don't perform electrochemical check
for (const auto& sp : reactants) {
if (kin.kineticsSpeciesIndex(sp.first) == npos) {
return true;
}
}
for (const auto& sp : products) {
if (kin.kineticsSpeciesIndex(sp.first) == npos) {
return true;
}
}
// Initialize the electron counter for each phase
std::vector<double> e_counter(phase_ids.size(), 0.0);
// Find the amount of electrons in the products for each phase
for (const auto& sp : products) {
const ThermoPhase& ph = kin.speciesPhase(sp.first);
size_t k = ph.speciesIndex(sp.first);
double stoich = sp.second;
for (size_t m = 0; m < phase_ids.size(); m++) {
if (phase_ids[m] == ph.id()) {
e_counter[m] += stoich * ph.charge(k);
break;
}
}
}
// Subtract the amount of electrons in the reactants for each phase
for (const auto& sp : reactants) {
const ThermoPhase& ph = kin.speciesPhase(sp.first);
size_t k = ph.speciesIndex(sp.first);
double stoich = sp.second;
for (size_t m = 0; m < phase_ids.size(); m++) {
if (phase_ids[m] == ph.id()) {
e_counter[m] -= stoich * ph.charge(k);
break;
}
}
}
// If the electrons change phases then the reaction is electrochemical
bool echemical = false;
for(size_t m = 0; m < phase_ids.size(); m++) {
if (fabs(e_counter[m]) > 1e-4) {
echemical = true;
break;
}
}
// If the reaction is electrochemical, ensure the reaction is identified as
// electrochemical. If not already specified beta is assumed to be 0.5
std::string type = ba::to_lower_copy(r["type"]);
if (!r.child("rateCoeff").hasChild("electrochem")) {
if ((type != "butlervolmer_noactivitycoeffs" &&
type != "butlervolmer" &&
type != "surfaceaffinity") &&
echemical) {
XML_Node& f = r.child("rateCoeff").addChild("electrochem","");
f.addAttribute("beta",0.5);
}
}
return true;
}