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

Rethink handling of duplicate reactions #132

Open
speth opened this issue Jan 28, 2022 · 4 comments
Open

Rethink handling of duplicate reactions #132

speth opened this issue Jan 28, 2022 · 4 comments
Labels
feature-request New feature request

Comments

@speth
Copy link
Member

speth commented Jan 28, 2022

Abstract

The current mechanism for handling "duplicate" reactions is mostly an attempt to replicate the corresponding syntax from the Chemkin format. However, I think there are some unwritten rules to this that we shouldn't necessarily try to replicate, and we have potentially better ways of handling reactions where the rate is a combination of different rates.

Motivation

Requiring reactions to be labeled as duplicates is an attempt to catch certain kinds of errors when assembling reaction mechanisms from multiple sources. However, it has a number of limitations.

  1. Reactions of different "types" are not considered duplicates, even if they have the same reactants and products. But in most cases, the "type" of a reaction is just a parameterization, and has no deep physical meaning, and it's certainly possible that two mechanisms could use different parameterizations (say, Plog or Chebyshev) for the same reaction, where we would want to identify these as duplicates.
  2. There is no "reverse" checking, i.e. that a reaction marked as duplicate actually has a duplicate in the mechanism. Nor is there an indicator of how many duplicates a reaction has, so while combining mechanisms that already include duplicate reactions, those groups of duplicates won't be identified as errors.

Possible Solutions

I think there are a couple of things that can be done, with different levels of difficulty.

  1. Treat reactions as potential duplicates regardless of the reaction "type". I guess for cases like third-body reactions, this requires deciding whether a reaction like A+B=C+D and A+B+M=C+D+M are considered as duplicates. If we change our definition of duplicate, I think we would want to update ck2yaml to provide a way of automatically setting relevant reactions as duplicates if the would not have satisfied Chemkin's duplicate reaction definition, and provide a way of automatically updating mechanisms to correspond to these rules.

  2. Provide a way of actually writing "duplicate" reactions as a single reaction with multiple rates. I think this should be somewhat easier with the improved infrastructure for handling reaction rates that's been introduced by Refactor Reaction Rate Evaluators #87. As a simple example,

- equation: OH + H2O2 <=> HO2 + H2O  # Reaction 88
  duplicate: true
  rate-constant: {A: 2.0e+12, b: 0.0, Ea: 427.0}
- equation: OH + H2O2 <=> HO2 + H2O  # Reaction 89
  duplicate: true
  rate-constant: {A: 1.7e+18, b: 0.0, Ea: 2.941e+04}

could instead be written as:

- equation: OH + H2O2 <=> HO2 + H2O
  rate-constants:
  - {A: 2.0e+12, b: 0.0, Ea: 427.0}
  - {A: 1.7e+18, b: 0.0, Ea: 2.941e+04}

For example, the following set of reactions from GRI 3.0:

- equation: H + O2 + M <=> HO2 + M  # Reaction 33
  type: three-body
  rate-constant: {A: 2.8e+18, b: -0.86, Ea: 0.0}
  efficiencies: {O2: 0.0, H2O: 0.0, CO: 0.75, CO2: 1.5, C2H6: 1.5, N2: 0.0,
    AR: 0.0}
- equation: H + 2 O2 <=> HO2 + O2  # Reaction 34
  rate-constant: {A: 2.08e+19, b: -1.24, Ea: 0.0}
- equation: H + O2 + H2O <=> HO2 + H2O  # Reaction 35
  rate-constant: {A: 1.126e+19, b: -0.76, Ea: 0.0}
- equation: H + O2 + N2 <=> HO2 + N2  # Reaction 36
  rate-constant: {A: 2.6e+19, b: -1.24, Ea: 0.0}
- equation: H + O2 + AR <=> HO2 + AR  # Reaction 37
  rate-constant: {A: 7.0e+17, b: -0.8, Ea: 0.0}

might instead be written as (very roughly):

