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

Remove reaction specializations #1333

Merged
merged 29 commits into from Jul 17, 2022

Conversation

ischoegl
Copy link
Member

@ischoegl ischoegl commented Jul 6, 2022

Changes proposed in this pull request

  • Deprecate ThreeBodyReaction in C++ and Python
  • Deprecate FalloffReaction in C++ and Python
  • Remove ReactionFactory and deprecate newReaction constructors
  • Update Python Reaction.__repr__ output
  • Implement ThirdBody object in Python and deprecate efficiencies argument in constructor

Incorporates #1332

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

Closes #1220; partially addresses Cantera/enhancements#142

If applicable, provide an example illustrating new features this pull request is introducing

In [1]: import cantera as ct

In [2]: ct.Reaction(equation="2 O + O2 <=> 2 O2", rate=ct.ArrheniusRate())
Out[2]: 2 O + O2 <=> O2 + O2    <three-body-Arrhenius>

In [3]: ct.Reaction(equation="2 O (+M) <=> O2 (+M)", rate=ct.TroeRate())
Out[3]: 2 O (+M) <=> O2 (+M)    <falloff-Troe>

In [4]: ct.Reaction("O:2", "O2:1", rate=ct.ArrheniusRate(), third_body=ct.ThirdBody())
Out[4]: 2 O + M <=> O2 + M    <three-body-Arrhenius>

In [5]: ct.Reaction("O:2", "O2:1", rate=ct.ArrheniusRate(), third_body=ct.ThirdBody("O2"))
Out[5]: 2 O + O2 <=> O2 + O2    <three-body-Arrhenius>

In [6]: ct.Reaction(equation="2 O + M <=> O2 + M", rate=ct.BlowersMaselRate())
Out[6]: 2 O + M <=> O2 + M    <three-body-Blowers-Masel>

Comments

  • three-body type entry is now optional in YAML input
  • Third body is supported for Blowers-Masel rates

Checklist

  • The pull request includes a clear description of this code change
  • Commit messages have short titles and reference relevant issues
  • Build passes (scons build & scons test) and unit tests address code coverage
  • Style & formatting of contributed code follows contributing guidelines
  • The pull request is ready for review

@ischoegl ischoegl force-pushed the remove-reaction-specializations branch from f9208d1 to 645a31a Compare July 6, 2022 19:19
@ischoegl ischoegl force-pushed the remove-reaction-specializations branch 4 times, most recently from 7b6258d to 82bb4fd Compare July 10, 2022 15:24
@ischoegl ischoegl marked this pull request as ready for review July 10, 2022 15:24
@ischoegl ischoegl force-pushed the remove-reaction-specializations branch 2 times, most recently from 8c2dab8 to 116dcdb Compare July 10, 2022 15:41
@ischoegl ischoegl requested a review from a team July 10, 2022 15:59
@ischoegl ischoegl force-pushed the remove-reaction-specializations branch 4 times, most recently from b9c7715 to b7cb764 Compare July 11, 2022 10:52
@ischoegl
Copy link
Member Author

