| 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 the MBO method in cclib""" |
| 9 |
|
| 10 |
from __future__ import print_function |
| 11 |
|
| 12 |
import sys |
| 13 |
import os |
| 14 |
import logging |
| 15 |
import unittest |
| 16 |
|
| 17 |
import numpy |
| 18 |
|
| 19 |
from cclib.method import MBO |
| 20 |
from cclib.parser import Gaussian |
| 21 |
|
| 22 |
sys.path.insert(1, "..") |
| 23 |
|
| 24 |
from ..test_data import getdatafile |
| 25 |
|
| 26 |
|
| 27 |
class MBOTest(unittest.TestCase): |
| 28 |
|
| 29 |
def test_mbo_sp(self): |
| 30 |
"""Testing Mayer bond orders for restricted single point.""" |
| 31 |
|
| 32 |
data, logfile = getdatafile(Gaussian, "basicGaussian09", ["dvb_sp.out"]) |
| 33 |
mbo = MBO(data) |
| 34 |
mbo.logger.setLevel(logging.ERROR) |
| 35 |
mbo.calculate() |
| 36 |
|
| 37 |
e_mbo = numpy.loadtxt(os.path.dirname(os.path.realpath(__file__)) + "/dvb_sp.mbo") |
| 38 |
self.assertTrue(numpy.all(mbo.fragresults[0] >= e_mbo - 0.25)) |
| 39 |
self.assertTrue(numpy.all(mbo.fragresults[0] <= e_mbo + 0.25)) |
| 40 |
|
| 41 |
def test_mbo_un_sp(self): |
| 42 |
"""Testing Mayer bond orders for unrestricted single point.""" |
| 43 |
|
| 44 |
data, logfile = getdatafile(Gaussian, "basicGaussian09", ["dvb_un_sp.log"]) |
| 45 |
mbo = MBO(data) |
| 46 |
mbo.logger.setLevel(logging.ERROR) |
| 47 |
mbo.calculate() |
| 48 |
|
| 49 |
e_mbo = numpy.loadtxt(os.path.dirname(os.path.realpath(__file__)) + "/dvb_un_sp.mbo") |
| 50 |
bond_orders = mbo.fragresults[0] + mbo.fragresults[1] |
| 51 |
self.assertTrue(numpy.all(bond_orders >= e_mbo - 0.30)) |
| 52 |
self.assertTrue(numpy.all(bond_orders <= e_mbo + 0.30)) |
| 53 |
|
| 54 |
if __name__ == "__main__": |
| 55 |
unittest.TextTestRunner(verbosity=2).run(unittest.makeSuite(MBOTest)) |