Skip to content

Prevent Surface_Dissociation_vdW family from breaking double bond - #748

Open
djlucey wants to merge 1 commit into
ReactionMechanismGenerator:mainfrom
djlucey:vdw_no_double_bond
Open

djlucey wants to merge 1 commit into
ReactionMechanismGenerator:mainfrom
djlucey:vdw_no_double_bond

Conversation

@djlucey

@djlucey djlucey commented Oct 6, 2026

Copy link
Copy Markdown

Motivation or Problem

When running RMG to create a surface mechanism for H2 reacting with CO, CO2, CH4, NH3, O2 (on Ni111), I encountered the following error:

For reaction generation 1 process is used.
Error: Could not update atomtypes for this molecule:
multiplicity -187
1 *4 X u0 p0 c0 {2,S}
2 *2 C u0 p1 c+1 {1,S}

Error: Problem family: Surface_Dissociation_vdW
Error: Problem reactants: (Molecule(smiles="[Pt]"), Molecule(smiles="[C]=C.[Pt]"))
Error: <Molecule "[Pt]">
1 *4 X u0 p0 c0

Error: <Molecule "[C]=C.[Pt]">
1 *1 C u0 p0 c0 {2,D} {3,S} {4,S}
2 *2 C u0 p1 c0 {1,D}
3    H u0 p0 c0 {1,S}
4    H u0 p0 c0 {1,S}
5 *3 X u0 p0 c0

The traceback looks like:

Traceback (most recent call last):
  File "/home/lucey.da/RMG-Py/rmg.py", line 33, in <module>
    __main__.main()
  File "/home/lucey.da/RMG-Py/rmgpy/__main__.py", line 104, in main
    rmg.execute(**kwargs)
  File "/home/lucey.da/RMG-Py/rmgpy/rmg/main.py", line 1213, in execute
    self.reaction_model.enlarge(
  File "/home/lucey.da/RMG-Py/rmgpy/rmg/model.py", line 789, in enlarge
    rxn_lists, spcs_tuples = react_all(
                             ^^^^^^^^^^
  File "/home/lucey.da/RMG-Py/rmgpy/rmg/react.py", line 172, in react_all
    return react(spc_fam_tuples, procnum), [fam_tuple[0] for fam_tuple in spc_fam_tuples]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lucey.da/RMG-Py/rmgpy/rmg/react.py", line 66, in react
    reactions = list(map(_react_species_star, spc_fam_tuples))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lucey.da/RMG-Py/rmgpy/rmg/react.py", line 79, in _react_species_star
    return react_species(*args)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/lucey.da/RMG-Py/rmgpy/rmg/react.py", line 94, in react_species
    reactions = get_db('kinetics').generate_reactions_from_families(species_tuple, only_families=only_families)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lucey.da/RMG-Py/rmgpy/data/kinetics/database.py", line 530, in generate_reactions_from_families
    reaction_list.extend(self.react_molecules(combo, products=products, only_families=only_families,
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lucey.da/RMG-Py/rmgpy/data/kinetics/database.py", line 558, in react_molecules
    reaction_list.extend(family.generate_reactions(molecules, products=products,
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lucey.da/RMG-Py/rmgpy/data/kinetics/family.py", line 1794, in generate_reactions
    self._generate_reactions(reactants=reactants,
  File "/home/lucey.da/RMG-Py/rmgpy/data/kinetics/family.py", line 2092, in _generate_reactions
    product_structures = self._generate_product_structures(reactant_structures,
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lucey.da/RMG-Py/rmgpy/data/kinetics/family.py", line 1640, in _generate_product_structures
    product_structures = self.apply_recipe(reactant_structures, forward=forward, relabel_atoms=relabel_atoms)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lucey.da/RMG-Py/rmgpy/data/kinetics/family.py", line 1527, in apply_recipe
    struct.update(sort_atoms=not self.save_order)
  File "rmgpy/molecule/molecule.py", line 1353, in rmgpy.molecule.molecule.Molecule.update
  File "rmgpy/molecule/molecule.py", line 1592, in rmgpy.molecule.molecule.Molecule.update_atomtypes
  File "rmgpy/molecule/molecule.py", line 1587, in rmgpy.molecule.molecule.Molecule.update_atomtypes
  File "rmgpy/molecule/atomtype.py", line 903, in rmgpy.molecule.atomtype.get_atomtype
  File "rmgpy/molecule/atomtype.py", line 931, in rmgpy.molecule.atomtype.get_atomtype
rmgpy.exceptions.AtomTypeError: Unable to determine atom type for atom C+, which has 1 single bonds, 0 double bonds (0 to O, 0 to S, 0 others), 0 triple bonds, 0 quadruple bonds, 0 benzene bonds, 1 lone pairs, and +1 charge.

It seems as though the reaction family Surface_Dissociation_vdW tried to break the double bond connecting two atoms while only giving each of them a single bond to the surface. Breaking the double bond seems to be handled by Surface_Dissociation_Double_vdW.

Description of Changes

I changed the entries that match species with a double bond between the atoms where the dissociation occurs to require a single bond only.

Testing

The following can be run, which I found reproduces the error without the fix, but runs without error after the fix is applied. This uses the same species that failed in the problem case.

from rmgpy import settings
from rmgpy.molecule import Molecule
from rmgpy.data.kinetics.database import KineticsDatabase


def test_surface_dissociation_vdw_no_double_bonds():
    """
    Test that the Surface_Dissociation_vdW family does not generate reactions for breaking a double bond.
    """

    database = KineticsDatabase()
    database.load_families(path=os.path.join(settings["database.directory"], "kinetics/families"),families=['Surface_Dissociation_vdW'])

    vacant = Molecule().from_adjacency_list("1 X u0 p0 c0")
    reactants = [
                Molecule().from_adjacency_list("""
                1   C u0 p0 c0 {2,D} {3,S} {4,S}
                2   C u0 p1 c0 {1,D}
                3   H u0 p0 c0 {1,S}
                4   H u0 p0 c0 {1,S}
                5 *3 X u0 p0 c0
                """),
            ]
    for reactant in reactants:
        database.generate_reactions([reactant, vacant])

test_surface_dissociation_vdw_no_double_bonds()

Reviewer Tips

I hope that I have understood this correctly, and I am not sure if a test would need to be added to RMG-Py, but if it did, I would plan to have it be in the form of the test provided. Thank you so much for taking a look!

… bonds so that recipe does not give error when applied.
@djlucey
djlucey requested a balanced review from Copilot October 6, 2026 18:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants