def calc_bondangle_append(self, bondangles, bond1, bond2, cutoff): acc = 10 ** -6 # accuracy for angle calculation # if both bonds are smaller than cutoff if bond1.bondlength() < cutoff[0] and bond2.bondlength() < cutoff[1]: preangle = ( calc.vecprod(bond1.bondvector(), bond2.bondvector()) / calc.length(bond1.bondvector()) / calc.length(bond2.bondvector()) ) # if angle is not 360 or 0 if preangle < 1 - acc: bondangles.append(numpy.arccos(preangle) * 180.0 / numpy.pi)
def crystal_cut(self,point,normal): # plane=a*x+b*y+c*z+f=0 poplist=[] #f =(-ax0-by0-cz0) normal=calc.norm(normal) f=(-calc.vecprod(normal,point)) # loop over molecules for i in range(self.nmol()): for j in range(0,self.mol[i].natoms()): coo=self.mol[i].at()[j].Rcoord() D=(calc.vecprod(normal,coo)+f)/calc.length(normal) # if above plane remove if D>0.0: poplist.append(self.mol[i].id()) # rm double or tripple counts poplist=sorted(list( set(poplist) )) # pop molecules for popi in range(0,len(poplist)): self.rm_submol(poplist[popi]) print >> sys.stderr, ('... {:5d} molecules popped').format(len(poplist)) return