예제 #1
0

class MolcasBigBasisTest(GenericBigBasisTest):
    """Customized big basis set unittest"""
    spherical = True


class MolproBigBasisTest(GenericBigBasisTest):
    """Customized big basis set unittest"""
    spherical = True


class Psi4BigBasisTest(GenericBigBasisTest):
    """Customized big basis set unittest"""
    spherical = True


class QChemBigBasisTest(GenericBigBasisTest):
    """Customized big basis set unittest"""
    spherical = True


if __name__ == "__main__":

    import sys
    sys.path.insert(1, os.path.join(__filedir__, ".."))

    from test_data import DataSuite
    suite = DataSuite(['Basis'])
    suite.testall()
예제 #2
0
    # Psi has a number of different convergence strategies to choose from, as described here:
    #     http://sirius.chem.vt.edu/psi4manual/latest/optking.html
    # and the default is to check that the max. force is converged and if the max energy change
    # or dispalcement is converged. This is in fact what is tested below.
    def testoptdone(self):
        """Has the geometry converged and set optdone to True?"""

        self.assertTrue(self.data.optdone)

        targets = self.data.geotargets
        values = numpy.abs(self.data.geovalues[-1])

        # Since the other criteria are not used and are not printed in this case, they should
        # be parsed as numpy.inf, for which we can check.
        self.assertTrue(numpy.isinf(targets[2]))
        self.assertTrue(numpy.isinf(targets[4]))

        conv = values[1] < targets[1] and (values[0] < targets[0]
                                           or values[3] < targets[3])
        self.assertTrue(conv)


if __name__ == "__main__":

    import sys
    sys.path.append(os.path.join(__filedir__, ".."))

    from test_data import DataSuite
    suite = DataSuite(['GeoOpt'])
    suite.testall()
예제 #3
0
                         len(self.data.optdone))
        for idone in self.data.optdone:
            self.assertOptDone(self.data.optstatus[idone])
            if idone != len(self.data.optstatus) - 1:
                self.assertOptNew(self.data.optstatus[idone + 1])


class GaussianScanTest(GenericScanTest):
    """Customized relaxed potential energy surface scan unittest"""
    extra = 1


class JaguarScanTest(GenericScanTest):
    """Customized relaxed potential energy surface scan unittest"""
    extra = 1


class OrcaScanTest(GenericScanTest):
    """Customized relaxed potential energy surface scan unittest"""
    extra = 1


if __name__ == "__main__":

    import sys
    sys.path.append(os.path.join(__filedir__, ".."))

    from test_data import DataSuite
    suite = DataSuite(['Scan'])
    suite.testall()
예제 #4
0
    # Jaguar prints only 10 virtual MOs by default. Can we re-run with full output?
    def testlengthmoenergies(self):
        """Is the number of evalues equal to the number of occ. MOs + 10?"""
        self.assertEquals(len(self.data.moenergies[0]), self.data.homos[0]+11)


class Psi3SPTest(GenericSPTest):
    """Customized restricted single point HF/KS unittest"""

    # The final energy is also a bit higher here, I think due to the fact
    # that a SALC calculation is done instead of a full LCAO.
    b3lyp_energy = -10300


class OrcaSPTest(GenericSPTest):
    """Customized restricted single point unittest"""

    # Orca has different weights for the masses
    molecularmass = 130190


if __name__=="__main__":

    import sys
    sys.path.insert(1, os.path.join(__filedir__, ".."))

    from test_data import DataSuite
    suite = DataSuite(['SP'])
    suite.testall()
예제 #5
0
    number = 10
    expected_l_max = 48000

    def testoscs(self):
        """Is the maximum of etoscs in the right range?"""
        self.assertEqual(len(self.data.etoscs), self.number)
        self.assertAlmostEqual(max(self.data.etoscs), .9, delta=0.1)


class GenericTDDFTtrpTest(GenericTDTest):
    """Generic time-dependent HF/DFT (triplet) unittest"""

    number = 5
    expected_l_max = 24500

    def testoscs(self):
        """Triplet excitations should be disallowed."""
        self.assertEqual(len(self.data.etoscs), self.number)
        self.assertAlmostEqual(max(self.data.etoscs), 0.0, delta=0.01)


if __name__=="__main__":

    import sys
    sys.path.insert(1, os.path.join(__filedir__, ".."))

    from test_data import DataSuite
    suite = DataSuite(['TD'])
    suite.testall()
