ReactionMechanismGenerator / RMG-Py

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

ValueError: invalidObjects could not be filled during resurrection process #1367

Closed davidfarinajr closed 6 years ago

davidfarinajr commented 6 years ago

I've added some chlorine rules etc to my database (as discussed a bit in https://github.com/ReactionMechanismGenerator/RMG-database/pull/257 - will open a PR once we have it closer to working), and I am trying to build a model for chloromethane combustion. After one iteration it fails:

initializing surface ...
surface initialization complete
 DASPK--  AT T (=R1) AND STEPSIZE H (=R2) THE                                    
      In above,  R1 =  0.3886834855475D-38   R2 =  0.6996302739854D-38
 DASPK--  ERROR TEST FAILED REPEATEDLY OR WITH ABS(H)=HMIN                       
Error: Trying to step from time 0.0 to 1e-12 resulted in a solver (DASPK) error
Resurrecting Model...
Error: Model Resurrection has failed
Error: Core species names: ['Ar', 'He', 'Ne', 'N2', 'CH3Cl(1)', 'H2(2)', 'O2(3)', 'HCl(4)', 'Cl(6)', 'CH3(5)']
Error: Core species moles: array([  9.60000000e-01,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   2.00000000e-02,   1.00000000e-02,
         1.00000000e-02,   0.00000000e+00,   1.11803399e-16,
         1.11803399e-16])
Error: Volume: 0.09752875656000003
Error: Core species net rates: array([  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,  -2.94934944e+23,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   2.94934944e+23,
         2.94934944e+23])
Error: Edge species net rates: array([], dtype=float64)
Error: Network leak rates: array([], dtype=float64)
Traceback (most recent call last):
  File "/Users/DavidFarina/Code/RMG-Py//rmg.py", line 173, in <module>
    main()
  File "/Users/DavidFarina/Code/RMG-Py//rmg.py", line 167, in main
    rmg.execute(**kwargs)
  File "/Users/DavidFarina/Code/RMG-Py/rmgpy/rmg/main.py", line 695, in execute
    simulatorSettings = simulatorSettings,
  File "rmgpy/solver/base.pyx", line 520, in rmgpy.solver.base.ReactionSystem.simulate
  File "rmgpy/solver/base.pyx", line 700, in rmgpy.solver.base.ReactionSystem.simulate
ValueError: invalidObjects could not be filled during resurrection process

I think the step size of 0.7e-38 seconds and the rate of 2.9e+23 are the cause of the problem, caused by bad kinetics estimates from my database (maybe bad thermo causing a fast reverse reaction), but can anyone help me understand what the ValueError: invalidObjects could not be filled during resurrection process means?

mjohnson541 commented 6 years ago

So this has some unexpected behavior involved, but as you've already guessed it's likely a symptom of a much more concerning problem related to rates and thermo. Model Resurrection is a method we use to continue a run after the solver errors. Instead of simply ending the RMG run we grab the highest flux edge species (and sometimes some other objects) and add them to the model (core). In theory if the solver failure isn't a fundamental issue with the thermo/kinetics the model will recover after a resurrection or two. If not it will keep resurrecting itself in an attempt to recover. The unexpected behavior here is that it's unable to find any edge species to grab since your edge species net rates are empty.

This is likely the same issue as #1258, which we were unable to solve because we didn't have a test case we could easily reproduce the error from. If I can access the database branch you're using and if you can send me your input file I should be able to debug it.

davidfarinajr commented 6 years ago

database: https://github.com/davidfarinajr/RMG-database/tree/Chlorine

input:

database(
    thermoLibraries = ['Chlorinated_Hydrocarbons', 'primaryThermoLibrary'],
    reactionLibraries = [],
    seedMechanisms = [],
    kineticsDepositories = ['training'],
    kineticsFamilies = 'default',
    kineticsEstimator = 'rate rules',
)

species(
    label = "CH3Cl",
    reactive = True,
    structure = adjacencyList(
"""
1 Cl u0 p3 c0 {2,S}
2 C  u0 p0 c0 {1,S} {3,S} {4,S} {5,S}
3 H  u0 p0 c0 {2,S}
4 H  u0 p0 c0 {2,S}
5 H  u0 p0 c0 {2,S}
"""),
)

species(
    label = "H2",
    reactive = True,
    structure = adjacencyList(
"""
1 H u0 p0 c0 {2,S}
2 H u0 p0 c0 {1,S}
"""),
)

species(
    label = "O2",
    reactive = True,
    structure = adjacencyList(
"""
multiplicity 3
1 O u1 p2 c0 {2,S}
2 O u1 p2 c0 {1,S}
"""),
)

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

species(
    label = "HCl",
    reactive = True,
    structure = adjacencyList(
"""
1 Cl u0 p3 c0 {2,S}
2 H  u0 p0 c0 {1,S}
"""),
)

simpleReactor(
    temperature = (1173,"K"),
    pressure = (1,"bar"),
    initialMoleFractions={
        "H2": 0.01,
        "O2": 0.01,
        "HCl": 0,
        "CH3Cl": 0.02,
        "Ar": 0.96,
    },
    terminationTime = (2,"s"),
    sensitivity = ['CH3Cl', 'HCl'],
    sensitivityThreshold = 0.001,
)

simulator(
    atol = 1e-16,
    rtol = 1e-08,
    sens_atol = 1e-06,
    sens_rtol = 0.0001,
)

model(
    toleranceMoveToCore = 1e-06,
    toleranceKeepInEdge = 0,
    toleranceInterruptSimulation = 1,
    maximumEdgeSpecies = 100000,
    minCoreSizeForPrune = 50,
    minSpeciesExistIterationsForPrune = 2,
    filterReactions = True,
)

options(
    units = "si",
    saveRestartPeriod = None,
    generateOutputHTML = True,
    generatePlots = False,
    saveSimulationProfiles = True,
    saveEdgeSpecies = True,
    keepIrreversible = None,
    verboseComments = True,
)

Thanks Matt

mjohnson541 commented 6 years ago

The problem seems to be that the filter simulation is failing. In #1371 I've added a try except that allows model runs to continue after filter simulations error, which fixes the issue in the sense that the run behaves as intended. However, this doesn't help your run specifically because it never recovers and the resurrection process just grabs species out of the edge until there aren't any left at which point it errors as expected.

mjohnson541 commented 6 years ago

Closing with merge of #1371

sthakris commented 1 year ago

Is this has been solved. I have got exact same error for nitogen containing species.

mjohnson541 commented 1 year ago

The issue is solved in the sense that the error occurs when expected. We expect this error to occur if RMG repeatedly fails to solve a reactor. This error almost always indicates a problem with the thermochemistry estimates, although it can also be an issue with the kinetic estimates.