RMG-Py icon indicating copy to clipboard operation
RMG-Py copied to clipboard

MultiArrhenius issue when loading reaction families

Open mazeau opened this issue 4 years ago • 4 comments

Bug Description

Hi, I am getting this error, both locally and on discovery, when trying to use the BurkeH2O2 reaction library. The below pops up when trying to add the entire library into the model edge, and I believe it may be due to multiarrhenius.

Traceback (most recent call last):
  File "/home/mazeau.e/.conda/envs/rmg/lib/python3.7/site-packages/julia/pseudo_python_cli.py", line 308, in main
    python(**vars(ns))
  File "/home/mazeau.e/.conda/envs/rmg/lib/python3.7/site-packages/julia/pseudo_python_cli.py", line 59, in python
    scope = runpy.run_path(script, run_name="__main__")
  File "/home/mazeau.e/.conda/envs/rmg/lib/python3.7/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/home/mazeau.e/.conda/envs/rmg/lib/python3.7/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/home/mazeau.e/.conda/envs/rmg/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/mazeau.e/Code/RMG-Py/rmg.py", line 118, in <module>
    main()
  File "/home/mazeau.e/Code/RMG-Py/rmg.py", line 112, in main
    rmg.execute(**kwargs)
  File "/scratch/westgroup/mazeau/RMG-Py/rmgpy/rmg/main.py", line 695, in execute
    self.initialize(**kwargs)
  File "/scratch/westgroup/mazeau/RMG-Py/rmgpy/rmg/main.py", line 577, in initialize
    self.reaction_model.add_reaction_library_to_edge(library)
  File "/scratch/westgroup/mazeau/RMG-Py/rmgpy/rmg/model.py", line 1725, in add_reaction_library_to_edge
    self.add_reaction_to_edge(rxn)
  File "/scratch/westgroup/mazeau/RMG-Py/rmgpy/rmg/model.py", line 1478, in add_reaction_to_edge
    self.edge.phase_system.phases["Default"].add_reaction(rxn)
  File "/scratch/westgroup/mazeau/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 "/scratch/westgroup/mazeau/RMG-Py/rmgpy/rmg/reactors.py", line 467, in to_rms
    kinetics = to_rms(obj.kinetics)
  File "/scratch/westgroup/mazeau/RMG-Py/rmgpy/rmg/reactors.py", line 403, in to_rms
    return rms.MultiArrhenius(arrs)
RuntimeError: <PyCall.jlwrap (in a Julia function called from Python)
JULIA: MethodError: no method matching ReactionMechanismSimulator.MultiArrhenius(::Vector{ReactionMechanismSimulator.Arrhenius{Float64, Float64, Float64, ReactionMechanismSimulator.EmptyRateUncertainty}})
Closest candidates are:
  ReactionMechanismSimulator.MultiArrhenius(::Any, !Matched::Q) where Q<:ReactionMechanismSimulator.AbstractRateUncertainty at /home/mazeau.e/.conda/envs/rmg/share/julia/site/packages/Parameters/MK0O4/src/Parameters.jl:526
  ReactionMechanismSimulator.MultiArrhenius(; arrs, unc) at /home/mazeau.e/.conda/envs/rmg/share/julia/site/packages/Parameters/MK0O4/src/Parameters.jl:545
  ReactionMechanismSimulator.MultiArrhenius(!Matched::ReactionMechanismSimulator.MultiArrhenius; kws...) at /home/mazeau.e/.conda/envs/rmg/share/julia/site/packages/Parameters/MK0O4/src/Parameters.jl:569
  ...
