Debian Codegraph @

test/data/testMP.py

raw
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (c) 2017, the cclib development team
4 #
5 # This file is part of cclib (http://cclib.github.io) and is distributed under
6 # the terms of the BSD 3-Clause License.
7
8 """Test Moller-Plesset logfiles in cclib"""
9
10 import os
11 import unittest
12
13 import numpy
14
15 from skip import skipForParser
16
17 __filedir__ = os.path.realpath(os.path.dirname(__file__))
18
19
20 class GenericMP2Test(unittest.TestCase):
21 """Generic MP2 unittest"""
22
23 level = 2
24
25 def testsizeandshape(self):
26 """(MP2) Are the dimensions of mpenergies correct?"""
27 self.assertEqual(self.data.mpenergies.shape,
28 (len(self.data.scfenergies), self.level-1))
29
30 def testchange(self):
31 """(MP2) Are Moller-Plesset corrections negative?"""
32 if self.level == 2:
33 corrections = self.data.mpenergies[:,0] - self.data.scfenergies
34 else:
35 corrections = self.data.mpenergies[:,self.level-2] - self.data.mpenergies[:,self.level-3]
36 self.assertTrue(numpy.alltrue(corrections < 0.0))
37
38 class GenericMP3Test(GenericMP2Test):
39 """Generic MP3 unittest"""
40 level = 3
41
42 class GenericMP4SDQTest(GenericMP2Test):
43 """Generic MP4(SDQ) unittest"""
44 level = 4
45
46 class GenericMP4SDTQTest(GenericMP2Test):
47 """Generic MP4(SDTQ) unittest"""
48 level = 4
49
50 class GenericMP5Test(GenericMP2Test):
51 """Generic MP5 unittest"""
52 level = 5
53
54
55 class GaussianMP2Test(GenericMP2Test):
56 """Customized MP2 unittest"""
57
58 def testnocoeffs(self):
59 """Are natural orbital coefficients the right size?"""
60 self.assertEqual(self.data.nocoeffs.shape, (self.data.nmo, self.data.nbasis))
61
62 def testnocoeffs(self):
63 """Are natural orbital occupation numbers the right size?"""
64 self.assertEqual(self.data.nooccnos.shape, (self.data.nmo, ))
65
66 class GaussianMP3Test(GenericMP2Test):
67 """Customized MP3 unittest"""
68 level = 3
69
70 class GaussianMP4SDQTest(GenericMP2Test):
71 """Customized MP4-SDQ unittest"""
72 level = 4
73
74 class GaussianMP4SDTQTest(GenericMP2Test):
75 """Customized MP4-SDTQ unittest"""
76 level = 4
77
78
79 class QChemMP4SDQTest(GenericMP2Test):
80 """Customized MP4-SDQ unittest"""
81 level = 4
82
83 class QChemMP4SDTQTest(GenericMP2Test):
84 """Customized MP4-SD(T)Q unittest"""
85 level = 5
86
87
88 if __name__=="__main__":
89
90 import sys
91 sys.path.insert(1, os.path.join(__filedir__, ".."))
92
93 from test_data import DataSuite
94 suite = DataSuite(['MP'])
95 suite.testall()