ReactionMechanismGenerator / RMG-Py

Python version of the amazing Reaction Mechanism Generator (RMG).
http://reactionmechanismgenerator.github.io/RMG-Py/
Other
397 stars 228 forks source link

RMG-Py main branch fails some regression tests #2228

Closed sevyharris closed 2 years ago

sevyharris commented 3 years ago

Bug Description

RMG fails while running the Nitrogen, Sulfur, and Oxidation regression tests in RMG-tests/test/rmg/ (It also fails the superminimal and liquid_oxidation tests, but for different reasons that probably need separate issues. It does pass the aromatics and eg1 tests)

How To Reproduce

  1. Checkout the main branches of RMG-Py and RMG-database
  2. Run the Nitrogen, Sulfur, or Oxidation input files
  3. The test run fails while trying to load the seed mechanism BurkeH2O2inArHe

Expected Behavior

I would expect this test to run without error because it is a part of the regression suite in RMG-tests.

Installation Information

Describe your installation method and system information.

Additional Context

I found this bug while running RMG-tests in Github Actions on a copy of the main RMG-Py branch. The details of the Github Actions run can be found here. I get the same result running on my local machine.

This is the error message:

Traceback (most recent call last):
  File "/home/moon/anaconda3/envs/rmg_env/lib/python3.7/site-packages/julia/pseudo_python_cli.py", line 308, in main
    python(**vars(ns))
  File "/home/moon/anaconda3/envs/rmg_env/lib/python3.7/site-packages/julia/pseudo_python_cli.py", line 59, in python
    scope = runpy.run_path(script, run_name="__main__")
  File "/home/moon/anaconda3/envs/rmg_env/lib/python3.7/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/home/moon/anaconda3/envs/rmg_env/lib/python3.7/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/home/moon/anaconda3/envs/rmg_env/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/moon/rmg/RMG-Py/rmg.py", line 118, in <module>
    main()
  File "/home/moon/rmg/RMG-Py/rmg.py", line 112, in main
    rmg.execute(**kwargs)
  File "/home/moon/rmg/RMG-Py/rmgpy/rmg/main.py", line 707, in execute
    self.initialize(**kwargs)
  File "/home/moon/rmg/RMG-Py/rmgpy/rmg/main.py", line 584, in initialize
    self.reaction_model.add_seed_mechanism_to_core(seed_mechanism, react=False)
  File "/home/moon/rmg/RMG-Py/rmgpy/rmg/model.py", line 1624, in add_seed_mechanism_to_core
    self.add_reaction_to_core(rxn)
  File "/home/moon/rmg/RMG-Py/rmgpy/rmg/model.py", line 1451, in add_reaction_to_core
    self.core.phase_system.phases["Default"].add_reaction(rxn)
  File "/home/moon/rmg/RMG-Py/rmgpy/rmg/reactors.py", line 217, in add_reaction
    self.reactions.append(to_rms(rxn, species_names=self.names, rms_species_list=self.species))
  File "/home/moon/rmg/RMG-Py/rmgpy/rmg/reactors.py", line 463, in to_rms
    reactantinds = [species_names.index(spc.label) for spc in obj.reactants]
  File "/home/moon/rmg/RMG-Py/rmgpy/rmg/reactors.py", line 463, in <listcomp>
    reactantinds = [species_names.index(spc.label) for spc in obj.reactants]
ValueError: 'O2' is not in list

This is the RMG Log:

Global RMG Settings:
   database.directory   = /home/moon/rmg/RMG-database/input (Default, relative to RMG-Py source code)
   test_data.directory  = /home/moon/rmg/RMG-Py/rmgpy/test_data (Default, relative to RMG-Py source code)
RMG execution initiated at Wed Oct 27 11:04:51 2021

#########################################################
# RMG-Py - Reaction Mechanism Generator in Python       #
# Version: 3.1.0                                        #
# Authors: RMG Developers (rmg_dev@mit.edu)             #
# P.I.s:   William H. Green (whgreen@mit.edu)           #
#          Richard H. West (r.west@neu.edu)             #
# Website: http://reactionmechanismgenerator.github.io/ #
#########################################################

