6767def _skip_first (in_tuple ):
6868 return in_tuple [1 :]
6969
70- bond_orders = {'S' : 1 , 'D' : 2 , 'T' : 3 , 'B' : 1.5 }
70+ bond_orders = {'S' : 1 , 'D' : 2 , 'T' : 3 , 'B' : 1.5 , 'vdW' : 0 }
7171
7272globals ().update ({
7373 'bond_orders' : bond_orders ,
@@ -1219,6 +1219,36 @@ def has_bond(self, atom1, atom2):
12191219 """
12201220 return self .has_edge (atom1 , atom2 )
12211221
1222+ def has_covalent_surface_bond (self ):
1223+ """
1224+ Return True if any bond in this molecule connects a surface site (X) via a covalent bond.
1225+ """
1226+ cython .declare (atom = Atom , bond = Bond )
1227+ for atom in self .atoms :
1228+ if atom .is_surface_site ():
1229+ for bond in atom .bonds .values ():
1230+ if not bond .is_van_der_waals ():
1231+ return True
1232+ return False
1233+
1234+ def has_vdw_surface_bond (self ):
1235+ """
1236+ Return True if any bond in this molecule connects a surface site (X)
1237+ via a van der Waals bond, or there's a surface site with no bonds
1238+ (but at least one other atom in the molecule).
1239+ """
1240+ cython .declare (atom = Atom , bond = Bond )
1241+ for atom in self .atoms :
1242+ if atom .is_surface_site ():
1243+ if not atom .bonds : # if there are no bonds at all
1244+ if len (self .atoms ) > 1 : # and there's something besides the surface site
1245+ return True # then treat as vdW bonded
1246+ for bond in atom .bonds .values ():
1247+ if bond .is_van_der_waals ():
1248+ return True
1249+
1250+ return False
1251+
12221252 def contains_surface_site (self ):
12231253 """
12241254 Returns ``True`` iff the molecule contains an 'X' surface site.
@@ -1273,9 +1303,14 @@ def remove_bond(self, bond):
12731303
12741304 def remove_van_der_waals_bonds (self ):
12751305 """
1276- Remove all van der Waals bonds.
1306+ Remove all van der Waals bonds. For multidentate species,
1307+ vdW bonds are preserved when there are still other
1308+ covalent bonds with the surface present. If no covalent surface bonds are present,
1309+ all vdW bonds are removed.
12771310 """
12781311 cython .declare (bond = Bond )
1312+ if self .has_covalent_surface_bond ():
1313+ return # preserve any vdW bonds if there's also a covalent X
12791314 for bond in self .get_all_edges ():
12801315 if bond .is_van_der_waals ():
12811316 self .remove_bond (bond )
@@ -3048,9 +3083,13 @@ def is_multidentate(self):
30483083 Return ``True`` if the adsorbate contains at least two binding sites,
30493084 or ``False`` otherwise.
30503085 """
3051- cython .declare (atom = Atom )
3052- if len ([atom for atom in self .vertices if atom .is_surface_site ()])>= 2 :
3053- return True
3086+ cython .declare (atom = Atom , found_one = cython .bint )
3087+ found_one = False
3088+ for atom in self .atoms :
3089+ if atom .is_surface_site ():
3090+ if found_one :
3091+ return True
3092+ found_one = True
30543093 return False
30553094
30563095 def get_adatoms (self ):
@@ -3076,6 +3115,7 @@ def get_desorbed_molecules(self):
30763115 ``*2`` - double bond
30773116 ``*3`` - triple bond
30783117 ``*4`` - quadruple bond
3118+ ``*0`` - vdW bond
30793119 """
30803120 cython .declare (desorbed_molecules = list , desorbed_molecule = Molecule , sites_to_remove = list , adsorbed_atoms = list ,
30813121 site = Atom , numbonds = cython .int , bonded_atom = Atom , bond = Bond , i = cython .int , j = cython .int , atom0 = Atom ,
@@ -3114,6 +3154,8 @@ def get_desorbed_molecules(self):
31143154 bonded_atom .increment_radical ()
31153155 bonded_atom .increment_lone_pairs ()
31163156 bonded_atom .label = '*4'
3157+ elif bond .is_van_der_waals ():
3158+ bonded_atom .label = '*0'
31173159 else :
31183160 raise NotImplementedError ("Can't remove surface bond of type {}" .format (bond .order ))
31193161 desorbed_molecule .remove_atom (site )
0 commit comments