- equation: H + O2 + M <=> HO2 + M
  rate-constants:
  - rate-constant: {A: 2.8e+18, b: -0.86, Ea: 0.0}
    third-body: M
    efficiencies: {CO: 0.75, CO2: 1.5, C2H6: 1.5}
  - rate-constant: {A: 2.08e+19, b: -1.24, Ea: 0.0}
    third-body: O2
  - rate-constant: {A: 1.126e+19, b: -0.76, Ea: 0.0}
    third-body: H2O
  - rate-constant: {A: 2.6e+19, b: -1.24, Ea: 0.0}
    third-body: N2
  - rate-constant: {A: 7.0e+17, b: -0.8, Ea: 0.0}
    third-body: AR

While this is obviously quite a bit more complicated to implement, I think it would have benefits for end users, where groups of reactions like these are really perceived as a single reaction and the need to split them into multiple reactions is an artificial result of how some modeling tools require the rates to be parameterized. Reactions with explicit reverse rates also fall into this category, where Cantera splits them up even though they really should be considered as a single reaction. Of course, the same need for automatically converting reactions to this style would exist as with (1).

@ischoegl
Copy link
Member

ischoegl commented Jan 28, 2022

Thanks for opening this issue, I think this is interesting. FWIW, I am also referencing Cantera/cantera#704 and Cantera/cantera#1019.

@ischoegl
Copy link
Member

ischoegl commented Jun 19, 2022

Linking user group discussion and Cantera/cantera#1193 - as an example, prior to Cantera 2.6, the following duplicate reactions worked (as the second version was not detected as a third-body reaction). Starting in Cantera 2.6, the reactions require a duplicate declaration to prevent the following error:

*******************************************************************************
InputFileError thrown by Kinetics::checkDuplicates:
Undeclared duplicate reactions detected:
Reaction 6: H + O2 + M <=> HO2 + M
Reaction 5: H + O2 + O2 <=> HO2 + O2
*******************************************************************************

