Exemple #1
0
 def redistribute_forces(self, p, grad_com, grad_p):
     R, R1, R2, R3 = aautils.rotMatDeriv(p, True)
     grad = np.dot(R1, np.transpose(self.atom_positions)).transpose()*grad_p[0]
     grad += np.dot(R2, np.transpose(self.atom_positions)).transpose()*grad_p[1]
     grad += np.dot(R3, np.transpose(self.atom_positions)).transpose()*grad_p[2]
     grad += grad_com
     
     grad = (self.atom_masses * grad.transpose()).transpose()/self.M
     
     return grad
Exemple #2
0
    def transform_grad(self, p, g):
        g_com = np.sum(g, axis=0)
        R, R1, R2, R3 = aautils.rotMatDeriv(p, True)
        g_p = np.zeros_like(g_com)
        for ga, x in zip(g, self.atom_positions):
            g_p[0] += np.dot(ga, np.dot(R1, x))
            g_p[1] += np.dot(ga, np.dot(R2, x))
            g_p[2] += np.dot(ga, np.dot(R3, x))
#                        

#        g_p[0] = -np.sum(
#                        np.dot(g, np.dot(R1, np.transpose(self.atom_positions)).transpose())
#                        )
#        g_p[1] = np.sum(
#                        np.dot(g, np.dot(R2, np.transpose(self.atom_positions)).transpose())
#                        )
#        g_p[2] = np.sum(
#                        np.dot(g, np.dot(R3, np.transpose(self.atom_positions)).transpose())
#                        )
        return g_com, g_p
Exemple #3
0
 def to_atomistic(self, com, p):
     R, R1, R2, R3 = aautils.rotMatDeriv(p, False)
     return com + np.dot(R, np.transpose(self.atom_positions)).transpose()