示例#1
0
        else:
            indexes = self.data.optdone
            geovalues_from_index = self.data.geovalues[indexes]
            temp = numpy.all(self.data.geovalues <= self.data.geotargets,
                             axis=1)
            geovalues = self.data.geovalues[temp]
            self.assertArrayEquals(geovalues, geovalues_from_index)


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"""
    def testindices(self):
        """Do the indices match the results from geovalues. PASS"""
        self.assertEquals(1, 1)


if __name__ == "__main__":

    from testall import testall
    testall(modules=["Scan"])
示例#2
0
    
    # Write up a new test, and/or revise the one inherited.
    def testcoeffs(self):
        """Are the basis set coefficients correct? PASS"""
        self.assertEqual(1, 1)


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


class JaguarBigBasisTest(GenericBigBasisTest):
    """Customized big basis set unittest"""

    spherical = True

    # Jaguar only goes up to F functions.
    names = ['S', 'P', 'D', 'F']


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

              
if __name__=="__main__":

    from testall import testall
    testall(modules=["Basis"])
示例#3
0
        self.assertEqual(len(self.data.etenergies), self.number)
    
    def testoscsnumber(self):
        """Is the length of eotscs correct?"""
        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__":

    from testall import testall
    testall(modules=["TDun"])
示例#4
0
    def testcorrect(self):
        """Is coreelectrons equal to what it should be?"""
        pt = PeriodicTable()
        ans = []
        for x in self.data.atomnos:
            ans.append(self.coredict[pt.element[x]])
        ans = numpy.array(ans, "i")
        self.assertArrayEquals(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__":

    from testall import testall
    testall(modules=["Core"])
示例#5
0
    # Why is this test passed?
    def testmosyms(self):
        """Are the dims of the mosyms equal to 2 x nmo? PASS"""
        self.assertEquals(1, 1)


class MolproSPunTest(GenericSPunTest):
    """Molpro unrestricted single point unittest."""
    def testmosyms(self):
        """Are the dims of the mosyms equal to 2 x nmo? PASS"""
        self.assertEquals(1, 1)


class OrcaSPunTest(GenericSPunTest):
    """ORCA unrestricted single point unittest."""

    # ORCA has no support for symmetry yet.
    def testmosyms(self):
        """Are the dims of the mosyms equals to 2 x nmo?"""
        self.assertEquals(1, 1)


class PCGamessSPunTest(GenericSPunTest):
    """PC-GAMESS unrestricted single point unittest."""


if __name__ == "__main__":

    from testall import testall
    testall(modules=["SPun"])
示例#6
0
class MolproSPTest(GenericSPTest):
    """Molpro restricted single point unittest."""
    def testsymlabels(self):
        """Are all the symmetry labels either Ag/u or Bg/u? PASS"""
        self.assertEquals(1, 1)


class OrcaSPTest(GenericSPTest):
    """ORCA restricted single point unittest."""

    # This was run in 3-21G; H has 2, C has 9.
    nbasisdict = {1: 2, 6: 9}

    # Approximate B3LYP energy of dvb after SCF in 3-21G.
    b3lyp_energy = -10470

    # ORCA has no support for symmetry yet.
    def testsymlabels(self):
        """Are all the symmetry labels either Ag/u or Bg/u? PASS"""
        self.assertEquals(1, 1)


class PCGamessSPTest(GenericSPTest):
    """PC-GAMESS restricted single point unittest."""


if __name__ == "__main__":

    from testall import testall
    testall(modules=["SP"])
示例#7
0
    def testcorrect(self):
        """Is coreelectrons equal to what it should be?"""
        pt = PeriodicTable()
        ans = []
        for x in self.data.atomnos:
            ans.append(self.coredict[pt.element[x]])
        ans = numpy.array(ans, "i")
        self.assertArrayEquals(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__":

    from testall import testall
    testall(modules=["Core"])
示例#8
0
        indexes = self.data.optdone
        geovalues_from_index = self.data.geovalues[indexes]
        temp = numpy.all(self.data.geovalues <= self.data.geotargets, axis=1)
        geovalues = self.data.geovalues[temp]

        self.assertArrayEquals(geovalues, geovalues_from_index)


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"""

    def testindices(self):
        """Do the indices match the results from geovalues. PASS"""
        self.assertEquals(1, 1)


