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

Skipping undeclared species does not work with specific third body detection #1024

Closed
speth opened this issue Apr 27, 2021 · 3 comments · Fixed by #1027
Closed

Skipping undeclared species does not work with specific third body detection #1024

speth opened this issue Apr 27, 2021 · 3 comments · Fixed by #1027
Assignees

Comments

@speth
Copy link
Member

speth commented Apr 27, 2021

Problem description

A phase definition specifying a subset of species from another mechanism, using the qualifier declared-species to select reactions and with the skip-undeclared-third-bodies option enabled, fails when there are third body reactions for specific colliders if that collider is not in the phase. This seems to be a corner case for the new handling introduced in #1015.

Steps to reproduce

import cantera as ct

gas_def = """
    phases:
    - name: gas
      species:
      - h2o2.yaml/species: [H, O2, H2O, HO2]
      thermo: ideal-gas
      kinetics: gas
      reactions:
      - h2o2.yaml/reactions: declared-species
      skip-undeclared-third-bodies: true
    """

gas = ct.Solution(yaml=gas_def)
gas.X = [1] * gas.n_species
for i in range(gas.n_reactions):
    R = gas.reaction(i)
    if isinstance(R, ct.ThreeBodyReaction):
        print(f"i = {i}: {R!s:30} {R.rate}")
print(gas.forward_rate_constants)

Behavior

i = 0: H + O2 + M <=> HO2 + M         Arrhenius(A=2.8e+12, b=-0.86, E=0)
i = 1: H + O2 + O2 <=> HO2 + O2       Arrhenius(A=2.08e+13, b=-1.24, E=0)
i = 2: H + O2 + H2O <=> HO2 + H2O     Arrhenius(A=1.126e+13, b=-0.76, E=0)
i = 3: H + O2 + N2 <=> HO2 + N2       Arrhenius(A=inf, b=-1.24, E=0)
i = 4: H + O2 + AR <=> HO2 + AR       Arrhenius(A=inf, b=-0.8, E=0)
[20448590.35034667  8714720.31109497 72687079.49225374               nan
               nan]

For the last two reactions, which have N2 and AR as third bodies, the pre-exponential factor ends up as infinity, and the reaction rate ends up being NaN. I think we need to find a way to skip adding these reactions, but it's not clear where to do so. GasKinetics::addThreeBodyReaction has access to the necessary information, but doesn't have a mechanism to make the determination, but by the point that it's called, all of the setup at the level of the parent Kinetics and BulkKinetics classes has already been completed.

I haven't looked yet, but I wonder if the refactoring in #995 provides a more obvious location to handle this case.

System information

  • Cantera version: 2.6.0a2 / main at b753dd5.
@ischoegl
Copy link
Member

ischoegl commented Apr 27, 2021

Indeed an edge case! I believe an additional check in detectEfficiencies() to toggle Reaction::valid is all that is needed (within Reaction.cpp). (Edit: it’s a little more than that)

@ischoegl
Copy link
Member

ischoegl commented Apr 27, 2021

Regarding #995 … it will eventually become possible to outright remove reactions. But until that point, taking care of XML is the limiting issue. The edge case can be caught relatively easily for YAML in ReactionFactory (but not for XML).

@ischoegl
Copy link
Member

Should be fixed by #1027.

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.

2 participants