예제 #6
0
    # to classes dynamically (bad idea), so they get overwritten when we reuse
    # classes for unittests. See bellow how we collect ccData instances to sidestep
    # this issue; although that doesn't alleviate the issue entirely, and the fix
    # needs to happen in the cclib code.
    try:
        from test_data import parser_names
        from test_data import DataSuite
        thispath = os.path.dirname(os.path.realpath(__file__))
        logpath = thispath + "/coverage.tests.log"
        try:
            with open(logpath, "w") as flog:
                stdout_backup = sys.stdout
                sys.stdout = flog
                alltests = {}
                for p in parser_names:
                    suite = DataSuite(argv=[p], stream=flog)
                    suite.testall()
                    alltests[p] = [{'data': t.data} for t in suite.alltests]
                sys.stdout = stdout_backup
        except Exception as e:
            print("Unit tests did not run correctly. Check log file for errors:")
            print(open(logpath, 'r').read())
            print(e)
            sys.exit(1)

    except ImportError:
        from testall import parsers as parser_names
        from testall import testall
        thispath = os.path.dirname(os.path.realpath(__file__))
        logpath = thispath + "/coverage.tests.log"
        try:
예제 #7
0
        size = len(self.data.atomnos)
        self.assertEquals(size, 20)


class JaguarSPunTest(GenericSPunTest):
    """Customized unrestricted single point unittest"""
    def testmoenergies(self):
        """Are the dims of the moenergies equal to 2 x homos+11?"""
        self.assertEquals(len(self.data.moenergies), 2)
        self.assertEquals(len(self.data.moenergies[0]),
                          self.data.homos[0] + 11)
        self.assertEquals(len(self.data.moenergies[1]),
                          self.data.homos[1] + 11)

    def testmosyms(self):
        """Are the dims of the mosyms equals to 2 x nmo?"""
        shape0 = (len(self.data.mosyms), len(self.data.mosyms[0]))
        shape1 = (len(self.data.mosyms), len(self.data.mosyms[1]))
        self.assertEquals(shape0, (2, self.data.homos[0] + 11))
        self.assertEquals(shape1, (2, self.data.homos[1] + 11))


if __name__ == "__main__":

    import sys
    sys.path.insert(1, os.path.join(__filedir__, ".."))

    from test_data import DataSuite
    suite = DataSuite(['SPun'])
    suite.testall()
예제 #8
0
    @skipForParser('Molcas','The parser is still being developed so we skip this test')
    @skipForParser('Turbomole','The parser is still being developed so we skip this test')
    def testisotropic(self):
        """Is the isotropic polarizability (average of the diagonal elements)
        +/- 0.01 from a reference?
        """
        isotropic = numpy.average(numpy.diag(self.data.polarizabilities[0]))
        self.assertAlmostEqual(isotropic, self.isotropic, delta=self.isotropic_delta)

    @skipForParser('Molcas','The parser is still being developed so we skip this test')
    @skipForParser('Turbomole','The parser is still being developed so we skip this test')
    def testprincomponents(self):
        """Are each of the principal components (eigenvalues) of the
        polarizability tensor +/- 0.01 from a reference?
        """
        principal_components = numpy.linalg.eigvalsh(self.data.polarizabilities[0])
        for c in range(3):
            self.assertAlmostEqual(principal_components[c],
                                   self.principal_components[c],
                                   delta=self.principal_components_delta)


if __name__=="__main__":

    import sys
    sys.path.insert(1, os.path.join(__filedir__, ".."))

    from test_data import DataSuite
    suite = DataSuite(['Polar'])
    suite.testall()
예제 #9
0
파일: testCI.py 프로젝트: zli37/cclib
                          (self.data.nmo, self.data.nbasis))

    def testnooccnos(self):
        """Are natural orbital occupation numbers the right size?"""
        self.assertEquals(self.data.nooccnos.shape, (self.data.nmo, ))


class Jaguar83CISTest(GenericCISTest):
    """Customized CIS(RHF)/STO-3G water unittest"""

    # The Jaguar8.3 job was created using 6-31G instead of STO-3G.
    etsecs0 = [[(4, 5, 0.99186)], [(4, 6, -0.98594)], [(3, 5, -0.98321)],
               [(2, 5, 0.19240), (3, 6, -0.97090)]]
    etsecs1 = [[(4, 5, 1.0)], [(2, 6, -0.231), (3, 5, -0.9676)], [(4, 6, 1.0)],
               [(2, 5, -0.536), (3, 6, -0.843)]]


