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

Detect unspecified thirdbody collision partners #1015

Merged
merged 7 commits into from
Apr 27, 2021

Conversation

ischoegl
Copy link
Member

@ischoegl ischoegl commented Apr 19, 2021

Changes proposed in this pull request

This PR is the second half of a fix for #967 (with the first half being taken care of by #968). I decided to post this as a dedicated PR instead of attaching the commits to #968, as review policies weren't clear, and this addition doesn't depend on the solution proposed in #968.

I believe the question on how to treat concentration has been settled in discussions in #967 and #968, but a process to convert reactions that explicitly specify a collision partner was still missing (per @decaluwe's suggestion). As an alternative to explicitly relabeling all affected reactions, it is possible to leave the existing syntax

- equation: H + 2 O2 <=> HO2 + O2
  rate-constant: {A: 2.08e+19, b: -1.24, Ea: 0.0}

and use simple rules to identify this reaction as a three-body reaction in a pre-processing step (similar to what is already done for the detection of electrochemical reactions). I.e. O2 would be detected as the collision partner, and treated as if one would manually specify

- equation: H + O2 + M <=> HO2 + M
  rate-constant: {A: 2.08e+19, b: -1.24, Ea: 0.0}
  type: three-body
  default-efficiency: 0
  efficiencies: {O2: 1.0}

Specifically, I am suggesting the following four rules for converting an elementary to a three-body reaction:

  1. one species has to occur on both sides
  2. reaction type must not be specified
  3. integer stoichiometric coefficients for all participating species
  4. one side has to have exactly 3 participating species to qualify

If applicable, fill in the issue number this pull request is fixing

Fixes #967 (as long as #968 is merged also)

Checklist

  • There is a clear use-case for this code change
  • The commit message has a short title & references relevant issues
  • Build passes (scons build & scons test) and unit tests address code coverage
  • The pull request is ready for review

@ischoegl ischoegl changed the title Detect thirdbody collision partners Detect unspecified thirdbody collision partners Apr 19, 2021
@ischoegl ischoegl added the Input Input parsing and conversion (for example, ck2yaml) label Apr 19, 2021
@ischoegl ischoegl requested a review from a team April 19, 2021 22:42
@ischoegl
Copy link
Member Author

@speth, @decaluwe and @rwest ... after making this its own PR - and adding unit tests - I believe this is ready for review and/or comments. If the approach is acceptable and finds approval, it should probably be merged at the same time as #968 so #967 can be resolved.

Copy link
Member

@rwest rwest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK to me! Thanks Ingmar

Per discussion in Cantera#967, species-specific third-body reactions should use
molar concentrations for collision partner concentrations instead of
activity concentrations to be consistent with three-body reactions with
generic collision partners.
A reaction is identified as a three-body reaction if the following
criteria are satisfied:

* reaction type must not be specified
* exactly one species has to occur on both reactant and product side
* all stoichiometric coefficients have integer values
* one side has to have exactly 3 participating species
* test-clib: species-specific three-body reaction are reformatted
* test-cxx/test-f90: reformatted species-specific three-body reactions;
    change of spurious net reaction rates, which should be zero
* test-f77-ctlib: change of spurious net production rate for AR (gri30)
@ischoegl
Copy link
Member Author

@decaluwe ... I saw that you merged #968 (which is the companion PR). I resolved the merge conflict created by Blowers-Masel, so this is ready for review again.

Copy link
Member

@speth speth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good to me, @ischoegl. All of my comments are on fairly minor items. Beyond the in-line comments, there are just a couple of other things:

  • Can you add a test for a reaction created via XML, given that you implemented this logic for both YAML and CTI/XML derived reactions?
  • Have you thought about how these reactions should be serialized? Right now, they are converted to three-body reactions with the default-efficiency and efficiencies fields set as one might expect. I guess the question is whether or not that extra information should be deleted.

Lastly, I just wanted to note that I like that this ends up moving the third body to the end of the reactant / product strings for these reactions.

include/cantera/kinetics/Reaction.h Outdated Show resolved Hide resolved
interfaces/cython/cantera/test/test_kinetics.py Outdated Show resolved Hide resolved
interfaces/cython/cantera/test/test_reaction.py Outdated Show resolved Hide resolved
src/kinetics/ReactionFactory.cpp Outdated Show resolved Hide resolved
src/kinetics/Kinetics.cpp Outdated Show resolved Hide resolved
src/kinetics/ReactionFactory.cpp Outdated Show resolved Hide resolved
test_problems/fortran/f77_ctlib_blessed.txt Show resolved Hide resolved
src/kinetics/Reaction.cpp Outdated Show resolved Hide resolved
@ischoegl
Copy link
Member Author

ischoegl commented Apr 21, 2021

@speth ... thanks for your review. Hadn't thought about serialization as this is still a brand-new addition, but your point is well taken. I had to change duplicate checks but will look at this again.

I just wanted to note that I like that this ends up moving the third body to the end of the reactant / product strings for these reactions.

Likewise. Have to admit that this was an unintended 'feature', and would probably have fought to keep the new behavior (as it is both more instructive and easier to implement).

PS: Regarding XML tests, those are implicitly included by test_convert.py.

@ischoegl
Copy link
Member Author

ischoegl commented Apr 22, 2021

@speth (and @bryanwweber) ... I think this should take care of the review comments. I did not feel the need to implement XML unit tests, as those are (implicitly) covered by test_convert.py: it is already verified that equation types created from CTI and YAML correspond.

I did, however, implement a shortened serialization output, which I had not thought about.

@ischoegl ischoegl requested a review from speth April 22, 2021 21:05
src/kinetics/Reaction.cpp Outdated Show resolved Hide resolved
Three-body reactions with explictly declared collision partners do not
need to declare additional fields, i.e. 'type', 'default-efficiency', and
'efficiencies'.
@ischoegl ischoegl requested a review from speth April 23, 2021 22:49
@speth speth merged commit b753dd5 into Cantera:main Apr 27, 2021
@ischoegl
Copy link
Member Author

Thanks @speth!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Input Input parsing and conversion (for example, ck2yaml)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug with the computation of [M] with real gases
4 participants