The current git HEAD for RMG-Py is:
    b'3816e2a412267f44761c2b176a77ac016c8b45bb'
    b'Sun Oct 24 15:10:44 2021 -0400'

The current git HEAD for RMG-database is:
    b'45d2d60c506337813d2d6217b437732e571506c9'
    b'Fri Oct 22 19:23:15 2021 -0400'

Reading input file "/home/moon/rmg/my_examples/nitrogen/input.py"...
# Tests nitrogen chemistry and the following functionalities:
# Filter reactions, Adding multiple species, Thermo pruning, Species constraints,
# Libraries and Seed, Rate ratio termination

database(
    thermoLibraries=['BurkeH2O2','primaryThermoLibrary','thermo_DFT_CCSDTF12_BAC','DFT_QCI_thermo','FFCM1(-)','NitrogenCurran'],
    reactionLibraries=[('FFCM1(-)',False),'Nitrogen_Dean_and_Bozzelli'],
    seedMechanisms=['BurkeH2O2inArHe'],
    kineticsDepositories=['training'],
    kineticsFamilies='default',
    kineticsEstimator='rate rules',
)

species(
    label='NC',
    reactive=True,
    structure=SMILES("NC"),
)

species(
    label='O2',
    reactive=True,
    structure=SMILES("[O][O]"),
)

species(
    label='Ar',
    reactive=False,
    structure=adjacencyList('1 Ar u0 p4 c0'),
)

simpleReactor(
    temperature=(1399,'K'),
    pressure=(1.93,'atm'),
    initialMoleFractions={'NC': 0.0005,
                          'O2': 0.002,
                          'Ar': 0.9975},
    terminationRateRatio=0.01,
)

simulator(
    atol=1e-16,
    rtol=1e-8,
)

model(
    toleranceKeepInEdge=0,
    toleranceMoveToCore=0.1,
    toleranceInterruptSimulation=0.1,
    toleranceThermoKeepSpeciesInEdge=0.5,
    maximumEdgeSpecies=10000,
    maxNumObjsPerIter=3,
    terminateAtMaxObjects=True,
    filterReactions=True,
)

options(
    units='si',
    saveEdgeSpecies=True,
)

generatedSpeciesConstraints(
    allowed=['input species','seed mechanisms','reaction libraries'],
    maximumCarbonAtoms=2,
    maximumOxygenAtoms=2,
    maximumNitrogenAtoms=2,
    maximumSiliconAtoms=0,
    maximumSulfurAtoms=0,
    maximumHeavyAtoms=3,
    maximumRadicalElectrons=1,
    allowSingletO2=False,
)

Warning: Edge species saving was turned on. This will slow down model generation for large simulations.

Loading transport library from NOx2018.py in /home/moon/rmg/RMG-database/input/transport/libraries...
Loading transport library from PrimaryTransportLibrary.py in /home/moon/rmg/RMG-database/input/transport/libraries...
Loading transport library from OneDMinN2.py in /home/moon/rmg/RMG-database/input/transport/libraries...
Loading transport library from NIST_Fluorine.py in /home/moon/rmg/RMG-database/input/transport/libraries...
Loading transport library from GRI-Mech.py in /home/moon/rmg/RMG-database/input/transport/libraries...
Loading transport group database from /home/moon/rmg/RMG-database/input/transport/groups...
Loading kinetics library BurkeH2O2inArHe from /home/moon/rmg/RMG-database/input/kinetics/libraries/BurkeH2O2inArHe/reactions.py...
Loading kinetics library FFCM1(-) from /home/moon/rmg/RMG-database/input/kinetics/libraries/FFCM1(-)/reactions.py...
Loading kinetics library Nitrogen_Dean_and_Bozzelli from /home/moon/rmg/RMG-database/input/kinetics/libraries/Nitrogen_Dean_and_Bozzelli/reactions.py...
Loading frequencies group database from /home/moon/rmg/RMG-database/input/statmech/groups...
Loading solvation thermodynamics group database from /home/moon/rmg/RMG-database/input/solvation/groups...
Loading thermodynamics library from BurkeH2O2.py in /home/moon/rmg/RMG-database/input/thermo/libraries...
Loading thermodynamics library from primaryThermoLibrary.py in /home/moon/rmg/RMG-database/input/thermo/libraries...
Loading thermodynamics library from thermo_DFT_CCSDTF12_BAC.py in /home/moon/rmg/RMG-database/input/thermo/libraries...
Loading thermodynamics library from DFT_QCI_thermo.py in /home/moon/rmg/RMG-database/input/thermo/libraries...
Loading thermodynamics library from FFCM1(-).py in /home/moon/rmg/RMG-database/input/thermo/libraries...
Loading thermodynamics library from NitrogenCurran.py in /home/moon/rmg/RMG-database/input/thermo/libraries...
Loading thermodynamics group database from /home/moon/rmg/RMG-database/input/thermo/groups...
Adding rate rules from training set in kinetics families...
Filling in rate rules in kinetics families by averaging...
Adding seed mechanism BurkeH2O2inArHe to model core...
sevyharris commented 3 years ago