class QChemCISTest(GenericCISTest):
    """Customized CIS(RHF)/STO-3G water unittest"""
    nstates = 10


if __name__ == "__main__":

    import sys
    sys.path.append(os.path.join(__filedir__, ".."))

    from test_data import DataSuite
    suite = DataSuite(['CI'])
    suite.testall()
예제 #10
0
        ans = []
        for x in self.data.atomnos:
            ans.append(self.coredict[pt.element[x]])
        ans = numpy.array(ans, "i")
        numpy.testing.assert_array_equal(self.data.coreelectrons, ans)


class ADFCoreTest(GenericCoreTest):
    """Customized core electrons unittest"""

    # For some reason ADF does not have a core in this test for chlorine atoms.
    # This might be fixable in the input.
    coredict = {'Mo': 28, 'O': 0, 'Cl': 0}


class JaguarCoreTest(GenericCoreTest):
    """Customized core electrons unittest"""

    # This test was done using LanL2DZ instead of the smaller variant.
    coredict = {'Mo': 36, 'O': 0, 'Cl': 10}


if __name__ == "__main__":

    import sys
    sys.path.append(os.path.join(__filedir__, ".."))

    from test_data import DataSuite
    suite = DataSuite(['Suite'])
    suite.testall()
예제 #11
0

class GaussianMP4SDQTest(GenericMP2Test):
    """Customized MP4-SDQ unittest"""
    level = 4


class GaussianMP4SDTQTest(GenericMP2Test):
    """Customized MP4-SDTQ unittest"""
    level = 4


class QChemMP4SDQTest(GenericMP2Test):
    """Customized MP4-SDQ unittest"""
    level = 4


class QChemMP4SDTQTest(GenericMP2Test):
    """Customized MP4-SD(T)Q unittest"""
    level = 5


if __name__ == "__main__":

    import sys
    sys.path.insert(1, os.path.join(__filedir__, ".."))

    from test_data import DataSuite
    suite = DataSuite(['MP'])
    suite.testall()
예제 #12
0
    def testdimatomcoords(self):
        """Are the number of parsed geometries consistent with the number of
        MD steps?
        """
        self.assertEqual(self.data.atomcoords.shape, (self.nenergies, 20, 3))

    def testdimtime(self):
        """Are the number of time points consistent with the number of MD
        steps?
        """
        self.assertEqual(self.data.time.shape, (self.nsteps, ))


class GaussianBOMDTest(GenericBOMDTest):
    """Customized Born-Oppenheimer molecular dynamics unittest"""

    # This may have something to do with our corrections for
    # extrapolation step rejection.
    nenergies = 35


if __name__ == "__main__":

    import sys
    sys.path.append(os.path.join(__filedir__, ".."))

    from test_data import DataSuite
    suite = DataSuite(['BOMD'])
    suite.testall()
예제 #13
0
파일: testHT.py 프로젝트: mwykes/cclib
                         (self.number, self.data.natom, 3, 3))


class GaussianHTTest(GenericHTTest):
    """Customized TD/CIS num freq HT unittest"""
    def testetveleltrdipgradsshape(self):
        """Is etveleltrdipgrads the right shape?"""
        self.assertEqual(numpy.shape(self.data.etveleltrdipgrads),
                         (self.number, self.data.natom, 3, 3))

    def testetmagtrdipgradsshape(self):
        """Is etmagtrdipgrads the right shape?"""
        self.assertEqual(numpy.shape(self.data.etmagtrdipgrads),
                         (self.number, self.data.natom, 3, 3))


class GaussianfcHTTest(GaussianHTTest):
    """Customized TD/CIS num freq HT unittest"""

    number = 1  # fchk only contains HT grads for root of interest


if __name__ == "__main__":

    import sys
    sys.path.append(os.path.join(__filedir__, ".."))

    from test_data import DataSuite
    suite = DataSuite(['HT'])
    suite.testall()
예제 #14
0
# This file is part of cclib (http://cclib.github.io) and is distributed under
# the terms of the BSD 3-Clause License.
"""Test NMR logfiles in cclib."""

import os
import unittest

from skip import skipForParser

__filedir__ = os.path.realpath(os.path.dirname(__file__))


