Example #1
0
 def Align(self, coords1, coords2):
     import pygmin.utils.rotations as rot
     import pygmin.utils.crystals as cr
     c1 = CoordsAdapter(nrigid=2, nlattice=6, coords=coords1)
     c2 = CoordsAdapter(nrigid=2, nlattice=6, coords=coords2)
     cr.compareStructures(c1, c2)
     
     dcom=np.mean(c2.posRigid[0], axis=0) - np.mean(c1.posRigid, axis=0)                  
     d1 = np.linalg.norm(c1.posRigid[0] - c2.posRigid[0] + dcom) + np.linalg.norm(c1.posRigid[1] - c2.posRigid[1] + dcom)
     d2 = np.linalg.norm(c1.posRigid[0] - c2.posRigid[1] + dcom) + np.linalg.norm(c1.posRigid[1] - c2.posRigid[0] + dcom)
     if(d1 > d2+1000000.):
         print "permute"
         tmp = c2.posRigid[0].copy()
         c2.posRigid[0]=c2.posRigid[1]
         c2.posRigid[1]=tmp
         tmp = c2.rotRigid[0].copy()
         c2.rotRigid[0]=c2.rotRigid[1]
         c2.rotRigid[1]=tmp
         
     for i in xrange(2):
         q1 = rot.aa2q(c1.rotRigid[i])
         q2 = rot.aa2q(c2.rotRigid[i])
         if(np.dot(q1,q2)<0):
             q2=-q2
         c2.rotRigid[i] = rot.q2aa(q2) 
         
     return coords1, coords2
Example #2
0
    def createNEB(self, coords1, coords2):
        from pygmin.utils import rotations as rot
        pot = gminpot.GMINPotential(GMIN)
        neb = NEB.NEB(coords1, coords2, pot, k = 100. ,nimages=20)
        # replace rotational interpolation by slerp
        c1 = CoordsAdapter(nrigid=2, nlattice=6, coords=neb.coords[0, :])
        c2 = CoordsAdapter(nrigid=2, nlattice=6, coords=neb.coords[-1, :])

        for i in xrange(1, neb.nimages):
            ci = CoordsAdapter(nrigid=2, nlattice=6, coords=neb.coords[i, :])
            t = float(i) / float(neb.nimages)
            for j in xrange(2):
                ci.rotRigid[j] =  rot.q2aa(rot.q_slerp(
                                       rot.aa2q(c1.rotRigid[j]),
                                       rot.aa2q(c2.rotRigid[j]), t))
        return neb
Example #3
0
def interpolate_angleaxis(initial, final, t):
    ''' interpolate between 2 arrays of angle axis coordinates
    
    Parameters
    ----------    
    initial: np.array
        configuration 1
    final: np.array
        configuration 2
    t: float
        interpolation parameter with t in [0,1]    
    
    '''    
    conf = initial.copy()
    for i in xrange(conf.shape[0]):
        conf[i] = rotations.q2aa(rotations.q_slerp(rotations.aa2q(initial[i]),
                                rotations.aa2q(final[i]), t))
    return conf
Example #4
0
def interpolate_angleaxis(initial, final, t):
    ''' interpolate between 2 arrays of angle axis coordinates
    
    Parameters
    ----------    
    initial: np.array
        configuration 1
    final: np.array
        configuration 2
    t: float
        interpolation parameter with t in [0,1]    
    
    '''    
    conf = initial.copy()
    for i in xrange(conf.shape[0]):
        conf[i] = rotations.q2aa(rotations.q_slerp(rotations.aa2q(initial[i]),
                                rotations.aa2q(final[i]), t))
    return conf