Skip to content

Commit

Permalink
[Kinetics] Prevent double counting in reaction path diagrams
Browse files Browse the repository at this point in the history
This fixes the double counting that occurs in reactions like:

    H + HO2 => 2 OH
  • Loading branch information
speth committed Dec 1, 2016
1 parent f2ff344 commit 12f2823
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/kinetics/ReactionPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "cantera/kinetics/ReactionPath.h"
#include "cantera/kinetics/reaction_defs.h"
#include <set>

using namespace std;

Expand Down Expand Up @@ -718,13 +719,22 @@ int ReactionPathBuilder::build(Kinetics& s, const string& element,
if (m_elatoms(m, i) > 0) {
size_t nr = m_reac[i].size();
size_t np = m_prod[i].size();
// each A->B species pair should only be counted once per reaction,
// to avoid double-counting fluxes involving species with non-unity
// stoichiometric coefficients
std::set<std::pair<size_t, size_t>> counted_pairs;

for (size_t kr = 0; kr < nr; kr++) {
size_t kkr = m_reac[i][kr];
string fwdlabel = reactionLabel(i, kr, nr, m_reac[i], s);

for (size_t kp = 0; kp < np; kp++) {
size_t kkp = m_prod[i][kp];
if (counted_pairs.find({kkr,kkp}) == counted_pairs.end()) {
counted_pairs.insert({kkr,kkp});
} else {
continue;
}
string revlabel = "";
for (size_t j = 0; j < np; j++) {
if (j != kp) {
Expand Down

0 comments on commit 12f2823

Please sign in to comment.