Rebased and updated to incorporate changes to yaml2ck. This should be good for a review now (with the caveat that the first couple of commits are repeated from #1332)

@ischoegl ischoegl force-pushed the remove-reaction-specializations branch from b7cb764 to e42b6b2 Compare July 11, 2022 17:13
@ischoegl
Copy link
Member Author

@speth … thanks for the quick review on #1332! After the merge, I rebased this again so now it’s just what goes beyond CustomReaction

@ischoegl ischoegl force-pushed the remove-reaction-specializations branch from e42b6b2 to b3740a8 Compare July 11, 2022 17:54
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.

Thanks, @ischoegl, I think this is an exciting step forward in simplifying the handling of different reaction rate parameterizations.

One thing that you only barely touched on is that by handling third bodies in the common Reaction class, these can in principle be used for any rate parameterization. However, there are a couple of quirks here that I think are worth ironing out. One is that there are a few places that single out the TwoTempPlasmaRate class as not being able to handle third bodies, but I don't understand why that would be the case now. Shouldn't any reaction type be able to handle third bodies now, with the exception that we explicitly remove them from Plog and Chebyshev reactions in acknowledgment that the third-body pressure dependence is already embedded in those rate constants?

The second is that there are a few situations where the automatic detection of specific third body colliders prevents instantiation of reactions as non-third-body reactions, even though I don't think these should be seen as problematic. For instance, the following reaction definitions raise exceptions, but were (I think correctly) permitted in Cantera 2.6:

R1 = ct.Reaction(
    equation="HO2 + O2 <=> OH + O + O2",
    rate={"type": "pressure-dependent-Arrhenius",
          "rate-constants": [
               {"P": 1013.25, "A": 1.2124e+16, "b": -0.5779, "Ea": 45491376.8},
               {"P": 101325., "A": 4.9108e+31, "b": -4.8507, "Ea": 103649395.2}
          ],
    }
)

R2 = ct.Reaction(
    equation="H + OH + 2 O2 = H2O + 2 O2",
    rate={"A": 1.234e5, "b": 0, "Ea": 4321.0}
)

include/cantera/kinetics/Reaction.h Outdated Show resolved Hide resolved
interfaces/cython/cantera/reaction.pyx Outdated Show resolved Hide resolved
interfaces/cython/cantera/reaction.pyx Outdated Show resolved Hide resolved
interfaces/cython/cantera/reaction.pyx Show resolved Hide resolved
interfaces/cython/cantera/reaction.pyx Outdated Show resolved Hide resolved
src/kinetics/Reaction.cpp Show resolved Hide resolved
include/cantera/kinetics/Reaction.h Outdated Show resolved Hide resolved
include/cantera/kinetics/Reaction.h Show resolved Hide resolved
test/kinetics/kineticsFromScratch.cpp Outdated Show resolved Hide resolved
test/kinetics/kineticsFromScratch.cpp Show resolved Hide resolved
@ischoegl ischoegl force-pushed the remove-reaction-specializations branch 5 times, most recently from 36a27db to fbfbc13 Compare July 15, 2022 12:09
@ischoegl
Copy link
Member Author

@speth ... thanks for the feedback. I ended up being a lot more permissive/selective with the detection of third bodies, which I believe does make sense.

Regarding the two reactions you mentioned, they now produce the following:

In [2]: ct.Reaction(
   ...:     equation="HO2 + O2 <=> OH + O + O2",
   ...:     rate={
   ...:         "type": "pressure-dependent-Arrhenius",
   ...:         "rate-constants": [
   ...:             {"P": 1013.25, "A": 1.2124e16, "b": -0.5779, "Ea": 45491376.8},
   ...:             {"P": 101325.0, "A": 4.9108e31, "b": -4.8507, "Ea": 103649395.2},
   ...:         ],
   ...:     },
   ...: )
Out[2]: HO2 + O2 <=> O + OH + O2    <three-body-pressure-dependent-Arrhenius>

In [3]: ct.Reaction(
   ...:     equation="H + OH + 2 O2 = H2O + 2 O2", rate={"A": 1.234e5, "b": 0, "Ea": 4321.0}
   ...: )
Out[3]: H + 2 O2 + OH <=> H2O + 2 O2    <Arrhenius>

@ischoegl ischoegl force-pushed the remove-reaction-specializations branch from fbfbc13 to 1b5210f Compare July 15, 2022 12:12
@ischoegl ischoegl requested a review from speth July 15, 2022 12:13
@ischoegl ischoegl force-pushed the remove-reaction-specializations branch from c49e7fd to 55ee7e8 Compare July 15, 2022 19:07
@ischoegl
Copy link
Member Author

ischoegl commented Jul 15, 2022

@speth ... I agree that there should be some updates to the Science section, but I think the rest is done! Thank you for the suggestions ... this should complete the work left over on refactoring of Reaction and ReactionRate outside of the website.

@ischoegl ischoegl force-pushed the remove-reaction-specializations branch from 034f4ca to 2efa9b8 Compare July 15, 2022 19:38
@ischoegl ischoegl mentioned this pull request Jul 15, 2022
5 tasks
@ischoegl
Copy link
Member Author

@speth ... I opened Cantera/cantera-website#216 to track the remaining documentation work.

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.

Thanks, @ischoegl - I think this is good to go.

@speth speth merged commit d60e59e into Cantera:main Jul 17, 2022
@ischoegl ischoegl mentioned this pull request Jul 18, 2022
5 tasks
@ischoegl ischoegl deleted the remove-reaction-specializations branch July 31, 2022 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Two-temperature-plasma incompatible with third-body notation
2 participants