def res_aloal(mc, sim, n, a1, a2): # @note: this is hard coded. nres_prev = 0 nres_now = 0 cutoff = 3.6 grp = mc.swap_grp2_atms[n] for i in range(len(grp)): if grp[i] == a2: pass else: r = get_dist(sim.atoms[a2].x, sim.atoms[grp[i]].x, sim.pbc) #print r, a2, grp[i] if r < cutoff: nres_prev += 1 for i in range(len(grp)): if grp[i] == a2: pass else: r = get_dist(sim.atoms[a1].x, sim.atoms[grp[i]].x, sim.pbc) #print r, a2, grp[i] if r < cutoff: nres_now += 1 return nres_now - nres_prev
def getBondDist(self, a1, a2): """Get the distance """ x1 = self.atoms[a1 - 1].x x2 = self.atoms[a2 - 1].x dist = get_dist(x1, x2) return dist
def getBondDist(self, a1, a2): """Get the distance """ x1 = self.atoms[a1-1].x x2 = self.atoms[a2-1].x dist = get_dist(x1, x2) return dist
def sphere_cut(control, b, grp): """Cut the sphere and balance the charge. Here, we use the ratio from input as criteria. We eliminate the extra atoms according to the distances to the center. (So we first sort the atoms according to distance). """ # coarse cut (only according to radius print " Cutting the sphere ..." natoms = [0]*len(control.atoms) ndx1 = [] # coarse cut ndx2 = [] # refine cut ndx3 = [] # final atoms for i in range(len(control.atoms)): ndx1.append([]) ndx2.append([]) ndx3.append([]) # should be useful for Li3PS4 case """ for i in range(len(grp.subgroups)): nc = int(control.grpatomscenter[i]) - 1 counter = 0 for j in grp.subgroups[i]: at = b.atoms[j[nc]] dist = get_dist(at.x, control.center) if dist < control.radius: natoms[i] += 1 ndx1[i].append("%09d_%08d"%(dist*1000, counter)) counter += 1 """ counter = 0 for i in b.atoms: dist = get_dist(i.x, control.center) if dist < control.radius: n = control.atoms.index(i.name) natoms[n] += 1 ndx1[n].append("%09d_%08d"%(dist*1000, counter)) counter += 1 # print information of coarse cut print " After Coarse cut we get:" for i in range(len(control.atoms)): print " %-6s = %8d"%(control.atoms[i], len(ndx1[i])) # sort the atoms for i in ndx1: i.sort() nmin = MAX_ATOMS for i in range(len(control.natoms)): n = int(natoms[i]/control.natoms[i]) if n < nmin: nmin = n for i in range(len(control.atoms)): n = nmin * control.natoms[i] for j in range(n): ndx2[i].append(int(ndx1[i][j].split("_")[-1])) print " After balancing charge we get:" for i in range(len(control.atoms)): print " %-6s = %8d"%(control.atoms[i], len(ndx2[i])) return ndx2