Nora-Khalil added a commit to Nora-Khalil/RMG-Py that referenced this issue Jul 11, 2022
For MultiArrhenius and MultiPDepArrhenius kinetics
we need to make more than one reaction in the
list of reactions for Cantera yaml.
(at least until this is implemented:
Cantera/enhancements#132 )
Nora-Khalil added a commit to ReactionMechanismGenerator/RMG-Py that referenced this issue Jul 13, 2022
For MultiArrhenius and MultiPDepArrhenius kinetics
we need to make more than one reaction in the
list of reactions for Cantera yaml.
(at least until this is implemented:
Cantera/enhancements#132 )
rwest pushed a commit to ReactionMechanismGenerator/RMG-Py that referenced this issue Jul 14, 2022
For MultiArrhenius and MultiPDepArrhenius kinetics
we need to make more than one reaction in the
list of reactions for Cantera yaml.
(at least until this is implemented:
Cantera/enhancements#132 )
rwest pushed a commit to ReactionMechanismGenerator/RMG-Py that referenced this issue Jul 14, 2022
For MultiArrhenius and MultiPDepArrhenius kinetics
we need to make more than one reaction in the
list of reactions for Cantera yaml.
(at least until this is implemented:
Cantera/enhancements#132 )
rwest pushed a commit to ReactionMechanismGenerator/RMG-Py that referenced this issue Jul 14, 2022
For MultiArrhenius and MultiPDepArrhenius kinetics
we need to make more than one reaction in the
list of reactions for Cantera yaml.
(at least until this is implemented:
Cantera/enhancements#132 )
rwest pushed a commit to ReactionMechanismGenerator/RMG-Py that referenced this issue Jul 14, 2022
For MultiArrhenius and MultiPDepArrhenius kinetics
we need to make more than one reaction in the
list of reactions for Cantera yaml.
(at least until this is implemented:
Cantera/enhancements#132 )
@corykinney
Copy link

@ischoegl Would it be possible to have ck2yaml automatically flag these as duplicates in the converted file (even though they are not declared that way in the CHEMKIN file) since Cantera is rightfully treating them as duplicates, or would automatically doing so would be undesirable? Additionally it could set a collision efficiency of zero on the generic form of the three body reaction, and raise a warning if the efficiency is set to a nonzero value.

@ischoegl
Copy link
Member

@cory-kinney … the way things are implemented, ck2yaml is strictly a conversion tool. The duplicate checks are run after the file is converted. For the time being, my preference would be to issue warnings rather than errors (or implement some logic to be permissive about undeclared duplicates).

Nora-Khalil added a commit to ReactionMechanismGenerator/RMG-Py that referenced this issue Mar 2, 2023
For MultiArrhenius and MultiPDepArrhenius kinetics
we need to make more than one reaction in the
list of reactions for Cantera yaml.
(at least until this is implemented:
Cantera/enhancements#132 )
xiaoruiDong pushed a commit to ReactionMechanismGenerator/RMG-Py that referenced this issue Apr 14, 2023
For MultiArrhenius and MultiPDepArrhenius kinetics
we need to make more than one reaction in the
list of reactions for Cantera yaml.
(at least until this is implemented:
Cantera/enhancements#132 )
Nora-Khalil added a commit to ReactionMechanismGenerator/RMG-Py that referenced this issue Jan 2, 2024
…ubstituted for 'yml'

Attach the YAMLWriter listener

Work on the yaml writing for cantera

Renaming yml_test to cantera

This is for writing Cantera yaml files

updated set_cantera_kinetics in falloff.py

spelled "high" wrong in set_cantera_kinetics

added write_cantera_inputs to falloff.pyx for Troe reactions

Fixing Lindemann and Troe

deleted write_cantera_inputs,
restructured using to_cantera > set_cantera_kinetics > to_cantera_kinetics
for Lindemann and Troe reactions

added efficiencies

restructured cantera.py, now includes MultiArrhenius reactions

added Chebyshev

restructured and added in RMG equations

added in Surface Arrhenius

added sticking coefficient :)

use_chemkin_identifier=True when making Cantera objects

This uses the correct species names

Dump yaml in the order of the dict, not alphabetical

remove quotes from species names

Handle duplicate reactions

For MultiArrhenius and MultiPDepArrhenius kinetics
we need to make more than one reaction in the
list of reactions for Cantera yaml.
(at least until this is implemented:
Cantera/enhancements#132 )

added the beginnings of the catalysis edits

still need to edit 'state' and fix 'vector<double>' error

fixed for catalysis.

Separates gas and surface reactions in the "reactions" section.
Now just need to fix the bug with the C.Pt(22) stuff. Stay strong, shortie

wip changes for stickingcoeffcient issue

fixed "sites" v. "size" problem, yaml_writer now works for catalysis and gas phase.

Time for pull request?

Removing comments

Trying cantera 2.5+ from conda-forge in environment.yml

I suspected that the unit tests are failing
because the new code can't work with
cantera 2.3 from the RMG channel

Trying Cantera 2.5+ from cantera channel in environment.yml

Added in doc strings to methods. Removed unused imports

Removed unused import from reaction.py

renamed cantera.py to cantera_.py. Edited import statement in main.py to reflect this name change. Edited reaction.py so depreciated Cantera term is not used. Edited reactionTest.py so that test_falloff is successful for third body reactions

Edited high_rate, low_rate in set_cantera_kinetics() for Lindemann reactions. Can now extract the high & low rate from the Cantera Lindemann object, which is necessary for reactionTest.py to pass successfully.

restructed set_cantera_kinetics() and to_cantera_kinetics() for Lindemann reactions in falloff.pyx. Added Lindemann reaction checks in falloff.pyx

Minor stylish change in falloff.py/ troe to cantera

cleaning up falloff.pyx after rebase conflicts
Nora-Khalil added a commit to ReactionMechanismGenerator/RMG-Py that referenced this issue Jan 3, 2024
…ubstituted for 'yml'

Attach the YAMLWriter listener

Work on the yaml writing for cantera

Renaming yml_test to cantera

This is for writing Cantera yaml files

updated set_cantera_kinetics in falloff.py

spelled "high" wrong in set_cantera_kinetics

added write_cantera_inputs to falloff.pyx for Troe reactions

Fixing Lindemann and Troe

deleted write_cantera_inputs,
restructured using to_cantera > set_cantera_kinetics > to_cantera_kinetics
for Lindemann and Troe reactions

added efficiencies

restructured cantera.py, now includes MultiArrhenius reactions

added Chebyshev

restructured and added in RMG equations

added in Surface Arrhenius

added sticking coefficient :)

use_chemkin_identifier=True when making Cantera objects

This uses the correct species names

Dump yaml in the order of the dict, not alphabetical

remove quotes from species names

Handle duplicate reactions

For MultiArrhenius and MultiPDepArrhenius kinetics
we need to make more than one reaction in the
list of reactions for Cantera yaml.
(at least until this is implemented:
Cantera/enhancements#132 )

added the beginnings of the catalysis edits

still need to edit 'state' and fix 'vector<double>' error

fixed for catalysis.

Separates gas and surface reactions in the "reactions" section.
Now just need to fix the bug with the C.Pt(22) stuff. Stay strong, shortie

wip changes for stickingcoeffcient issue

fixed "sites" v. "size" problem, yaml_writer now works for catalysis and gas phase.

Time for pull request?

Removing comments

Trying cantera 2.5+ from conda-forge in environment.yml

I suspected that the unit tests are failing
because the new code can't work with
cantera 2.3 from the RMG channel

Trying Cantera 2.5+ from cantera channel in environment.yml

Added in doc strings to methods. Removed unused imports

Removed unused import from reaction.py

renamed cantera.py to cantera_.py. Edited import statement in main.py to reflect this name change. Edited reaction.py so depreciated Cantera term is not used. Edited reactionTest.py so that test_falloff is successful for third body reactions

Edited high_rate, low_rate in set_cantera_kinetics() for Lindemann reactions. Can now extract the high & low rate from the Cantera Lindemann object, which is necessary for reactionTest.py to pass successfully.

restructed set_cantera_kinetics() and to_cantera_kinetics() for Lindemann reactions in falloff.pyx. Added Lindemann reaction checks in falloff.pyx

Minor stylish change in falloff.py/ troe to cantera

cleaning up falloff.pyx after rebase conflicts
Nora-Khalil added a commit to ReactionMechanismGenerator/RMG-Py that referenced this issue Jan 3, 2024
For MultiArrhenius and MultiPDepArrhenius kinetics
we need to make more than one reaction in the
list of reactions for Cantera yaml.
(at least until this is implemented:
Cantera/enhancements#132 )
ntietje1 pushed a commit to ntietje1/RMG-Py that referenced this issue Mar 20, 2024
…ubstituted for 'yml'

Attach the YAMLWriter listener

Work on the yaml writing for cantera

Renaming yml_test to cantera

This is for writing Cantera yaml files

updated set_cantera_kinetics in falloff.py

spelled "high" wrong in set_cantera_kinetics

added write_cantera_inputs to falloff.pyx for Troe reactions

Fixing Lindemann and Troe

deleted write_cantera_inputs,
restructured using to_cantera > set_cantera_kinetics > to_cantera_kinetics
for Lindemann and Troe reactions

added efficiencies

restructured cantera.py, now includes MultiArrhenius reactions

added Chebyshev

restructured and added in RMG equations

added in Surface Arrhenius

added sticking coefficient :)

use_chemkin_identifier=True when making Cantera objects

This uses the correct species names

Dump yaml in the order of the dict, not alphabetical

remove quotes from species names

Handle duplicate reactions

For MultiArrhenius and MultiPDepArrhenius kinetics
we need to make more than one reaction in the
list of reactions for Cantera yaml.
(at least until this is implemented:
Cantera/enhancements#132 )

added the beginnings of the catalysis edits

still need to edit 'state' and fix 'vector<double>' error

fixed for catalysis.

Separates gas and surface reactions in the "reactions" section.
Now just need to fix the bug with the C.Pt(22) stuff. Stay strong, shortie

wip changes for stickingcoeffcient issue

fixed "sites" v. "size" problem, yaml_writer now works for catalysis and gas phase.

Time for pull request?

Removing comments

Trying cantera 2.5+ from conda-forge in environment.yml

I suspected that the unit tests are failing
because the new code can't work with
cantera 2.3 from the RMG channel

Trying Cantera 2.5+ from cantera channel in environment.yml

Added in doc strings to methods. Removed unused imports

Removed unused import from reaction.py

renamed cantera.py to cantera_.py. Edited import statement in main.py to reflect this name change. Edited reaction.py so depreciated Cantera term is not used. Edited reactionTest.py so that test_falloff is successful for third body reactions

Edited high_rate, low_rate in set_cantera_kinetics() for Lindemann reactions. Can now extract the high & low rate from the Cantera Lindemann object, which is necessary for reactionTest.py to pass successfully.

restructed set_cantera_kinetics() and to_cantera_kinetics() for Lindemann reactions in falloff.pyx. Added Lindemann reaction checks in falloff.pyx

Minor stylish change in falloff.py/ troe to cantera

cleaning up falloff.pyx after rebase conflicts
ntietje1 pushed a commit to ntietje1/RMG-Py that referenced this issue Mar 20, 2024
For MultiArrhenius and MultiPDepArrhenius kinetics
we need to make more than one reaction in the
list of reactions for Cantera yaml.
(at least until this is implemented:
Cantera/enhancements#132 )
rwest pushed a commit to ReactionMechanismGenerator/RMG-Py that referenced this issue Mar 22, 2024
…ubstituted for 'yml'

Attach the YAMLWriter listener

Work on the yaml writing for cantera

Renaming yml_test to cantera

This is for writing Cantera yaml files

updated set_cantera_kinetics in falloff.py

spelled "high" wrong in set_cantera_kinetics

added write_cantera_inputs to falloff.pyx for Troe reactions

Fixing Lindemann and Troe

deleted write_cantera_inputs,
restructured using to_cantera > set_cantera_kinetics > to_cantera_kinetics
for Lindemann and Troe reactions

added efficiencies

restructured cantera.py, now includes MultiArrhenius reactions

added Chebyshev

restructured and added in RMG equations

added in Surface Arrhenius

added sticking coefficient :)

use_chemkin_identifier=True when making Cantera objects

This uses the correct species names

Dump yaml in the order of the dict, not alphabetical

remove quotes from species names

Handle duplicate reactions

For MultiArrhenius and MultiPDepArrhenius kinetics
we need to make more than one reaction in the
list of reactions for Cantera yaml.
(at least until this is implemented:
Cantera/enhancements#132 )

added the beginnings of the catalysis edits

still need to edit 'state' and fix 'vector<double>' error

fixed for catalysis.

Separates gas and surface reactions in the "reactions" section.
Now just need to fix the bug with the C.Pt(22) stuff. Stay strong, shortie

wip changes for stickingcoeffcient issue

fixed "sites" v. "size" problem, yaml_writer now works for catalysis and gas phase.

Time for pull request?

Removing comments

Trying cantera 2.5+ from conda-forge in environment.yml

I suspected that the unit tests are failing
because the new code can't work with
cantera 2.3 from the RMG channel

Trying Cantera 2.5+ from cantera channel in environment.yml

Added in doc strings to methods. Removed unused imports

Removed unused import from reaction.py

renamed cantera.py to cantera_.py. Edited import statement in main.py to reflect this name change. Edited reaction.py so depreciated Cantera term is not used. Edited reactionTest.py so that test_falloff is successful for third body reactions

Edited high_rate, low_rate in set_cantera_kinetics() for Lindemann reactions. Can now extract the high & low rate from the Cantera Lindemann object, which is necessary for reactionTest.py to pass successfully.

restructed set_cantera_kinetics() and to_cantera_kinetics() for Lindemann reactions in falloff.pyx. Added Lindemann reaction checks in falloff.pyx

Minor stylish change in falloff.py/ troe to cantera

cleaning up falloff.pyx after rebase conflicts
rwest pushed a commit to ReactionMechanismGenerator/RMG-Py that referenced this issue Mar 22, 2024
For MultiArrhenius and MultiPDepArrhenius kinetics
we need to make more than one reaction in the
list of reactions for Cantera yaml.
(at least until this is implemented:
Cantera/enhancements#132 )
rwest pushed a commit to ReactionMechanismGenerator/RMG-Py that referenced this issue Apr 1, 2024
…ubstituted for 'yml'

Attach the YAMLWriter listener

Work on the yaml writing for cantera

Renaming yml_test to cantera

This is for writing Cantera yaml files

updated set_cantera_kinetics in falloff.py

spelled "high" wrong in set_cantera_kinetics

added write_cantera_inputs to falloff.pyx for Troe reactions

Fixing Lindemann and Troe

deleted write_cantera_inputs,
restructured using to_cantera > set_cantera_kinetics > to_cantera_kinetics
for Lindemann and Troe reactions

added efficiencies

restructured cantera.py, now includes MultiArrhenius reactions

added Chebyshev

restructured and added in RMG equations

added in Surface Arrhenius

added sticking coefficient :)

use_chemkin_identifier=True when making Cantera objects

This uses the correct species names

Dump yaml in the order of the dict, not alphabetical

remove quotes from species names

Handle duplicate reactions

For MultiArrhenius and MultiPDepArrhenius kinetics
we need to make more than one reaction in the
list of reactions for Cantera yaml.
(at least until this is implemented:
Cantera/enhancements#132 )

added the beginnings of the catalysis edits

still need to edit 'state' and fix 'vector<double>' error

fixed for catalysis.

Separates gas and surface reactions in the "reactions" section.
Now just need to fix the bug with the C.Pt(22) stuff. Stay strong, shortie

wip changes for stickingcoeffcient issue

fixed "sites" v. "size" problem, yaml_writer now works for catalysis and gas phase.

Time for pull request?

Removing comments

Trying cantera 2.5+ from conda-forge in environment.yml

I suspected that the unit tests are failing
because the new code can't work with
cantera 2.3 from the RMG channel

Trying Cantera 2.5+ from cantera channel in environment.yml

Added in doc strings to methods. Removed unused imports

Removed unused import from reaction.py

renamed cantera.py to cantera_.py. Edited import statement in main.py to reflect this name change. Edited reaction.py so depreciated Cantera term is not used. Edited reactionTest.py so that test_falloff is successful for third body reactions

Edited high_rate, low_rate in set_cantera_kinetics() for Lindemann reactions. Can now extract the high & low rate from the Cantera Lindemann object, which is necessary for reactionTest.py to pass successfully.

restructed set_cantera_kinetics() and to_cantera_kinetics() for Lindemann reactions in falloff.pyx. Added Lindemann reaction checks in falloff.pyx

Minor stylish change in falloff.py/ troe to cantera

cleaning up falloff.pyx after rebase conflicts
rwest pushed a commit to ReactionMechanismGenerator/RMG-Py that referenced this issue Apr 1, 2024
For MultiArrhenius and MultiPDepArrhenius kinetics
we need to make more than one reaction in the
list of reactions for Cantera yaml.
(at least until this is implemented:
Cantera/enhancements#132 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature request
Projects
No open projects
Development

No branches or pull requests

3 participants