Skip to content

Commit

Permalink
[Kinetics] Prevent positive feedback in negative species concentrations
Browse files Browse the repository at this point in the history
For binary (or higher order) reactions, multiple negative (but small, i.e. with
respect to integration tolerances) species concentrations should not produce
positive reaction rates that would drive those concentrations to even more
negative values.
  • Loading branch information
speth committed Aug 23, 2015
1 parent bb2d1c0 commit 60b98b3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions include/cantera/kinetics/StoichManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,11 @@ class C2
}

void multiply(const doublereal* S, doublereal* R) const {
R[m_rxn] *= S[m_ic0] * S[m_ic1];
if (S[m_ic0] < 0 && S[m_ic1] < 0) {
R[m_rxn] = 0;
} else {
R[m_rxn] *= S[m_ic0] * S[m_ic1];
}
}

void incrementReaction(const doublereal* S, doublereal* R) const {
Expand Down Expand Up @@ -281,7 +285,12 @@ class C3
}

void multiply(const doublereal* S, doublereal* R) const {
R[m_rxn] *= S[m_ic0] * S[m_ic1] * S[m_ic2];
if ((S[m_ic0] < 0 && (S[m_ic1] < 0 || S[m_ic2] < 0)) ||
(S[m_ic1] < 0 && S[m_ic2] < 0)) {
R[m_rxn] = 0;
} else {
R[m_rxn] *= S[m_ic0] * S[m_ic1] * S[m_ic2];
}
}

void incrementReaction(const doublereal* S, doublereal* R) const {
Expand Down Expand Up @@ -357,12 +366,19 @@ class C_AnyN

void multiply(const doublereal* input, doublereal* output) const {
doublereal oo;
int neg_count = 0;
for (size_t n = 0; n < m_n; n++) {
oo = m_order[n];
if (oo != 0.0) {
if (input[m_ic[n]] < 0) {
neg_count++;
}
output[m_rxn] *= ppow(input[m_ic[n]], oo);
}
}
if (neg_count > 1) {
output[m_rxn] = 0;
}
}

void incrementSpecies(const doublereal* input,
Expand Down

0 comments on commit 60b98b3

Please sign in to comment.