Skip to content

Commit e7f0f12

Browse files
committed
add is_double_or_triple function to Bond class
update adsorbate_shift_up_resonance_structures with double_or_triple function update adsorbate_conjugate_resonance_structure with double_or_triple function
1 parent 20843b0 commit e7f0f12

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

rmgpy/molecule/molecule.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,13 @@ def is_quadruple(self):
883883
"""
884884
return self.is_order(4)
885885

886+
def is_double_or_triple(self):
887+
"""
888+
Return ``True`` if the bond represents a double or triple bond or ``False``
889+
if not.
890+
"""
891+
return self.is_order(2) or self.is_order(3)
892+
886893
def is_benzene(self):
887894
"""
888895
Return ``True`` if the bond represents a benzene bond or ``False`` if

rmgpy/molecule/resonance.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,20 +1180,21 @@ def generate_adsorbate_shift_up_resonance_structures(mol):
11801180
for atom in mol.vertices:
11811181
paths = pathfinder.find_adsorbate_delocalization_paths(atom)
11821182
for atom1, atom2, atom3, atom4, bond12, bond23, bond34 in paths:
1183-
if (bond12.is_double() and bond23.is_single() and bond34.is_double()) or (bond23.is_double() and bond12.is_double() and bond34.is_double()) or (bond12.is_triple() and bond23.is_single() and bond34.is_triple()) or (bond12.is_triple() and bond23.is_single() and bond34.is_double()):
1184-
bond12.decrement_order()
1185-
bond23.increment_order()
1186-
bond34.decrement_order()
1187-
structure = mol.copy(deep=True)
1188-
bond12.increment_order()
1189-
bond23.decrement_order()
1190-
bond34.increment_order()
1191-
try:
1192-
structure.update_atomtypes(log_species=False)
1193-
except AtomTypeError:
1194-
pass
1195-
else:
1196-
structures.append(structure)
1183+
if ((bond12.is_double_or_triple() and bond23.is_single() and bond34.is_double_or_triple()) or
1184+
(bond12.is_double() and bond23.is_double() and bond34.is_double())):
1185+
bond12.decrement_order()
1186+
bond23.increment_order()
1187+
bond34.decrement_order()
1188+
structure = mol.copy(deep=True)
1189+
bond12.increment_order()
1190+
bond23.decrement_order()
1191+
bond34.increment_order()
1192+
try:
1193+
structure.update_atomtypes(log_species=False)
1194+
except AtomTypeError:
1195+
pass
1196+
else:
1197+
structures.append(structure)
11971198
return structures
11981199

11991200

@@ -1215,9 +1216,9 @@ def generate_adsorbate_conjugate_resonance_structures(mol):
12151216
for atom in mol.vertices:
12161217
paths = pathfinder.find_adsorbate_conjugate_delocalization_paths(atom)
12171218
for atom1, atom2, atom3, atom4, atom45, bond12, bond23, bond34, bond45 in paths:
1218-
if ((bond12.is_double() or bond12.is_triple()) and
1219+
if (bond12.is_double_or_triple() and
12191220
(bond23.is_single() or bond23.is_double()) and
1220-
(bond34.is_double() or bond34.is_triple()) and
1221+
bond34.is_double_or_triple() and
12211222
(bond45.is_single() or bond45.is_double())):
12221223
bond12.decrement_order()
12231224
bond23.increment_order()

0 commit comments

Comments
 (0)