Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in reaction path flux calculation #377

Closed
speth opened this issue Nov 2, 2016 · 2 comments · Fixed by #424
Closed

Error in reaction path flux calculation #377

speth opened this issue Nov 2, 2016 · 2 comments · Fixed by #424

Comments

@speth
Copy link
Member

speth commented Nov 2, 2016

The reaction path flux calculation appears to fail for reactions such as:

H + HO2 <=> 2 OH

For example, running the following code:

import cantera as ct
g = ct.Solution('h2o2.xml')
g.TPX = 900, ct.one_atm, 'H:0.1, HO2:0.1, AR:6'
diagram = ct.ReactionPathDiagram(g, 'H')
ropf = g.forward_rates_of_progress
ropr = g.reverse_rates_of_progress
for i in range(g.n_reactions):
    if (ropf[i] > 1e-8 or ropr[i] > 1e-8) and ('H' in g.reaction(i).reactants or 'H' in g.reaction(i).products):
        print('{:2d}  {:25s}  {:11.5g} {:11.5g}'.format(i, g.reaction_equation(i), ropf[i], ropr[i]))
print(diagram.get_data())
print(g['H'].net_production_rates)

Produces the following output:

 5  H + O2 + M <=> HO2 + M               0  1.3514e-06
 8  AR + H + O2 <=> AR + HO2             0  1.5244e-05
10  2 H + M <=> H2 + M             0.46067           0
14  H + HO2 <=> H2O + O             130.12           0
15  H + HO2 <=> H2 + O2             1176.1           0
16  H + HO2 <=> 2 OH                2809.2           0

H HO2 H2 H2O H2O2 
H HO2 0 -1.65958e-05
H H2 1176.99 -0
H H2O 130.122 -0
H H2O2 0 -0
HO2 H2 1176.07 -0
HO2 H2O 130.122 -0
HO2 H2O2 79.6986 -0
H2 H2O 0 -0
H2 H2O2 0 -0
H2O H2O2 0 -0

[-4116.29642908]

From this, we see:

  • Reactions 5+8 give the correct flux for HO2 -> H
  • Reactions 10+15 give the correct flux for H -> H2
  • Reaction 14 gives the correct flux for H -> H2O
  • Reaction 16 is not contributing to the apparent flux of H -> OH
  • Reaction 16 is not contributing to the apparent flux of HO2 -> OH

In addition, the sum of all fluxes from H (-1.6e-5 - 1176 - 130 = -1306) do not equal the net production rate of H (-4116).

@speth
Copy link
Member Author

speth commented Nov 2, 2016

In Cantera 2.1.2, this calculation is differently wrong. Instead of giving zero flux for H -> OH and HO2 ->OH, it gives twice the correct value. A slightly modified version of the above script:

import cantera as ct
g = ct.Solution('h2o2.xml')
g.TPX = 900, ct.one_atm, 'H:0.1, HO2:0.1, AR:6'
diagram = ct.ReactionPathDiagram(g, 'H')
ropf = g.forward_rates_of_progress
ropr = g.reverse_rates_of_progress
for i in range(g.n_reactions):
    if (ropf[i] > 1e-8 or ropr[i] > 1e-8) and ('H' in g.reaction(i).reactants or 'H' in g.reaction(i).products):
        print('{:2d}  {:25s}  {:11.5g} {:11.5g}'.format(i, g.reaction_equation(i), ropf[i], ropr[i]))
print(diagram.get_data())
print(g['H'].net_production_rates)

gives the output:

 7  H + O2 + AR <=> HO2 + AR             0  1.5244e-05
 9  2 H + M <=> H2 + M             0.46067           0
13  H + HO2 <=> O + H2O             130.12           0
14  H + HO2 <=> O2 + H2             1176.1           0
15  H + HO2 <=> 2 OH                2809.2           0

H HO2 H2 H2O OH H2O2 
H HO2 0 -1.52444e-05
H H2 1176.99 -0
H H2O 130.122 -0
H OH 5618.36 -0
H H2O2 0 -0
HO2 H2 1176.07 -0
HO2 H2O 130.122 -0
HO2 OH 5618.36 -0
HO2 H2O2 79.6986 -0
H2 H2O 0 -0
H2 OH 0 -0
H2 H2O2 0 -0
H2O OH 0 -0
H2O H2O2 0 -0
OH H2O2 0 -0

[-4116.29643043]

@speth
Copy link
Member Author

speth commented Dec 2, 2016

speth/cantera@f2ff344 is a partial fix for this issue, and restores the double-counting behavior seen before 37f71bd.

speth/cantera@12f2823 is an attempt to fix the double-counting seen when computing the flux of H->OH and HO2->OH in the reaction H + HO2 <=> 2 OH. It does achieve this goal. However, this change seems to then cause the flux of HO2->H2O2 from the reaction 2 HO2 <=> H2O2 + O2 not to be correct (where I think this flux should be twice the ROP for the reaction, since two H atoms are being transferred). As an example:

import cantera as ct
g = ct.Solution('h2o2.xml')

g.TPX = 900, ct.one_atm, 'H:0.1, HO2:0.1, AR:6'
diagram = ct.ReactionPathDiagram(g, 'H')
ropf = g.forward_rates_of_progress
ropr = g.reverse_rates_of_progress
for i in range(g.n_reactions):
    if (ropf[i] > 1e-8 or ropr[i] > 1e-8):
        print('{:2d}  {:25s}  {:11.5g} {:11.5g}'.format(
            i, g.reaction_equation(i), ropf[i], ropr[i]))

print()
for i,line in enumerate(diagram.get_data().split('\n')):
    s = line.split()
    if len(s) != 4:
        continue
    print('{:>6s} -> {:6s} {: 9.2f} {: 9.2f}'.format(
        s[0], s[1], float(s[2]), float(s[3])))

gives the output:

 5  H + O2 + M <=> HO2 + M               0  1.3514e-06
 8  AR + H + O2 <=> AR + HO2             0  1.5244e-05
10  2 H + M <=> H2 + M             0.46067           0
14  H + HO2 <=> H2O + O             130.12           0
15  H + HO2 <=> H2 + O2             1176.1           0
16  H + HO2 <=> 2 OH                2809.2           0
25  2 HO2 <=> H2O2 + O2             15.426           0
26  2 HO2 <=> H2O2 + O2             24.423           0

     H -> HO2         0.00     -0.00
     H -> H2       1176.53     -0.00
     H -> H2O       130.12     -0.00
     H -> OH       2809.18     -0.00
     H -> H2O2        0.00     -0.00
   HO2 -> H2       1176.07     -0.00
   HO2 -> H2O       130.12     -0.00
   HO2 -> OH       2809.18     -0.00
   HO2 -> H2O2       39.85     -0.00
    H2 -> H2O         0.00     -0.00
    H2 -> OH          0.00     -0.00
    H2 -> H2O2        0.00     -0.00
   H2O -> OH          0.00     -0.00
   H2O -> H2O2        0.00     -0.00
    OH -> H2O2        0.00     -0.00

speth added a commit to speth/cantera that referenced this issue Jan 27, 2017
This fixes the double counting that occurs in reactions like:

    H + HO2 => 2 OH

Fixes Cantera#377
speth added a commit to speth/cantera that referenced this issue Jan 28, 2017
This fixes the double counting that occurs in reactions like:

    H + HO2 => 2 OH

Fixes Cantera#377
speth added a commit that referenced this issue Feb 13, 2017
This fixes the double counting that occurs in reactions like:

    H + HO2 => 2 OH

Fixes #377
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant