示例#1
0
    def test_val_0D_1(self):
        """Values without PBC"""

        masses = np.array([1.] * 2)

        ric = RIC()
        ric.add_stretch([1, 2])
        ric.setup(masses)

        for coords, ref in [([[-1, 0, 0], [1, 0, 0]], 2),
                            ([[0, -1, 0], [0, 1, 0]], 2),
                            ([[0, 0, -1], [0, 0, 1]], 2),
                            ([[1, 1, 1], [-1, -1, -1]], 2 * np.sqrt(3))]:

            ric.construct_b_matrix(None, np.array(coords, dtype=np.float64))
            res = ric.get_val_stretches()[0]
            self.assertAlmostEqual(res, ref)
示例#2
0
    def test_val_3D_1(self):
        """Values with PBC in an orthogonal box"""

        masses = np.array([1.] * 2)
        hmat = np.array([[5., 0., 0.], [0., 6., 0.], [0., 0., 7.]])

        ric = RIC()
        ric.add_stretch([1, 2])
        ric.setup(masses)

        for coords, ref in [([[-1, 0, 0], [1, 0, 0]], 2),
                            ([[0, -1, 0], [0, 1, 0]], 2),
                            ([[0, 0, -1], [0, 0, 1]], 2),
                            ([[1, 1, 1], [-1, -1, -1]], 2 * np.sqrt(3))]:

            ric.construct_b_matrix(hmat, np.array(coords, dtype=np.float64))
            res = ric.get_val_stretches()[0]
            self.assertAlmostEqual(res, ref)
示例#3
0
    def test_1(self):

        ric = RIC()
        ric.add_stretch([1, 2])
        ric.add_eckart()
        ric.setup(self.masses)

        bmat = ric.construct_b_matrix(self.hmat, self.coords)

        self.assertEqual(
            ric.get_val_stretches()[0],
            np.sqrt(np.sum((self.coords[0, :] - self.coords[1, :])**2)))

        bmat_inv, rank = ric.invert_b_matrix()
        bmat_inv_ = nl.pinv(bmat)
        self.assertLess(np.max(np.abs(bmat_inv - bmat_inv_)), 1.e-14)

        hess = ric.project_hessian(self.hess)
        hess_ = np.dot(bmat_inv.T, np.dot(self.hess, bmat_inv))
        self.assertLess(np.max(np.abs(hess - hess_)), 1.e-14)