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