if __name__=="__main__":

    from testall import testall
    testall(modules=["Scan"])
示例#9
0
        """Are all the symmetry labels either Ag/u or Bg/u? PASS"""
        self.assertEquals(1, 1)


class OrcaGeoOptTest(GenericGeoOptTest):
    """ORCA geometry optimization unittest."""

    extracoords = 1
    extrascfs = 1

    # This was run in 3-21G; H has 2, C has 9.
    nbasisdict = {1: 2, 6: 9}

    # Approximate B3LYP energy of dvb after SCF in 3-21G.
    b3lyp_energy = -10470

    # ORCA has no support for symmetry yet.
    def testsymlabels(self):
        """Are all the symmetry labels either Ag/u or Bg/u? PASS"""
        self.assertEquals(1, 1)


class PCGamessGeoOptTest(GenericGeoOptTest):
    """PC-GAMESS geometry optimization unittest."""


if __name__ == "__main__":

    from testall import testall
    testall(modules=["GeoOpt"])
示例#10
0
    nstates = 5

    def testnocoeffs(self):
        """(MP2) Are Natural Orbital coefficients the right size?"""
        self.assertEquals(self.data.nocoeffs.shape,
                          (self.data.nmo, self.data.nbasis))


class GaussianCISTest(GenericCISWaterTest):
    """Gaussian CIS(RHF)/STO-3G water unittest."""

    nstates = 10

    def testnocoeffs(self):
        """(MP2) Are Natural Orbital coefficients the right size?"""
        self.assertEquals(self.data.nocoeffs.shape,
                          (self.data.nmo, self.data.nbasis))


class JaguarCISTest(GenericCISWaterTest):
    """Jaguar CIS(RHF)/STO-3G water unittest."""

    nstates = 5


if __name__ == "__main__":

    from testall import testall
    testall(modules=["CI"])
示例#11
0
文件: testTD.py 项目: avirshup/cclib

class OrcaTDDFTTest(GenericTDTest):
    """Customized time-dependent HF/DFT unittest"""

    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.assertInside(max(self.data.etoscs), 1.0, 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.assertInside(max(self.data.etoscs), 0.0, 0.01)


if __name__ == "__main__":

    from testall import testall
    testall(modules=["TD"])
示例#12
0
            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:
            with open(logpath, "w") as flog:
                stdout_backup = sys.stdout
                sys.stdout = flog
                alltests = {}
                for p in parser_names:
                    tests = testall(parsers=[p], stream=flog)
                    alltests[p] = [{'data': t.data} for t in tests]
                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)

    ncols = len(parser_names)+1
    colwidth = 20
    colfmt = "%%-%is" % colwidth
    dashes = ("="*(colwidth-1) + " ") * ncols

    print(dashes)
    print(colfmt*ncols % tuple(["attributes"] + parser_names))
示例#13
0
    # Molecular mass of DVB in mD.
    molecularmass = 130078.25

    def testatommasses(self):
        """Do the atom masses sum up to the molecular mass (130078.25+-0.1mD)?"""
        mm = 1000*sum(self.data.atommasses)
        self.assertAlmostEquals(mm, 130078.25, places=10, msg="Molecule mass: %f not 130078 +- 0.1mD" %mm)


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

    # 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


if __name__=="__main__":

    from testall import testall
    testall(modules=["SP"])
示例#14
0
class GaussianRamanTest(GenericRamanTest):
    """Gaussian Raman unittest."""

    def testramanintens(self):
        """Is the maximum Raman intensity 1066 +/- 5 A**4/amu?"""
        self.assertInside(max(self.data.vibramans), 1066, 5)


class MolproRamanTest(GenericRamanTest):
    """Molpro Raman unittest."""


class OrcaRamanTest(GenericRamanTest):
    """ORCA Raman unittest."""


class PCGamessRamanTest(GenericRamanTest):
    """PC-GAMESS Raman unittest."""


class GamessUSIRimgTest(GenericIRimgTest):
    """GAMESS-US imaginary vibrational frequency unittest."""


if __name__ == "__main__":

    from testall import testall

    testall(modules=["vib"])
