Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vd w bonds #2706

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions rmgpy/data/kinetics/family.py
Original file line number Diff line number Diff line change
Expand Up @@ -1670,11 +1670,17 @@ def is_molecule_forbidden(self, molecule):
return True

# forbid vdw multi-dentate molecules for surface families
surface_sites = []
if "surface" in self.label.lower():
if molecule.get_num_atoms('X') > 1:
for atom in molecule.atoms:
if atom.atomtype.label == 'Xv':
return True
if "surface_monodentate_to_vdw_bidentate" in self.label.lower() and molecule.get_num_atoms('X') > 1:
surface_sites = [atom.atomtype.label for atom in molecule.atoms if 'X' in atom.atomtype.label]
if all(site == 'Xv' for site in surface_sites):
return True
else:
if molecule.get_num_atoms('X') > 1:
for atom in molecule.atoms:
if atom.atomtype.label == 'Xv':
return True

return False

Expand Down
2 changes: 1 addition & 1 deletion rmgpy/molecule/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def to_rdkit_mol(mol, remove_h=True, return_mapping=False, sanitize=True, save_o
label_dict[label] = [saved_index]
rd_bonds = Chem.rdchem.BondType
orders = {'S': rd_bonds.SINGLE, 'D': rd_bonds.DOUBLE, 'T': rd_bonds.TRIPLE, 'B': rd_bonds.AROMATIC,
'Q': rd_bonds.QUADRUPLE}
'Q': rd_bonds.QUADRUPLE, 'vdW': rd_bonds.UNSPECIFIED}
# Add the bonds
for atom1 in mol.vertices:
for atom2, bond in atom1.edges.items():
Expand Down
3 changes: 3 additions & 0 deletions rmgpy/molecule/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,9 @@ def _render_bond(self, atom1, atom2, bond, cr):
elif bond.is_hydrogen_bond():
# Draw a dashed line
self._draw_line(cr, x1, y1, x2, y2, dashed=True, dash_sizes=[0.5, 3.5])
elif bond.is_van_der_waals():
# Draw a dashed line
self._draw_line(cr, x1, y1, x2, y2, dashed=True, dash_sizes=[0.5, 3.5])
else:
self._draw_line(cr, x1, y1, x2, y2)
else:
Expand Down
20 changes: 16 additions & 4 deletions rmgpy/molecule/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

################################################################################

bond_orders = {'S': 1, 'D': 2, 'T': 3, 'B': 1.5}
bond_orders = {'S': 1, 'D': 2, 'T': 3, 'B': 1.5, 'vdW': 0}

globals().update({
'bond_orders': bond_orders,
Expand Down Expand Up @@ -1258,9 +1258,19 @@ def remove_van_der_waals_bonds(self):
Remove all van der Waals bonds.
"""
cython.declare(bond=Bond)
for bond in self.get_all_edges():
if bond.is_van_der_waals():
self.remove_bond(bond)
if self.is_multidentate():
#bond_types =
#possible_bonds_with_resonance = #TODO: Include possible nitrogen bonds
if any([k in ['O-X', 'C#X', 'C=X', 'C-X'] for k in self.enumerate_bonds()]):
pass
else:
for bond in self.get_all_edges():
if bond.is_van_der_waals():
self.remove_bond(bond)
else:
for bond in self.get_all_edges():
if bond.is_van_der_waals():
self.remove_bond(bond)

def sort_atoms(self):
"""
Expand Down Expand Up @@ -2942,6 +2952,8 @@ def get_desorbed_molecules(self):
bonded_atom.increment_radical()
bonded_atom.increment_lone_pairs()
bonded_atom.label = '*4'
elif bond.is_van_der_waals():
bonded_atom.label = '*5'
else:
raise NotImplementedError("Can't remove surface bond of type {}".format(bond.order))
desorbed_molecule.remove_atom(site)
Expand Down
Loading