Thanks to PR 2208 the ValueError: 'O2' is not in list error is fixed and the Sulfur test passes! However the Nitrogen test (run on Github Actions) now fails for non-identical thermo and kinetics:

Running rmg/nitrogen test case
Benchmark code directory: /home/runner/work/RMG-tests/RMG-tests/code/benchmark/RMG-Py
Running benchmark job
Benchmark job completed
Testing code directory: /home/runner/work/RMG-tests/RMG-tests/code/testing/RMG-Py
Running testing job
Testing job completed
Comparing results
Benchmark model folder: /home/runner/work/RMG-tests/RMG-tests/results/benchmark/rmg/nitrogen
Testing model folder: /home/runner/work/RMG-tests/RMG-tests/results/testmodel/rmg/nitrogen
Core for rmg/nitrogen:
Test model has 41 species.
Original model has 41 species.
Test model has 360 reactions.
Original model has 360 reactions.
Edge for rmg/nitrogen:
Test model has 132 species.
Original model has 132 species.
Test model has 998 reactions.
Original model has 998 reactions.

Non-identical thermo!
original:   O1[C]=N1
tested: O1[C]=N1
Hf(300K)  |S(300K)   |Cp(300K)  |Cp(400K)  |Cp(500K)  |Cp(600K)  |Cp(800K)  |Cp(1000K) |Cp(1500K) 
    116.46|     53.90|     11.62|     12.71|     13.49|     13.96|     14.14|     13.85|     13.58
    141.64|     58.66|     12.26|     12.27|     12.09|     11.96|     12.26|     12.72|     12.15
thermo: Thermo group additivity estimation: group(O2s-CdN3d) + group(N3d-OCd) + group(Cd-HN3dO) + ring(Cyclopropene) + radical(CdJ-NdO)
thermo: Thermo group additivity estimation: group(O2s-CdN3d) + group(N3d-OCd) + group(Cd-HN3dO) + ring(oxirene) + radical(CdJ-NdO)

Non-identical kinetics!
original:
rxn: NCO(66) <=> O1[C]=N1(126)      origin: Intra_R_Add_Endocyclic
tested:
rxn: NCO(66) <=> O1[C]=N1(126)      origin: Intra_R_Add_Endocyclic
k(1bar)|300K   |400K   |500K   |600K   |800K   |1000K  |1500K  |2000K  

k(T):  | -50.17| -34.42| -24.95| -18.64| -10.73|  -5.97|   0.40|   3.60
k(T):  | -68.50| -48.17| -35.96| -27.81| -17.60| -11.47|  -3.27|   0.85

