Пример #1
0
    def metric_tensor_cog(self, x, p):
        ''' calculate the metric tensor when for w_i != m_i '''
        R, R1, R2, R3 = rotMatDeriv(p, True)        
        g = np.zeros([6,6])

        # the com part
        g[0:3,0:3] = self.W * np.identity(3)

        # the rotational part        
        g[3,3] = np.trace(np.dot(R1, np.dot(self.Sm, R1.transpose())))
        g[3,4] = np.trace(np.dot(R1, np.dot(self.Sm, R2.transpose())))
        g[3,5] = np.trace(np.dot(R1, np.dot(self.Sm, R3.transpose())))
        g[4,4] = np.trace(np.dot(R2, np.dot(self.Sm, R2.transpose())))
        g[4,5] = np.trace(np.dot(R2, np.dot(self.Sm, R3.transpose())))
        g[5,5] = np.trace(np.dot(R3, np.dot(self.Sm, R3.transpose())))
        
        g[4,3] = g[3,4]
        g[5,4] = g[4,5]
        g[5,3] = g[3,5]
        
        # the mixing part
#        g[0:3,3] = 2.*self.W * np.dot(R1, self.cog)
#        g[0:3,4] = 2.*self.W * np.dot(R2, self.cog)
#        g[0:3,5] = 2.*self.W * np.dot(R3, self.cog)
#        #g[0:3,3:] = g[0:3,3:].transpose() 
#        
#        g[3,0:3] = g[0:3,3] 
#        g[4,0:3] = g[0:3,4] 
#        g[5,0:3] = g[0:3,5] 
        
        return g
Пример #2
0
    def metric_tensor(self, p):
        ''' calculate the mass weighted metric tensor '''
        R, R1, R2, R3 = rotMatDeriv(p, True)        
        g = np.zeros([3,3])
                
        g[0,0] = np.trace(np.dot(R1, np.dot(self.Sm, R1.transpose())))
        g[0,1] = np.trace(np.dot(R1, np.dot(self.Sm, R2.transpose())))
        g[0,2] = np.trace(np.dot(R1, np.dot(self.Sm, R3.transpose())))
        g[1,1] = np.trace(np.dot(R2, np.dot(self.Sm, R2.transpose())))
        g[1,2] = np.trace(np.dot(R2, np.dot(self.Sm, R3.transpose())))
        g[2,2] = np.trace(np.dot(R3, np.dot(self.Sm, R3.transpose())))
        
        g[1,0] = g[0,1]
        g[2,1] = g[1,2]
        g[2,0] = g[0,2]
        gx = np.identity(3)*self.M        

        return gx, g
Пример #3
0
    def distance_squared_grad(self, com1, p1, com2, p2):
        '''
        calculate spring force between 2 sites
        
        Parameters
        ----------
        com1:
            center of mass of 1st site
        p1: 
            angle axis vector of 1st site
        com2:
            center of mass of 2nd site
        p2:
            angle axis vector of 2nd site    
        sitetype: AASiteType, optional
            amgle axis site type with mass and moment of inertia tensor
        returns: tuple
            spring cart, spring rot
        '''
        
        return _aadist.sitedist_grad(self.get_smallest_rij(com1, com2), p1, p2, self.S, self.W, self.cog)
        R1, R11, R12, R13 = rotMatDeriv(p1, True)
        R2 = rotations.aa2mx(p2)
        dR = R2 - R1
        
        dR = dR
        
        g_M = -2.*self.W*(com2-com1)
        # dR_kl S_lm dR_km
        g_P = np.zeros(3) 
        g_P[0] = -2.*np.trace(np.dot(R11, np.dot(self.S, dR.transpose())))
        g_P[1] = -2.*np.trace(np.dot(R12, np.dot(self.S, dR.transpose())))
        g_P[2] = -2.*np.trace(np.dot(R13, np.dot(self.S, dR.transpose())))
    
        g_M -= 2.*self.W *  np.dot(dR, self.cog)
        g_P[0] -= 2.*self.W * np.dot((com2-com1), np.dot(R11, self.cog))
        g_P[1] -= 2.*self.W * np.dot((com2-com1), np.dot(R12, self.cog))
        g_P[2] -= 2.*self.W * np.dot((com2-com1), np.dot(R13, self.cog))

        return g_M, g_P
Пример #4
0
 
 grad[0] -= np.dot(grad[0], v)*v
 grad[1] -= np.dot(grad[1], v)*v
 
 grad -= np.average(grad, axis=0)
 grad /= np.linalg.norm(grad)
 
 print "torque", np.linalg.norm(np.cross(grad, v))
 rbgrad = system.transform_gradient(rbcoords, grad)
 p = rbcoords[3:]
 x = rbcoords[0:3]
 gp = rbgrad[3:]
 gx = rbgrad[:3]
 
 from pygmin.potentials.fortran.rmdrvt import rmdrvt as rotMatDeriv
 R, R1, R2, R3 = rotMatDeriv(p, True)        
 
 print "test1", np.linalg.norm(R1*gp[0])     
 print "test2", np.linalg.norm(R2*gp[1])     
 print "test3", np.linalg.norm(R3*gp[2])
 print "test4", np.linalg.norm(R1*gp[0]) + np.linalg.norm(R2*gp[1]) + np.linalg.norm(R3*gp[2])
      
 dR = R1*gp[0] + R2*gp[1] + R3*gp[2]
 print "test", np.linalg.norm(R1*gp[0] + R2*gp[1] + R3*gp[2])
 print np.trace(np.dot(dR, dR.transpose()))
 G = water.metric_tensor_aa(p)
 print np.dot(p, np.dot(G, p))     
 exit()
 
 
 gnew = system.redistribute_forces(rbcoords, rbgrad)
Пример #5
0
 def update_rot_mat(self, aa, do_derivatives=True):
     self.rotation_mat, self.drmat[0, :, :], self.drmat[
         1, :, :], self.drmat[2, :, :] = rotMatDeriv(aa, do_derivatives)
Пример #6
0
    grad[0] -= np.dot(grad[0], v) * v
    grad[1] -= np.dot(grad[1], v) * v

    grad -= np.average(grad, axis=0)
    grad /= np.linalg.norm(grad)

    print "torque", np.linalg.norm(np.cross(grad, v))
    rbgrad = system.transform_gradient(rbcoords, grad)
    p = rbcoords[3:]
    x = rbcoords[0:3]
    gp = rbgrad[3:]
    gx = rbgrad[:3]

    from pygmin.potentials.fortran.rmdrvt import rmdrvt as rotMatDeriv
    R, R1, R2, R3 = rotMatDeriv(p, True)

    print "test1", np.linalg.norm(R1 * gp[0])
    print "test2", np.linalg.norm(R2 * gp[1])
    print "test3", np.linalg.norm(R3 * gp[2])
    print "test4", np.linalg.norm(R1 * gp[0]) + np.linalg.norm(
        R2 * gp[1]) + np.linalg.norm(R3 * gp[2])

    dR = R1 * gp[0] + R2 * gp[1] + R3 * gp[2]
    print "test", np.linalg.norm(R1 * gp[0] + R2 * gp[1] + R3 * gp[2])
    print np.trace(np.dot(dR, dR.transpose()))
    G = water.metric_tensor_aa(p)
    print np.dot(p, np.dot(G, p))
    exit()

    gnew = system.redistribute_forces(rbcoords, rbgrad)
Пример #7
0
 def update_rot_mat(self, aa, do_derivatives = True):
     self.rotation_mat, self.drmat[0,:,:], self.drmat[1,:,:], self.drmat[2,:,:] = rotMatDeriv(aa, do_derivatives)