Skip to content

Commit

Permalink
Prevent resonance structure generation from making charged adsorbates.
Browse files Browse the repository at this point in the history
The problem was that O=X (where X is the surface site) was forming [O+]#X
which has a net charge.

Not sure if this is the best way to solve the problem, but it solves the problem.

Closes cfgoldsmith#43
  • Loading branch information
rwest committed Jan 20, 2019
1 parent 4d9c254 commit 9616740
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion rmgpy/molecule/resonance.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,10 @@ def generate_adj_lone_pair_multiple_bond_resonance_structures(mol):
except AtomTypeError:
pass # Don't append resonance structure if it creates an undefined atomType
else:
structures.append(structure)
if structure.getNetCharge() and structure.containsSurfaceSite():
pass
else:
structures.append(structure)
return structures


Expand Down
9 changes: 9 additions & 0 deletions rmgpy/molecule/resonanceTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1332,3 +1332,12 @@ def testExocyclicDB(self):
newmol = generate_clar_structures(mol)

self.assertEquals(len(newmol), 0)

def testSurfaceO(self):
"""Test resonance structure generation for surface adsorbed O=X
Should not crash."""
# See https://github.com/cfgoldsmith/RMG-Py/issues/43
mol_list = generate_resonance_structures(Molecule().fromAdjacencyList("""OX
1 X u0 p0 c0 {2,D}
2 O u0 p2 c0 {1,D}"""))

0 comments on commit 9616740

Please sign in to comment.