Stacktrace:
  [1] invokelatest(::Any, ::Any, ::Vararg{Any, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base ./essentials.jl:708
  [2] invokelatest(::Any, ::Any, ::Vararg{Any, N} where N)
    @ Base ./essentials.jl:706
  [3] _pyjlwrap_call(f::Type, args_::Ptr{PyCall.PyObject_struct}, kw_::Ptr{PyCall.PyObject_struct})
    @ PyCall ~/.conda/envs/rmg/share/julia/site/packages/PyCall/BD546/src/callback.jl:28
  [4] pyjlwrap_call(self_::Ptr{PyCall.PyObject_struct}, args_::Ptr{PyCall.PyObject_struct}, kw_::Ptr{PyCall.PyObject_struct})
    @ PyCall ~/.conda/envs/rmg/share/julia/site/packages/PyCall/BD546/src/callback.jl:44
  [5] macro expansion
    @ ~/.conda/envs/rmg/share/julia/site/packages/PyCall/BD546/src/exception.jl:95 [inlined]
  [6] #107
    @ ~/.conda/envs/rmg/share/julia/site/packages/PyCall/BD546/src/pyfncall.jl:43 [inlined]
  [7] disable_sigint
    @ ./c.jl:458 [inlined]
  [8] __pycall!
    @ ~/.conda/envs/rmg/share/julia/site/packages/PyCall/BD546/src/pyfncall.jl:42 [inlined]
  [9] _pycall!(ret::PyObject, o::PyObject, args::Tuple{Vector{String}}, nargs::Int64, kw::Ptr{Nothing})
    @ PyCall ~/.conda/envs/rmg/share/julia/site/packages/PyCall/BD546/src/pyfncall.jl:29
 [10] _pycall!
    @ ~/.conda/envs/rmg/share/julia/site/packages/PyCall/BD546/src/pyfncall.jl:11 [inlined]
 [11] #_#114
    @ ~/.conda/envs/rmg/share/julia/site/packages/PyCall/BD546/src/pyfncall.jl:86 [inlined]
 [12] (::PyObject)(args::Vector{String})
    @ PyCall ~/.conda/envs/rmg/share/julia/site/packages/PyCall/BD546/src/pyfncall.jl:86
 [13] top-level scope
    @ none:4
 [14] eval
    @ ./boot.jl:360 [inlined]
 [15] exec_options(opts::Base.JLOptions)
    @ Base ./client.jl:261
 [16] _start()
    @ Base ./client.jl:485>

How To Reproduce

Running this this input file will go it, but I have a suspicion that any reaction library with multiarrhenius may cause this as well

# Data sources
database(
    thermoLibraries=['surfaceThermoPt111', 'primaryThermoLibrary', 'thermo_DFT_CCSDTF12_BAC','DFT_QCI_thermo'],
    reactionLibraries = [
    ('Surface/CPOX_Pt/Deutschmann2006_adjusted', False),
    # ('Surface/Methane/Deutschmann_Pt', False),
    'BurkeH2O2inArHe'],
    seedMechanisms = [],
    kineticsDepositories = ['training'],
    kineticsFamilies =['surface','default'],
    kineticsEstimator = 'rate rules',
)

# catalystProperties( # default values for Rh(111)
#     bindingEnergies = {
#                        'C':(-6.568, 'eV/molecule'),
#                        'O':(-4.610, 'eV/molecule'),
#                        'N':(-4.352, 'eV/molecule'),
#                        'H':(-2.479, 'eV/molecule'),
#                        },
#     surfaceSiteDensity=(2.72e-9, 'mol/cm^2'),
#     coverageDependence=True,
# )

# catalystProperties( # default values for Pt(111)
#     bindingEnergies = {
#                        'C':(-6.750, 'eV/molecule'),
#                        'O':(-3.586, 'eV/molecule'),
#                        'N':(-4.352, 'eV/molecule'),
#                        'H':(-2.479, 'eV/molecule'),
#                        },
#     surfaceSiteDensity=(2.72e-9, 'mol/cm^2'),
# )

catalystProperties(
    metal = 'Pt111',
    coverageDependence=True,
)

# List of species
species(
    label='X',
    reactive=True,
    structure=adjacencyList("1 X u0"),
)

species(
    label='CH4',
    reactive=True,
    structure=SMILES("[CH4]"),
)
species(
    label='O2',
    reactive=True,
    structure=adjacencyList(
    """
    1 O u1 p2 c0 {2,S}
    2 O u1 p2 c0 {1,S}
    """),
)

species(
    label='Ar',
    reactive=False,
    structure=SMILES("[Ar]"),
)

species(
    label='CO2',
    reactive=True,
    structure=SMILES("O=C=O"),
)

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

species(
    label='H2',
    reactive=True,
    structure=SMILES("[H][H]"),
)

species(
    label='CO',
    reactive=True,
    structure=SMILES("[C-]#[O+]"),
)

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

species(
    label='CH2O',
    reactive=True,
    structure=SMILES("C=O"),
)

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

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

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

species(
    label='C2H5',
    reactive=True,
    structure=SMILES("C[CH2]"),
)

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

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

species(
    label='CH3CHO',
    reactive=True,
    structure=SMILES("CC=O"),
)

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

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

species(
    label='CH3CH',
    reactive=True,
    structure=SMILES("[CH]C"),
)

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

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

species(
    label='CO2X',
    reactive=True,
    structure=adjacencyList(
    """
    1 O u0 p2 c0 {3,D}
    2 O u0 p2 c0 {3,D}
    3 C u0 p0 c0 {1,D} {2,D}
    4 X u0 p0 c0
    """),
)

species(
    label='COX',
    reactive=True,
    structure=adjacencyList(
    """
    1 O u0 p2 c0 {2,D}
    2 C u0 p0 c0 {1,D} {3,D}
    3 X u0 p0 c0 {2,D}
    """),
)

species(
    label='CH4X',
    reactive=True,
    structure=adjacencyList(
    """
    1 C u0 p0 c0 {2,S} {3,S} {4,S} {5,S}
    2 H u0 p0 c0 {1,S}
    3 H u0 p0 c0 {1,S}
    4 H u0 p0 c0 {1,S}
    5 H u0 p0 c0 {1,S}
    6 X u0 p0 c0
    """),
)

species(
    label='OX',
    reactive=True,
    structure=adjacencyList(
    """
    1 O u0 p2 c0 {2,D}
    2 X u0 p0 c0 {1,D}
    """),
)

species(
    label='CH2X',
    reactive=True,
    structure=adjacencyList(
    """
    1 C u0 p0 c0 {2,S} {3,S} {4,D}
    2 H u0 p0 c0 {1,S}
    3 H u0 p0 c0 {1,S}
    4 X u0 p0 c0 {1,D}
    """),
)

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

species(
    label='CHX',
    reactive=True,
    structure=adjacencyList(
    """
    1 C u0 p0 c0 {2,S} {3,T}
    2 H u0 p0 c0 {1,S}
    3 X u0 p0 c0 {1,T}
    """),
)

species(
    label='CX',
    reactive=True,
    structure=adjacencyList(
    """
    1 C u0 p0 c0 {2,Q}
    2 X u0 p0 c0 {1,Q}
    """),
)

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

species(
    label='OHX',
    reactive=True,
    structure=adjacencyList(
    """
    1 O u0 p2 c0 {2,S} {3,S}
    2 H u0 p0 c0 {1,S}
    3 X u0 p0 c0 {1,S}
    """),
)

species(
    label='H2OX',
    reactive=True,
    structure=adjacencyList(
    """
    1 O u0 p2 c0 {2,S} {3,S}
    2 H u0 p0 c0 {1,S}
    3 H u0 p0 c0 {1,S}
    4 X u0 p0 c0
    """),
)

species(
    label='CHOX',
    reactive=True,
    structure=adjacencyList(
    """
    1 O u0 p2 c0 {2,D}
    2 C u0 p0 c0 {1,D} {3,S} {4,S}
    3 H u0 p0 c0 {2,S}
    4 X u0 p0 c0 {2,S}
    """),
)

#----------
# Reaction systems
surfaceReactor(
    temperature=(600,'K'),
    initialPressure=(1.0, 'bar'),
    initialGasMoleFractions={
        "CH4": 0.041866,
        "O2": 0.03488,
        "Ar": 0.131246,
    },
    initialSurfaceCoverages={
        "X": 1.0,
    },
    surfaceVolumeRatio=(1.e5, 'm^-1'),
    terminationConversion = { "CH4":0.95,},
    terminationTime=(10., 's'),
    # terminationConversion={'O2': 0.99,},
    terminationRateRatio=0.05
)

surfaceReactor(
    temperature=(600,'K'),
    initialPressure=(1.0, 'bar'),
    initialGasMoleFractions={
        "CH4": 0.108574,
        "O2": 0.02088,
        "Ar": 0.78547,
    },
    initialSurfaceCoverages={
        "X": 1.0,
    },
    surfaceVolumeRatio=(1.e5, 'm^-1'),
    terminationConversion = { "CH4":0.95,},
    terminationTime=(10., 's'),
    # terminationConversion={'O2': 0.99,},
    terminationRateRatio=0.05
)

surfaceReactor(
    temperature=(2000,'K'),
    initialPressure=(1.0, 'bar'),
    initialGasMoleFractions={
        "CH4": 0.041866,
        "O2": 0.03488,
        "Ar": 0.131246,
    },
    initialSurfaceCoverages={
        "X": 1.0,
    },
    surfaceVolumeRatio=(1.e5, 'm^-1'),
    terminationConversion = { "CH4":0.95,},
    terminationTime=(10., 's'),
    # terminationConversion={'O2': 0.99,},
    terminationRateRatio=0.05
)

surfaceReactor(
    temperature=(2000,'K'),
    initialPressure=(1.0, 'bar'),
    initialGasMoleFractions={
        "CH4": 0.108574,
        "O2": 0.02088,
        "Ar": 0.78547,
    },
    initialSurfaceCoverages={
        "X": 1.0,
    },
    surfaceVolumeRatio=(1.e5, 'm^-1'),
    terminationConversion = { "CH4":0.95,},
    terminationTime=(10., 's'),
    # terminationConversion={'O2': 0.99,},
    terminationRateRatio=0.05
)

simulator(
    atol=1e-18,
    rtol=1e-12,
)

model(
    toleranceKeepInEdge=0.0,
    toleranceMoveToCore=1e-1,
# inturrupt tolerance was 0.1 wout pruning, 1e8 w pruning on
    toleranceInterruptSimulation=1e8,
    maximumEdgeSpecies=500000,
# PRUNING: uncomment to prune
#    minCoreSizeForPrune=50,
# prune before simulation based on thermo
#    toleranceThermoKeepSpeciesInEdge=0.5,
# prune rxns from edge that dont move into core
#    minSpeciesExistIterationsForPrune=2,
# FILTERING: set so threshold is slightly larger than max rate constants
#    filterReactions=True,
#    filterThreshold=5e8, # default value
)

options(
    units='si',
    saveRestartPeriod=None,
    generateOutputHTML=True,
    generatePlots=False,
    saveEdgeSpecies=True,
    saveSimulationProfiles=True,
)

generatedSpeciesConstraints(
    allowed=['input species','reaction libraries'],
    maximumSurfaceSites=1,
)

Expected Behavior

I should be able to get a nice model for the catalytic partial oxidation of methane on pt with coverage dependence

Installation Information

Describe your installation method and system information.

  • RMG-Py: latest main 47c4e0b16ee274919ec24aa4160ac5e83cc9f0a9
  • RMG-database: latest main 2118733e3d2b8fcbfc8d23c15f665799b3920e6a

Additional Context

@davidfarinajr

mazeau avatar Oct 01 '21 20:10 mazeau

I think it’s missing another input in RMS it needs rms.EmptyRateUncertainty() as a last argument when RMG constructs the rms object inside to_rms in reactor.py. It's possible this needs done for some of the other non-Arrhenius rates as well.

mjohnson541 avatar Oct 01 '21 23:10 mjohnson541

Hi, so I did as you suggested and am now getting this error on both main branches of py and db:

Adding reaction library BurkeH2O2inArHe to model edge...
Traceback (most recent call last):
  File "/Users/emilymazeau/anaconda3/envs/rmg/lib/python3.7/site-packages/julia/pseudo_python_cli.py", line 308, in main
    python(**vars(ns))
  File "/Users/emilymazeau/anaconda3/envs/rmg/lib/python3.7/site-packages/julia/pseudo_python_cli.py", line 59, in python
    scope = runpy.run_path(script, run_name="__main__")
  File "/Users/emilymazeau/anaconda3/envs/rmg/lib/python3.7/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/Users/emilymazeau/anaconda3/envs/rmg/lib/python3.7/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/Users/emilymazeau/anaconda3/envs/rmg/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/emilymazeau/Code/RMG-Py/rmg.py", line 118, in <module>
    main()
  File "/Users/emilymazeau/Code/RMG-Py/rmg.py", line 112, in main
    rmg.execute(**kwargs)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/rmg/main.py", line 695, in execute
    self.initialize(**kwargs)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/rmg/main.py", line 577, in initialize
    self.reaction_model.add_reaction_library_to_edge(library)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/rmg/model.py", line 1725, in add_reaction_library_to_edge
    self.add_reaction_to_edge(rxn)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/rmg/model.py", line 1478, in add_reaction_to_edge
    self.edge.phase_system.phases["Default"].add_reaction(rxn)
  File "/Users/emilymazeau/Code/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 "/Users/emilymazeau/Code/RMG-Py/rmgpy/rmg/reactors.py", line 467, in to_rms
    kinetics = to_rms(obj.kinetics)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/rmg/reactors.py", line 416, in to_rms
    efficiencies = {spc.label: float(val) for spc, val in obj.efficiencies.items() if val != 1}
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/rmg/reactors.py", line 416, in <dictcomp>
    efficiencies = {spc.label: float(val) for spc, val in obj.efficiencies.items() if val != 1}
AttributeError: 'rmgpy.molecule.molecule.Molecule' object has no attribute 'label'

mazeau avatar Oct 04 '21 18:10 mazeau

upon further inspection, @davidfarinajr and I think it looks like there is some mismatch with rate efficiencies

ReactionMechanismSimulator.ThirdBody(::Any, !Matched::Dict{N, K}, !Matched::Dict{String, K}, !Matched::Q) where {N<:Integer, K<:AbstractFloat, Q<:ReactionMechanismSimulator.AbstractRateUncertainty} at /Users/emilymazeau/.julia/packages/Parameters/MK0O4/src/Parameters.jl:526 got unsupported keyword argument "nameefficiencies"

@with_kw struct ThirdBody{N<:Integer,K<:AbstractFloat,Q<:AbstractRateUncertainty} <: AbstractFalloffRate
    arr::Arrhenius
    efficiencies::Dict{N,K} = Dict()
    nameefficiencies::Dict{String,K} = Dict{String,Float64}()
    unc::Q = EmptyRateUncertainty()
end

mazeau avatar Oct 04 '21 19:10 mazeau

So if you go to yml.py it builds object dictionaries that RMS reads into species when parsing. I think if you index into the species_names they way they index I think you should be alright:

efficiencies = {species_names[i] : float(val)
                             for i, val in enumerate(obj.get_effective_collider_efficiencies(species_names)) if val != 1}

mjohnson541 avatar Oct 04 '21 20:10 mjohnson541

This issue is being automatically marked as stale because it has not received any interaction in the last 90 days. Please leave a comment if this is still a relevant issue, otherwise it will automatically be closed in 30 days.

github-actions[bot] avatar Jun 21 '23 22:06 github-actions[bot]