Ejemplo n.º 1
0
    def setUp(self):
        # Load the object

        # Imports
        from opan.grad import OrcaEngrad

        # Create the object
        self.oe = OrcaEngrad(path=self.file_name)

        # Enable long messages
        self.longMessage = True
Ejemplo n.º 2
0
    def test_ENGRAD_AltDataAtomicSymbol(self):
        from opan.grad import OrcaEngrad

        # Fail if any exception raised while loading the modified file
        #  with copper specified as the atomic symbol
        try:
            oe = OrcaEngrad(path=(self.file_name + self.names.atomicsym))
        except Exception:
            self.fail("Failed to load .engrad file with atomic symbol")
Ejemplo n.º 3
0
    def test_ENGRAD_LiveData(self):

        import os
        from opan.grad import OrcaEngrad
        from opan.error import GradError

        for fname in os.listdir(self.resourcedir):
            if fname.startswith("test_orca") and fname.endswith("engrad"):
                print("\nTesting file '" + fname + "' ... ")
                try:
                    OrcaEngrad(path=os.path.join(self.resourcedir, fname))
                except (IOError, GradError) as e: # pragma: no cover
                    self.longMessage = True
                    self.fail("Load of test file '" + str(fname) +
                            "' failed:\n" + str(e))
Ejemplo n.º 4
0
class TestOrcaEngradKnownGood(SuperOrcaEngrad):
    # Testing errors related to file parsing of a known-good ENGRAD file

    @classmethod
    def setUpClass(cls):
        from opan.test.utils import setUpTestDir

        # Set up the directory
        setUpTestDir(cls.testdir)

        # Write the file
        with open(cls.file_name, 'w') as f:
            f.write(cls.file_text_good)


    @classmethod
    def tearDownClass(cls):
        import os
        from opan.test.utils import tearDownTestDir

        # Delete the engrad file
        os.remove(cls.file_name)

        # Remove the working directory
        tearDownTestDir(cls.testdir)

    def setUp(self):
        # Load the object

        # Imports
        from opan.grad import OrcaEngrad

        # Create the object
        self.oe = OrcaEngrad(path=self.file_name)

        # Enable long messages
        self.longMessage = True

    def test_ENGRAD_KnownGoodAtomVec(self):
        # Confirm the values coming out of the ENGRAD match the known-good
        #  example file.

        # Confirm the atom list is good
        for i in range(len(self.oe.atom_syms)):
            self.assertEqual(self.oe.atom_syms[i], self.atoms[i])

    def test_ENGRAD_KnownGoodGradient(self):
        # Confirm the known-good gradient matches what's expected.

        # Confirm the gradient vector is good
        for i in range(self.oe.gradient.shape[0]):
            self.assertAlmostEqual(self.oe.gradient[i],
                        self.gradient[i], delta=1e-10,
                        msg="Gradient index " + str(i))

    def test_ENGRAD_KnownGoodEnergy(self):
        # Confirm the known-good energy matches what's expected
        self.assertAlmostEqual(self.energy, self.oe.energy, delta=1e-12)

    def test_ENGRAD_KnownGoodGeom(self):
        for i in range(self.oe.geom.shape[0]):
            self.assertAlmostEqual(self.oe.geom[i],
                        self.geom[i], delta=1e-7,
                        msg="Coordinate index " + str(i))

    def test_ENGRAD_KnownGoodCheckGeomMatches(self):
        self.assertTrue(self.oe.check_geom(self.oe.geom, self.oe.atom_syms))