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.
Problem description
A phase definition specifying a subset of species from another mechanism, using the qualifier
declared-speciesto select reactions and with theskip-undeclared-third-bodiesoption 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
Behavior
For the last two reactions, which have
N2andARas 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::addThreeBodyReactionhas 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 parentKineticsandBulkKineticsclasses 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
mainat b753dd5.