Kinetics: Arrhenius(A=(1.55936e+11,'s^-1'), n=0.551, Ea=(86.101,'kcal/mol'), T0=(1,'K'), comment="""Estimated using template [R3_linear;multiplebond_intra;radadd_intra] for rate rule [R3_linear;multiplebond_intra;radadd_intra_O]
Kinetics: Arrhenius(A=(1.55936e+11,'s^-1'), n=0.551, Ea=(111.271,'kcal/mol'), T0=(1,'K'), comment="""Estimated using template [R3_linear;multiplebond_intra;radadd_intra] for rate rule [R3_linear;multiplebond_intra;radadd_intra_O]
Identical kinetics comments
Execution time, Benchmark:
    Execution time (DD:HH:MM:SS): 00:00:01:53
Execution time, Tested:
    Execution time (DD:HH:MM:SS): 00:00:01:42
Memory used, Benchmark:
    Memory used: 1421.00 MB
Memory used, Tested:
    Memory used: 1431.86 MB
Traceback (most recent call last):
  File "/usr/share/miniconda/envs/testing/lib/python3.7/site-packages/julia/pseudo_python_cli.py", line 308, in main
    python(**vars(ns))
  File "/usr/share/miniconda/envs/testing/lib/python3.7/site-packages/julia/pseudo_python_cli.py", line 59, in python
    scope = runpy.run_path(script, run_name="__main__")
  File "/usr/share/miniconda/envs/testing/lib/python3.7/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/usr/share/miniconda/envs/testing/lib/python3.7/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/share/miniconda/envs/testing/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/runner/work/RMG-tests/RMG-tests/code/testing/RMG-Py/rmgpy/tools/regression.py", line 199, in <module>
    main()
  File "/home/runner/work/RMG-tests/RMG-tests/code/testing/RMG-Py/rmgpy/tools/regression.py", line 195, in main
    run(benchmark, tested, *args)
  File "/home/runner/work/RMG-tests/RMG-tests/code/testing/RMG-Py/rmgpy/tools/regression.py", line 157, in run
    observables={'species': observables}
  File "/home/runner/work/RMG-tests/RMG-tests/code/testing/RMG-Py/rmgpy/tools/observablesregression.py", line 138, in __init__
    quiet=True)
  File "/home/runner/work/RMG-tests/RMG-tests/code/testing/RMG-Py/rmgpy/tools/canteramodel.py", line 305, in load_chemkin_model
    self.model = ct.Solution(out_name)
  File "interfaces/cython/cantera/base.pyx", line 29, in cantera._cantera._SolutionBase.__cinit__
  File "interfaces/cython/cantera/base.pyx", line 50, in cantera._cantera._SolutionBase._init_cti_xml
cantera._cantera.CanteraError: 
***********************************************************************
CanteraError thrown by ct2ctml_string:
Error converting input file "/home/runner/work/RMG-tests/RMG-tests/results/benchmark/rmg/nitrogen/chemkin/chem_annotated.cti" to CTML.
Python command was: '/usr/share/miniconda/envs/testing/bin/python'
The exit code was: 7
-------------- start of converter log --------------
Python 3.7.11 (default, Jul 27 2021, 14:35:47) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
Traceback (most recent call last):
  File "<console>", line 8, in <module>
  File "/usr/share/miniconda/envs/testing/lib/python3.7/site-packages/cantera/ctml_writer.py", line 2694, in convert
    write(outName)
  File "/usr/share/miniconda/envs/testing/lib/python3.7/site-packages/cantera/ctml_writer.py", line 377, in write
    x.write(sys.stdout)
  File "/usr/share/miniconda/envs/testing/lib/python3.7/site-packages/cantera/ctml_writer.py", line 152, in write
    filename.write(''.join(s))
BlockingIOError: [Errno 11] write could not complete without blocking
--------------- end of converter log ---------------
***********************************************************************
sevyharris commented 3 years ago

Update from the last Github Actions run, on the main RMG-Py branch, commit 5a940c5d44cb90bf58477927b88f19fc1fe594c8:

aromatics status: 0
nitrogen status: 1
sulfur status: 0
oxidation status: 1
liquid oxidation status: 1
superminimal status: 0
eg1 status: 0

nitrogen, oxidation, and liquid oxidation tests fail with Cantera error: BlockingIOError: [Errno 11] write could not complete without blocking liquid oxidation also fails with nonidentical kinetics superminimal test passes with this PR: https://github.com/ReactionMechanismGenerator/RMG-tests/pull/80

sevyharris commented 2 years ago

Thanks @ChrisBNEU for fixing the Cantera issue! The regression tests appear to be working again.