Exemple #1
0
 def Pdefine_bonds(self, cutoff, cutmin=10 ** (-10), atomlist=[], periodicity=False):
     bndcnt = 0
     for at in self.at():
         # print if
         if (at.id() % 100) == 0 or at.id() == self.natoms() - 1:
             print >>sys.stderr, "...bonding for atom {:d} of {:d} calculated".format(at.id() + 1, self.natoms())
         # only check atoms in range
         if at.id() in atomlist:
             # do bond calculation for periodic structures
             if periodicity:
                 perx = [-1, 0, 1]
                 pery = [-1, 0, 1]
                 perz = [-1, 0, 1]
             else:
                 perx = [0]
                 pery = [0]
                 perz = [0]
             for x in perx:
                 for y in pery:
                     for z in perz:
                         for neigh in self.at():
                             l = calc.a_dist(at, neigh, per=[x, y, z])
                             if l > cutmin and l < cutoff:
                                 # print at.id(),neigh.id(),x,y,z,l #infos
                                 at.add_bond(neigh, per=[x, y, z])
                                 bndcnt += 1
     return bndcnt
Exemple #2
0
 def bondlength(self):
     return calc.a_dist(self.atom(), self.neighbor(), self.per())