示例#1
0
    def test_2(self):
        """Multiple repeated calls"""

        ric = RIC()
        ric.add_stretch([1, 2])
        ric.add_stretch([2, 3])
        ric.add_stretch([3, 4])
        ric.add_in_bend([1, 2, 3])
        ric.add_in_bend([2, 3, 4])
        ric.add_torsion([1, 0, 0, 0, 0, 2, 3, 4, 0, 0, 0, 0])
        ric.add_eckart()
        ric.setup(self.masses)

        bmat = ric.construct_b_matrix(None, self.coords)
        b1 = np.copy(bmat)
        bmat = ric.construct_b_matrix(None, self.coords)
        b2 = np.copy(bmat)
        self.assertEqual(np.max(np.abs(b1 - b2)), 0)

        bmat_inv, rank = ric.invert_b_matrix()
        i1 = np.copy(bmat_inv)
        bmat = ric.construct_b_matrix(None, self.coords)
        b3 = np.copy(bmat)
        bmat_inv, rank = ric.invert_b_matrix()
        i2 = np.copy(bmat_inv)
        self.assertEqual(np.max(np.abs(b1 - b3)), 0)
        self.assertEqual(np.max(np.abs(i1 - i2)), 0)

        hess = ric.project_hessian(self.hess)
        h1 = np.copy(hess)
        bmat = ric.construct_b_matrix(None, self.coords)
        b4 = np.copy(bmat)
        bmat_inv, rank = ric.invert_b_matrix()
        i3 = np.copy(bmat_inv)
        hess = ric.project_hessian(self.hess)
        h2 = np.copy(hess)
        hess = ric.get_ric_hessian()
        h3 = np.copy(hess)
        self.assertEqual(np.max(np.abs(b1 - b4)), 0)
        self.assertEqual(np.max(np.abs(i1 - i3)), 0)
        self.assertEqual(np.max(np.abs(h1 - h2)), 0)
        self.assertEqual(np.max(np.abs(h1 - h3)), 0)
示例#2
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)
示例#3
0
    def test_1(self):

        ric = RIC()
        ric.add_stretch([1, 2])
        ric.add_stretch([2, 3])
        ric.add_stretch([3, 4])
        ric.add_in_bend([1, 2, 3])
        ric.add_in_bend([2, 3, 4])
        ric.add_torsion([1, 0, 0, 0, 0, 2, 3, 4, 0, 0, 0, 0])
        ric.add_eckart()
        ric.setup(self.masses)

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

        bmat_inv, rank = ric.invert_b_matrix()
        bmat_inv_ = nl.pinv(bmat)
        self.assertLess(np.max(np.abs(bmat_inv - bmat_inv_)), 7.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_)), 3.e-13)
示例#4
0
  def test_2(self):

    g1, g2 = Group([1,2,3]), Group([5,6,7])

    ric = RIC()
    ric.add_stretch([1,3])
    ric.add_stretch([2,3])
    ric.add_distance([g1,4])
    ric.add_distance([4,g2])
    ric.add_stretch([5,6])
    ric.add_stretch([5,7])
    ric.add_in_bend([1,3,2])
    ric.add_in_bend([1,3,4])
    ric.add_in_bend([2,3,4])
    ric.add_in_bend([4,5,6])
    ric.add_in_bend([4,5,7])
    ric.add_in_bend([6,5,7])
    ric.add_lin_bend([3,4,5], 'yz')
    ric.add_out_bend([3,1,2,4])
    ric.add_out_bend([3,2,4,1])
    ric.add_out_bend([3,4,1,2])
    ric.add_out_bend([5,4,6,7])
    ric.add_out_bend([5,6,7,4])
    ric.add_out_bend([5,7,4,6])
    ric.add_dihedral([1,2], [g1,g2], [6,7])
    ric.add_eckart()
    ric.setup(self.masses)

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

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

    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-13)
示例#5
0
  def test_1(self):

    ric = RIC()
    ric.add_stretch([1,3])
    ric.add_stretch([2,3])
    ric.add_stretch([3,4])
    ric.add_stretch([4,5])
    ric.add_stretch([5,6])
    ric.add_stretch([5,7])
    ric.add_in_bend([1,3,2])
    ric.add_in_bend([1,3,4])
    ric.add_in_bend([2,3,4])
    ric.add_in_bend([4,5,6])
    ric.add_in_bend([4,5,7])
    ric.add_in_bend([6,5,7])
    ric.add_lin_bend([3,4,5], 'yz')
    ric.add_out_bend([3,1,2,4])
    ric.add_out_bend([3,2,4,1])
    ric.add_out_bend([3,4,1,2])
    ric.add_out_bend([5,4,6,7])
    ric.add_out_bend([5,6,7,4])
    ric.add_out_bend([5,7,4,6])
    ric.add_torsion([1,2,0,0,0,3,5,6,7,0,0,0])
    ric.add_eckart()
    ric.setup(self.masses)

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

    bmat_inv, rank = ric.invert_b_matrix()
    bmat_inv_ = nl.pinv(bmat)
    self.assertEqual(rank, self.coords.size)
    self.assertLess(np.max(np.abs(bmat_inv - bmat_inv_)), 7.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_)),3.e-13)