示例#15
0
        """Are the first row and colm of the overlap matrix identical? PASS"""
    def testdimaooverlaps(self):
        """Are the dims of the overlap matrix consistent with nbasis? PASS"""

class Psi3SPTest(PsiSPTest):
    """Customized restructed 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

    # Psi3 did not print partial atomic charges.
    def testatomcharges(self):
        """Are atomcharges (at least Mulliken) consistent with natom and sum to zero? PASS"""

    # The molecular orbitals in Psi3 are printed within each irreducible representation,
    # but I don't know if that means there is no mixing between them (SALC calculation).
    # In any case, Psi4 prints a standard LCAO, with coefficients between all basis functions
    # and molecular orbitals, so we do not parse mocoeffs in Psi3 at all.
    def testdimmocoeffs(self):
        """Are the dimensions of mocoeffs equal to 1 x nmo x nbasis? PASS"""


if __name__=="__main__":

    from testall import testall
    parser = None
    if len(sys.argv)==2:
        parser = sys.argv[1]
    testall(parser, modules=["SP"])
示例#16
0
class GaussianBigBasisTest(GenericBigBasisTest):
    """Gaussian big basis set unittest."""

    spherical = True


class MolproBasisTest(GenericBasisTest):
    """Molpro basis set unittest."""


class MolproBigBasisTest(GenericBigBasisTest):
    """Molpro big basis set unittest."""

    spherical = True


class PCGamessBasisTest(GenericBasisTest):
    """PC-GAMESS basis set unittest."""


class PCGamessBigBasisTest(GenericBigBasisTest):
    """PC-GAMESS big basis set unittest."""


if __name__ == "__main__":

    from testall import testall

    testall(modules=["Basis"])
示例#17
0
        self.assertEqual(len(self.data.etenergies), self.number)
    
    def testoscsnumber(self):
        """Is the length of eotscs correct?"""
        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__":

    from testall import testall
    testall(modules=["TDun"])
示例#18
0
    
class OrcaTDDFTTest(GenericTDTest):
    """Customized time-dependent HF/DFT unittest"""

    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), 1.0, 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__":

    from testall import testall
    testall(modules=["TD"])
示例#19
0
    #   4) energy, gradients and angles are converged (displacements not considered)
    # All these exceptions are signaleld in the output with some comments, and here
    # we include the first three exceptions for the pruposes of the unit test.
    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])

        target_e = targets[0]
        target_g = targets[1:3]
        target_x = targets[3:]
        value_e = values[0]
        value_g = values[1:3]
        value_x = values[3:]

        conv_all = all(values < targets)
        conv_e = value_e < 25*target_e and all(value_g < target_g) and all(value_x < target_x)
        conv_g = value_e < target_e and all(value_g < target_g/3.0) and all(value_x < target_x*3.0)
        conv_x = value_e < target_e and all(value_g < target_g*3.0) and all(value_x < target_x/3.0)
        converged = conv_all or conv_e or conv_g or conv_x
        self.assertTrue(converged)


if __name__=="__main__":

    from testall import testall
    testall(modules=["GeoOpt"])
示例#20
0
class GaussianSPunTest(GenericSPunTest):
    """Customized unrestricted single point unittest"""

    def testatomnos(self):
        """Does atomnos have the right dimension (20)?"""
        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__":

    from testall import testall
    testall(modules=["SPun"])
示例#21
0
文件: testMP.py 项目: avirshup/cclib
class GaussianMP3Test(GenericMP2Test):
    """Customized MP3 unittest"""
    level = 3


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__":

    from testall import testall
    testall(modules=["MP"])
示例#22
0
    """GAMESS-UK Raman unittest."""


class GaussianRamanTest(GenericRamanTest):
    """Gaussian Raman unittest."""
    def testramanintens(self):
        """Is the maximum Raman intensity 1066 +/- 5 A**4/amu?"""
        self.assertInside(max(self.data.vibramans), 1066, 5)


class MolproRamanTest(GenericRamanTest):
    """Molpro Raman unittest."""


class OrcaRamanTest(GenericRamanTest):
    """ORCA Raman unittest."""


class PCGamessRamanTest(GenericRamanTest):
    """PC-GAMESS Raman unittest."""


class GamessUSIRimgTest(GenericIRimgTest):
    """GAMESS-US imaginary vibrational frequency unittest."""


if __name__ == "__main__":

    from testall import testall
    testall(modules=["vib"])
示例#23
0

class GaussianCCDTest(GenericCCDTest):
    """Gaussian CCD unittest."""


class GaussianCCSDTest(GenericCCSDTest):
    """Gaussian CCSD unittest."""


class GaussianCCSDTTest(GenericCCSDTTest):
    """Gaussian CCSD(T) unittest."""


class MolproCCDTest(GenericCCDTest):
    """Molpro CCD unittest."""


class MolproCCSDTest(GenericCCSDTest):
    """Molpro CCSD unittest."""


class MolproCCSDTTest(GenericCCSDTTest):
    """Molpro CCSD(T) unittest."""


if __name__ == "__main__":

    from testall import testall
    testall(modules=["CC"])
示例#24
0
class GenericMP5Test(GenericMP2Test):
    """Generic MP5 unittest"""
    level = 5


class GaussianMP2Test(GenericMP2Test):
    """Customized MP2 unittest"""
        
    def testnocoeffs(self):
        """(MP2) Are Natural Orbital coefficients the right size?"""
        self.assertEquals(self.data.nocoeffs.shape, (self.data.nmo, self.data.nbasis))

class GaussianMP3Test(GenericMP2Test):
    """Customized MP3 unittest"""
    level = 3

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

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


if __name__=="__main__":

    from testall import testall
    testall(modules=["MP"])
示例#25
0
    
class GaussianCCDTest(GenericCCDTest):
    """Gaussian CCD unittest."""

    
class GaussianCCSDTest(GenericCCSDTest):
    """Gaussian CCSD unittest."""

    
class GaussianCCSDTTest(GenericCCSDTTest):
    """Gaussian CCSD(T) unittest."""

    
class MolproCCDTest(GenericCCDTest):
    """Molpro CCD unittest."""

    
class MolproCCSDTest(GenericCCSDTest):
    """Molpro CCSD unittest."""

    
class MolproCCSDTTest(GenericCCSDTTest):
    """Molpro CCSD(T) unittest."""


if __name__ == "__main__":

    from testall import testall
    testall(modules=["CC"])
示例#26
0
class GAMESSUSCISTest(GenericCISWaterTest):
    """GAMESS-US CIS(RHF)/STO-3G water unittest."""

    nstates = 5
        
    def testnocoeffs(self):
        """(MP2) Are Natural Orbital coefficients the right size?"""
        self.assertEquals(self.data.nocoeffs.shape, (self.data.nmo, self.data.nbasis))


class GaussianCISTest(GenericCISWaterTest):
    """Gaussian CIS(RHF)/STO-3G water unittest."""

    nstates = 10

    def testnocoeffs(self):
        """(MP2) Are Natural Orbital coefficients the right size?"""
        self.assertEquals(self.data.nocoeffs.shape, (self.data.nmo, self.data.nbasis))


class JaguarCISTest(GenericCISWaterTest):
    """Jaguar CIS(RHF)/STO-3G water unittest."""

    nstates = 5

             
if __name__=="__main__":

    from testall import testall
    testall(modules=["CI"])
示例#27
0
    # we are taking the easy way out and require the directory containing
    # tests to be passed as an argument (the only one).
    thispath = os.path.dirname(os.path.realpath(__file__))
    testpath = sys.argv[1]
    os.chdir(testpath)
    sys.path.append('.')
    from testall import parsers, testall

    # Try running all unit tests, and dump output to a file. In case there is some
    # rogue output from the tests, switch sys.stdout to the open log, too.
    logpath = thispath + "/coverage.tests.log"
    try:
        with open(logpath, "w") as flog:
            stdout_backup = sys.stdout
            sys.stdout = flog
            alltests = [testall([p], stream=flog) for p in parsers]
            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)

    ncols = len(parsers)+1
    colwidth = 18
    colfmt = "%%-%is" % colwidth
    dashes = ("="*(colwidth-1) + " ") * ncols

    print(dashes)
    print(colfmt*ncols % tuple(["attributes"] + parsers))
    print(dashes)