-
-
Notifications
You must be signed in to change notification settings - Fork 409
Description
Problem description
Creating a "reduced" mechanism containing a subset of reactions from a different mechanism where only one of a pair of "duplicate" reactions is included results in errors if that mechanism is subsequently written as a YAML file and read again. This occurs unless the user explicitly identifies such reactions and removes the duplicate flag.
Since we don't enforce any particular rules about duplicates when building a Kinetics object one reaction at a time, I think we should automatically assign the duplicate flags when serializing mechanisms so that they are self-consistent and produce a valid mechanism, without the user needing to write their own algorithm to identify and flag these reactions.
Steps to reproduce
- From the shell, run
python samples/python/kinetics/mechanism_reduction.py - From Python, run:
import cantera as ct
gas = ct.Solution('hexane-reduced-100-reaction.yaml')Behavior
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
gas = ct.Solution('hexane-reduced-100-reaction.yaml')
File "build/python/cantera/solutionbase.pyx", line 37, in cantera.solutionbase._SolutionBase.__cinit__
self._cinit(infile=infile, name=name, adjacent=adjacent, origin=origin,
File "build/python/cantera/solutionbase.pyx", line 75, in cantera.solutionbase._SolutionBase._cinit
self._init_yaml(infile, name, adjacent, yaml, transport)
File "build/python/cantera/solutionbase.pyx", line 160, in cantera.solutionbase._SolutionBase._init_yaml
soln = newSolution(
cantera._utils.CanteraError:
*******************************************************************************
InputFileError thrown by Kinetics::checkDuplicates:
Error on line 1070 of ./hexane-reduced-100-reaction.yaml:
No duplicate found for declared duplicate reaction number 97 (C3H6 <=> C3H5-A + H)
| Line |
| 1065 | rate-constant: {A: 1.21e+09, b: 1.05, Ea: 4.72792e+07}
| 1066 | - equation: CH2CO + H <=> CH3 + CO
| 1067 | rate-constant: {A: 7.704e+10, b: -0.171, Ea: 1.75025088e+07}
| 1068 | - equation: C6H13-1 + O2 <=> C6H13O2-1
| 1069 | rate-constant: {A: 6.863e+13, b: -1.627, Ea: 8.313608e+05}
> 1070 > - equation: C3H6 <=> C3H5-A + H
^
| 1071 | type: pressure-dependent-Arrhenius
| 1072 | rate-constants:
| 1073 | - {P: 1013.25, A: 9.16e+74, b: -17.6, Ea: 5.0208e+08}
*******************************************************************************
System information
- Cantera version:
mainbranch at b105c52
Additional context
Previously, #1629 noted that explicitly removing the duplicate flag didn't work correctly. This was resolved in #1740.