示例#1
0
文件: test_zmat.py 项目: gncs/molgym
    def test_dihedral_sign(self):
        p0 = np.array([0, 0, 1], dtype=np.float)
        p1 = np.array([0, 0, 0], dtype=np.float)
        p2 = np.array([0, 1, 0], dtype=np.float)

        p3_1 = np.array([1, 0, 0], dtype=np.float)
        dihedral = get_dihedral(p0, p1, p2, p3_1)
        self.assertEqual(dihedral, np.pi / 2)

        p3_2 = np.array([-1, 0, 0], dtype=np.float)
        dihedral = get_dihedral(p0, p1, p2, p3_2)
        self.assertEqual(dihedral, -np.pi / 2)
示例#2
0
文件: test_zmat.py 项目: gncs/molgym
    def test_dihedral(self):
        p1 = np.array([0, 0, 1.5], dtype=np.float)
        p2 = np.array([0, 0, 0], dtype=np.float)
        p3 = np.array([0, 0.5, 0], dtype=np.float)

        for psi in np.arange(start=-np.pi, stop=np.pi, step=np.pi / 17):
            p4 = np.array([np.sin(psi), 0.5, np.cos(psi)], dtype=np.float)
            dihedral = get_dihedral(p1, p2, p3, p4)
            self.assertAlmostEqual(psi, dihedral)
示例#3
0
文件: test_zmat.py 项目: gncs/molgym
    def test_dihedral_2(self):
        p1 = np.array([0, 0, 1.5], dtype=np.float)
        p2 = np.array([0, 0, 0], dtype=np.float)
        p3 = np.array([0, 0.5, 0], dtype=np.float)

        # Add delta so that the corner case of -180, 180 goes away
        delta = 1E-4
        for psi in np.arange(start=-np.pi + delta,
                             stop=np.pi - delta,
                             step=np.pi / 17):
            p4 = np.array(
                [np.sin(2 * np.pi + psi), 0.5,
                 np.cos(2 * np.pi + psi)],
                dtype=np.float)
            dihedral = get_dihedral(p1, p2, p3, p4)
            self.assertAlmostEqual(psi, dihedral)
示例#4
0
文件: test_zmat.py 项目: gncs/molgym
    def test_positioning(self):
        p0 = np.array([0, 0, 1], dtype=np.float)
        p1 = np.array([0, 0, 0], dtype=np.float)
        p2 = np.array([0, 1, 0], dtype=np.float)

        distance = 2.5
        angle = 2 * np.pi / 3

        # Add delta so that the corner case of -180, 180 goes away
        delta = 1E-4
        for psi in np.arange(start=-np.pi + delta,
                             stop=np.pi - delta,
                             step=np.pi / 17):
            p_new = position_point(p0=p0,
                                   p1=p1,
                                   p2=p2,
                                   distance=distance,
                                   angle=angle,
                                   dihedral=psi)

            self.assertAlmostEqual(get_distance(p2, p_new), distance)
            self.assertAlmostEqual(get_angle(p1, p2, p_new), angle)
            self.assertAlmostEqual(get_dihedral(p0, p1, p2, p_new), psi)
示例#5
0
文件: test_zmat.py 项目: gncs/molgym
 def test_dihedral_nan(self):
     string = '4\n\nC 0.5995394918 0.0 1.0\nC -0.5995394918 0.0 1.0\nH -1.6616385861 0.0 1.0\nH 1.6616385861 0.0 1.0'
     atoms = ase.io.read(io.StringIO(string), format='xyz')
     dihedral = get_dihedral(*(a.position for a in atoms))
     self.assertTrue(np.isnan(dihedral))