ReactionMechanismGenerator / RMG-Py

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

ValueError: 'site' is not in list when using Deutschmann_Ni as seed mechanism #2649

Closed ccaitlien closed 7 months ago

ccaitlien commented 7 months ago

Bug Description

In my RMG input file, I'm trying to use the Surface/Methane/Deutschmann_Ni reaction library as a seed mechanism for a simulation involving a SurfaceReactor but I'm getting a ValueError saying that 'site' is not in list. This is what the full traceback looks like:

  File "/home/RMG-Py/rmg.py", line 118, in <module>
    main()
  File "/home/RMG-Py/rmg.py", line 112, in main
    rmg.execute(**kwargs)
  File "/home/RMG-Py/rmgpy/rmg/main.py", line 760, in execute
    self.initialize(**kwargs)
  File "/home/RMG-Py/rmgpy/rmg/main.py", line 624, in initialize
    self.reaction_model.add_seed_mechanism_to_core(seed_mechanism, react=False)
  File "/home/RMG-Py/rmgpy/rmg/model.py", line 1692, in add_seed_mechanism_to_core
    self.add_reaction_to_core(rxn)
  File "/home/RMG-Py/rmgpy/rmg/model.py", line 1502, in add_reaction_to_core
    self.core.phase_system.interfaces[frozenset({"Default", "Surface"})].add_reaction(rxn, species_names, rms_species_list)
  File "/home/RMG-Py/rmgpy/rmg/reactors.py", line 340, in add_reaction
    self.reactions.append(to_rms(rxn, species_names=species_names, rms_species_list=rms_species_list))
  File "/home/RMG-Py/rmgpy/rmg/reactors.py", line 754, in to_rms
    reactantinds = [species_names.index(spc.label) for spc in obj.reactants]
  File "/home/RMG-Py/rmgpy/rmg/reactors.py", line 754, in <listcomp>
    reactantinds = [species_names.index(spc.label) for spc in obj.reactants]
ValueError: 'site' is not in list

How To Reproduce

I'm using the methane steam reforming example in the RMG docs here, except I'm using Surface/Methane/Deutschmann_Ni as a seed mechanism instead of a reaction library:

database(
    thermoLibraries=['surfaceThermoNi111', 'surfaceThermoPt111', 'primaryThermoLibrary', 'thermo_DFT_CCSDTF12_BAC'], 
    seedMechanisms = ['Surface/Methane/Deutschmann_Ni'],
    kineticsDepositories = ['training'],
    kineticsFamilies = ['surface','default'],
    kineticsEstimator = 'rate rules',
)

Expected Behavior

I expect add_seed_mechanism_to_core to add all of the species in my seed mechanism into the core, however it doesn't seem to be working correctly because the model can't find 'site' in the species list. I also have 'site' as an input species since it's required for a SurfaceReactor, but it looks like having it as an input species doesn't add it into the core either.

species(
    label='site',
    reactive=True,
    structure=adjacencyList("1 X u0"),
)
#----------
# Reaction systems
surfaceReactor(
    temperature=(1000,'K'),
    initialPressure=(1.0, 'bar'),
    initialGasMoleFractions={
        "CH4": 1.0,
        "O2": 0.0,
        "CO2": 1.2,
        "H2O": 1.2,
        "H2": 0.0,
        "CH3OH": 0.0,
        "C2H4": 0.0,
    },
    initialSurfaceCoverages={
        "site": 1.0,
    },
    surfaceVolumeRatio=(1.e5, 'm^-1'),
    terminationConversion = { "CH4":0.9,},
    terminationTime=(0.01, 's'),
)

Installation Information

JacksonBurns commented 7 months ago

@mjohnson541 could you take a look at this?

mjohnson541 commented 7 months ago

Broadly, we add the initial species to the edge early during initialization because we currently don't add them to core until we call enlarge (which generates reactions so we don't want to call it until all seed mechanisms and reaction libraries have been added). Later the function for adding seed mechanisms searches for the "site" species and finds it (it is in the edge), since it finds it, as best I can tell it assumes because that species was found it doesn't need to do anything about it, which becomes a problem when it tries to add the associated reaction directly to core since "site" isn't in the core.

2653 attempts to handle this by having add_seed_mechanism_to_core add those species to core and telling enlarge it's okay if the species is already in core.

JacksonBurns commented 7 months ago

@ccaitlien the fix has now been merged into the main branch. You can use the latest Docker image to try it out or install RMG from source using main, or wait for this to make it into an official release (could be a while).

ccaitlien commented 7 months ago

@JacksonBurns @mjohnson541 thanks for fixing the issue! Appreciate all the work y'all have done maintaining this package :)