class GenericNMRTest(unittest.TestCase):
    """Generic NMR unittest"""
    def testsize(self):
        """Check to make sure there are the correct number of tensors parsed"""
        self.assertEqual(len(self.data.nmrtensors), self.data.natom)
        self.assertEqual(len(self.data.nmrtensors[0]), 3)
        self.assertEqual(self.data.nmrtensors[0]["total"].shape, (3, 3))


if __name__ == "__main__":
    import sys

    sys.path.insert(1, os.path.join(__filedir__, ".."))

    from test_data import DataSuite

    suite = DataSuite(['NMR'])
    suite.testall()
예제 #15
0
파일: testTDun.py 프로젝트: szl0072/cclib
        self.assertEqual(len(self.data.etoscs), self.number)

    def testrotatsnumber(self):
        """Is the length of etrotats correct?"""
        self.assertEqual(len(self.data.etrotats), self.number)

    def testsecsnumber(self):
        """Is the length of etsecs correct?"""
        self.assertEqual(len(self.data.etsecs), self.number)

    def testsymsnumber(self):
        """Is the length of etsyms correct?"""
        self.assertEqual(len(self.data.etsyms), self.number)

    def testsyms(self):
        """Is etsyms populated by singlets and triplets 50/50?"""
        singlets = [sym for sym in self.data.etsyms if "Singlet" in sym]
        triplets = [sym for sym in self.data.etsyms if "Triplet" in sym]
        self.assertEqual(len(singlets), self.number / 2)
        self.assertEqual(len(triplets), self.number / 2)


if __name__ == "__main__":

    import sys
    sys.path.insert(1, os.path.join(__filedir__, ".."))

    from test_data import DataSuite
    suite = DataSuite(['TDun'])
    suite.testall()
예제 #16
0
파일: testvib.py 프로젝트: shivupa/cclib
    """Customized Raman unittest"""

    max_raman_intensity = 745


class GaussianRamanTest(GenericRamanTest):
    """Customized Raman unittest"""

    max_raman_intensity = 1066


class OrcaRamanTest(GenericRamanTest):
    """Customized Raman unittest"""

    max_raman_intensity = 1045


class QChemRamanTest(GenericRamanTest):
    """Customized Raman unittest"""

    max_raman_intensity = 588

if __name__=="__main__":

    import sys
    sys.path.insert(1, os.path.join(__filedir__, ".."))

    from test_data import DataSuite
    suite = DataSuite(['vib'])
    suite.testall()
예제 #17
0
파일: testCC.py 프로젝트: yishutu/cclib
"""Test coupled cluster logfiles"""

import os
import unittest

import numpy

from skip import skipForParser

__filedir__ = os.path.realpath(os.path.dirname(__file__))


class GenericCCTest(unittest.TestCase):
    """Generic coupled cluster unittest"""
    @skipForParser('Molcas',
                   'The parser is still being developed so we skip this test')
    def testsign(self):
        """Are the coupled cluster corrections negative?"""
        corrections = self.data.ccenergies - self.data.scfenergies
        self.failUnless(numpy.alltrue(corrections < 0.0))


if __name__ == "__main__":

    import sys
    sys.path.insert(1, os.path.join(__filedir__, ".."))

    from test_data import DataSuite
    suite = DataSuite(['CC'])
    suite.testall()
예제 #18
0
        from test_data import all_parsers
        from test_data import parser_names
        from test_data import DataSuite
        import inspect
        ds_args = inspect.getargspec(DataSuite.__init__).args
        thispath = os.path.dirname(os.path.realpath(__file__))
        logpath = thispath + "/coverage.tests.log"
        try:
            with open(logpath, "w") as flog:
                stdout_backup = sys.stdout
                sys.stdout = flog
                alltests = {}
                for p in parser_names:
                    # newer versions, changed in rev 17b5b263
                    if 'parsers' in ds_args:
                        suite = DataSuite(parsers={p: all_parsers[p]}, modules=all_modules, stream=flog)
                    else:
                        assert 'argv' in ds_args
                        suite = DataSuite(argv=[p], stream=flog)
                    suite.testall()
                    alltests[p] = [{'data': t.data} for t in suite.alltests]
                sys.stdout = stdout_backup
        except Exception as e:
            print("Unit tests did not run correctly. Check log file for errors:")
            print(open(logpath, 'r').read())
            print(e)
            sys.exit(1)

    except ImportError:
        from testall import parsers as parser_names
        from testall import testall