Debian Codegraph @

test/method/testorbitals.py

raw
1 # This file is part of cclib (http://cclib.github.io), a library for parsing
2 # and interpreting the results of computational chemistry packages.
3 #
4 # Copyright (C) 2016 the cclib development team
5 #
6 # The library is free software, distributed under the terms of
7 # the GNU Lesser General Public version 2.1 or later. You should have
8 # received a copy of the license along with cclib. You can also access
9 # the full license online at http://www.gnu.org/copyleft/lgpl.html.
10
11 """Test the various population analyses (MPA, LPA, CSPA) in cclib"""
12
13 import sys
14 import os
15 import logging
16 import unittest
17
18 import numpy
19
20 from cclib.method import Orbitals
21 from cclib.parser import Gaussian
22 from cclib.parser import Psi4
23
24 sys.path.insert(1, "..")
25
26 from ..test_data import getdatafile
27
28
29 class RestrictedCalculationTest(unittest.TestCase):
30 """Check retricted calculation."""
31 def setUp(self):
32 self.data, self.logfile = getdatafile(Gaussian, "basicGaussian09", ["dvb_sp.out"])
33
34 def test_closed_shell(self):
35 self.assertTrue(Orbitals(self.data).closed_shell())
36
37
38 class UnrestrictedCalculationTest(unittest.TestCase):
39 """Check unrestricted calculation."""
40 def setUp(self):
41 self.data, self.logfile = getdatafile(Gaussian, "basicGaussian09", ["dvb_un_sp.log"])
42
43 def test_closed_shell(self):
44 self.assertFalse(Orbitals(self.data).closed_shell())
45
46
47 class RestrictedOpenShellCalculationTest(unittest.TestCase):
48 """Check restricted open shell calcualtion."""
49 def setUp(self):
50 self.data, self.logfile = getdatafile(Psi4, "basicPsi4-1.0", ["dvb_sp_rohf.out"])
51
52 def test_closed_shel(self):
53 self.assertFalse(Orbitals(self.data).closed_shell())
54
55 # TODO: add a case (regression) with an unrestricted calculation for a closed shell system.
56 # For example, in regressions: Gaussian/Gaussian03/Mo4OSibdt2
57
58
59 tests = [RestrictedCalculationTest, UnrestrictedCalculationTest]
60
61
62 if __name__ == "__main__":
63 for test in tests:
64 thistest = unittest.makeSuite(test)
65 unittest.TextTestRunner(verbosity=2).run(thistest)