示例#1
0
def compareTransformed(coords1, coords2, x1, x2, M):
    # the lattice matrix
    ml1 = lattice.lowerTriangular(coords1.lattice)
    ml2 = lattice.lowerTriangular(coords2.lattice)
    
    # the inerse lattice matrix
    iml2 = vec3.invert3x3(ml2)
    for i in xrange(coords1.nrigid):
        ptest = coords1.rotRigid[i]
        ptrans = rotations.mx2aa(rotations.np.dot(M, rotations.aa2mx(ptest)))
        for d in [np.zeros(3),[0.,1.,0.],[0.,1.,0.],[0.,0.,1.]]:
            xtest = coords1.posRigid[i] + np.array(d) - x1
            xtrans = np.dot(iml2, np.dot(M, np.dot(ml1, xtest)))
     
            match = False
            for j in xrange(coords1.nrigid):
                dx = coords2.posRigid[j] - xtrans - x2
                dx = dx - np.floor(dx)
                dx[dx>0.8]-=1.0
                dp = rotations.mx2aa(np.dot(vec3.invert3x3(rotations.aa2mx(ptrans)),rotations.aa2mx(coords2.rotRigid[j])))
                match = np.linalg.norm(np.dot(ml2, dx)) < tol_shift \
                    and np.linalg.norm(dp) < tol_rot
                if(match):
                    break
            if(not match):
                return False
    return True
示例#2
0
def has_overlap(coords, cutoff=1.0):
    ml = lattice.lowerTriangular(coords[-6:])
    natoms = coords.size/3-2
    atoms = coords.reshape(coords.size/3,3)[:-2]
    # mi = vec3.invert3x3(ml)
    
    mindist = 1000.

    a = ml[:,0]
    b = ml[:,1]
    c = ml[:,2]

    for i in xrange(natoms):
        for j in xrange(i+1,natoms):
            #d = np.dot(mi, atoms[i] - atoms[j])
            #d -= np.floor(d)
            #d[d>0.5] -= 1.
            #r_ij = np.linalg.norm(np.dot(ml, d))
            
            r_i = atoms[i]
            r_j = atoms[j]
            r_tp = r_j - r_i;
            r_dp = r_tp - c*int(r_tp[2]/c[2])
            r_sp = r_dp - b*int(r_dp[1]/b[1])
            r_ij = r_sp - a*int(r_sp[0]/a[0])

            r = np.linalg.norm(r_ij)
            if(r < cutoff):
                # print "overlapping distance is", r
                return True
            mindist = min(mindist, r)
                
    #print "the minimum distance ist", mindist
    return False