def remove_unibonded(g,d=1.0,tol=0.01,use_fortran=use_fortran,iterative=False): """Removes from the geometry atoms with only one bond""" sb = [] if g.dimensionality>0: use_fortran = False # only for 0d if use_fortran: # use fortran routine # array with true in right atoms retain = clean_geometryf90.clean_geometry(g.r.transpose(),2) sb = [] # remove this atoms for i in range(len(retain)): if not retain[i]: sb.append(i) # remove gout = remove(g,sb) # remove those atoms else: # use python routine for i in range(len(g.r)): r1 = g.r[i] # first position nb = 0 # initialize for direc in g.neighbor_directions(): # loop over directions for r2 in g.replicas(d=direc): # loop over replicas dr = r1-r2 if d-tol < dr.dot(dr) < d+tol: # if sirdt neighbor nb += 1 # increase counter if nb<2: sb.append(i+0) # add to the list gout = remove(g,sb) # remove those atoms if iterative: # ensure that it hs the same number of atoms by calling again if len(g.x) != len(gout.x): # call again print("Iterative cleaning") return remove_unibonded(gout,d=d,tol=tol, use_fortran=use_fortran,iterative=iterative) return gout # return the geometry
def remove_unibonded(g,d=1.0,tol=0.01,use_fortran=use_fortran,iterative=False): """Removes from the geometry atoms with only one bond""" sb = [] if use_fortran: # use fortran routine # array with true in right atoms retain = clean_geometryf90.clean_geometry(g.r.transpose(),2) sb = [] # remove this atoms for i in range(len(retain)): if not retain[i]: sb.append(i) # remove gout = remove(g,sb) # remove those atoms else: # use python routine for i in range(len(g.r)): r1 = g.r[i] # first position nb = 0 # initialize for r2 in g.r: dr = r1-r2 if d-tol < dr.dot(dr) < d+tol: # if sirdt neighbor nb += 1 # increase counter if nb<2: sb.append(i+0) # add to the list gout = remove(g,sb) # remove those atoms if iterative: # ensure that it hs the same number of atoms by calling again if len(g.x) != len(gout.x): # call again print("Iterative cleaning") return remove_unibonded(gout,d=d,tol=tol, use_fortran=use_fortran,iterative=iterative) return gout # return the geometry
def remove_unibonded(g,d=1.0,tol=0.01,use_fortran=True): """Removes from the geometry atoms with only one bond""" sb = [] if use_fortran: # use fortran routine import clean_geometryf90 # array with true in right atoms retain = clean_geometryf90.clean_geometry(g.r.transpose(),2) sb = [] # remove this atoms for i in range(len(retain)): if not retain[i]: sb.append(i) # remove return remove(g,sb) # remove those atoms else: # use python routine for i in range(len(g.r)): r1 = g.r[i] # first position nb = 0 # initialize for r2 in g.r: dr = r1-r2 if d-tol < dr.dot(dr) < d+tol: # if sirdt neighbor nb += 1 # increase counter if nb<2: sb.append(i+0) # add to the list return remove(g,sb) # remove those atoms
def remove_unibonded(g, d=1.0, tol=0.01, use_fortran=True): """Removes from the geometry atoms with only one bond""" sb = [] if use_fortran: # use fortran routine import clean_geometryf90 # array with true in right atoms retain = clean_geometryf90.clean_geometry(g.r.transpose(), 2) sb = [] # remove this atoms for i in range(len(retain)): if not retain[i]: sb.append(i) # remove return remove(g, sb) # remove those atoms else: # use python routine for i in range(len(g.r)): r1 = g.r[i] # first position nb = 0 # initialize for r2 in g.r: dr = r1 - r2 if d - tol < dr.dot(dr) < d + tol: # if sirdt neighbor nb += 1 # increase counter if nb < 2: sb.append(i + 0) # add to the list return remove(g, sb) # remove those atoms