Exemplo n.º 1
0
 def test_axes_orthonorm(self):
     import opan.utils.inertia as oui
     from opan.utils.vector import orthonorm_check as onchk
     axes = oui.principals(self.xyz.geoms[0], self.hess.atom_masses)[1]
     on, nfail, ofail = onchk(axes, report=True)
     self.assertTrue(on, msg="Norm failures: " + str(nfail) +
                             "; ortho failures: " + str(ofail))
Exemplo n.º 2
0
    def test_Utils_Vector_ONCheck_Trivial1D(self):
        import numpy as np
        from scipy import linalg as spla
        from opan.utils.vector import orthonorm_check as onchk

        vec = np.array(range(15))
        vec = vec / spla.norm(vec)

        c, nf, of = onchk(vec)

        self.assertTrue(c)
        self.assertIsNone(nf)
        self.assertIsNone(of)

        c, nf, of = onchk(vec, report=True)

        self.assertTrue(c)
        self.assertEqual(len(nf), 0)
        self.assertEqual(len(of), 0)
Exemplo n.º 3
0
    def test_Utils_Vector_ONCheck_Trivial1D(self):
        import numpy as np
        from scipy import linalg as spla
        from opan.utils.vector import orthonorm_check as onchk

        vec = np.array(range(15))
        vec = vec / spla.norm(vec)

        c, nf, of = onchk(vec)

        self.assertTrue(c)
        self.assertIsNone(nf)
        self.assertIsNone(of)

        c, nf, of = onchk(vec, report=True)

        self.assertTrue(c)
        self.assertEqual(len(nf), 0)
        self.assertEqual(len(of), 0)
Exemplo n.º 4
0
    def test_Utils_Vector_ONCheck_Trivial2D(self):
        import numpy as np
        from scipy import linalg as spla
        from opan.utils.vector import orthonorm_check as onchk
        from opan.utils.vector import ortho_basis as ob

        vec = np.array([3.18, -2.25, 1.0005])
        on1, on2 = ob(vec)

        m = np.column_stack((vec / spla.norm(vec), on1, on2))

        c, nf, of = onchk(m)

        self.assertTrue(c)
        self.assertIsNone(nf)
        self.assertIsNone(of)

        c, nf, of = onchk(m, report=True)

        self.assertTrue(c)
        self.assertEqual(len(nf), 0)
        self.assertEqual(len(of), 0)
Exemplo n.º 5
0
    def test_Utils_Vector_ONCheck_Trivial2D(self):
        import numpy as np
        from scipy import linalg as spla
        from opan.utils.vector import orthonorm_check as onchk
        from opan.utils.vector import ortho_basis as ob

        vec = np.array([3.18, -2.25, 1.0005])
        on1, on2 = ob(vec)

        m = np.column_stack((vec / spla.norm(vec), on1, on2))

        c, nf, of = onchk(m)

        self.assertTrue(c)
        self.assertIsNone(nf)
        self.assertIsNone(of)

        c, nf, of = onchk(m, report=True)

        self.assertTrue(c)
        self.assertEqual(len(nf), 0)
        self.assertEqual(len(of), 0)
Exemplo n.º 6
0
    def test_Utils_Vector_ONCheck_NonNormedVec(self):
        import numpy as np
        from opan.utils.vector import orthonorm_check as onchk
        from opan.utils.vector import ortho_basis as ob

        vec = np.array([-2.112, 2923.3, -0.2323])
        on1, on2 = ob(vec)

        m = np.column_stack((vec, on1, on2))

        c, nf, of = onchk(m)

        self.assertFalse(c)
        self.assertIsNone(nf)
        self.assertIsNone(of)

        c, nf, of = onchk(m, report=True)

        self.assertFalse(c)
        self.assertEqual(len(of), 0)

        self.assertEqual(len(nf), 1)
        self.assertEqual(nf[0], 0)
Exemplo n.º 7
0
    def test_Utils_Vector_ONCheck_NonNormedVec(self):
        import numpy as np
        from opan.utils.vector import orthonorm_check as onchk
        from opan.utils.vector import ortho_basis as ob

        vec = np.array([-2.112, 2923.3, -0.2323])
        on1, on2 = ob(vec)

        m = np.column_stack((vec, on1, on2))

        c, nf, of = onchk(m)

        self.assertFalse(c)
        self.assertIsNone(nf)
        self.assertIsNone(of)

        c, nf, of = onchk(m, report=True)

        self.assertFalse(c)
        self.assertEqual(len(of), 0)

        self.assertEqual(len(nf), 1)
        self.assertEqual(nf[0], 0)
Exemplo n.º 8
0
    def test_Utils_Vector_ONCheck_SkewedVec(self):
        import numpy as np
        from scipy import linalg as spla
        from opan.utils.vector import orthonorm_check as onchk
        from opan.utils.vector import ortho_basis as ob

        vec = np.array([-6.277, 1.345, -23.8734])
        offvec = np.subtract(vec, np.array([-3, 5, -12]))
        offvec = offvec / spla.norm(offvec)

        on1, on2 = ob(vec)

        m = np.column_stack((offvec, on1, on2))

        c, nf, of = onchk(m, report=True)

        self.assertFalse(c)
        self.assertEqual(len(nf), 0)

        self.assertEqual(len(of), 2)
        self.assertEqual(of[0], (0,1))
        self.assertEqual(of[1], (0,2))
Exemplo n.º 9
0
    def test_Utils_Vector_ONCheck_SkewedVec(self):
        import numpy as np
        from scipy import linalg as spla
        from opan.utils.vector import orthonorm_check as onchk
        from opan.utils.vector import ortho_basis as ob

        vec = np.array([-6.277, 1.345, -23.8734])
        offvec = np.subtract(vec, np.array([-3, 5, -12]))
        offvec = offvec / spla.norm(offvec)

        on1, on2 = ob(vec)

        m = np.column_stack((offvec, on1, on2))

        c, nf, of = onchk(m, report=True)

        self.assertFalse(c)
        self.assertEqual(len(nf), 0)

        self.assertEqual(len(of), 2)
        self.assertEqual(of[0], (0, 1))
        self.assertEqual(of[1], (0, 2))