| 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 Electrons method in cclib""" |
| 9 |
|
| 10 |
from __future__ import print_function |
| 11 |
|
| 12 |
import sys |
| 13 |
import os |
| 14 |
import re |
| 15 |
import logging |
| 16 |
import unittest |
| 17 |
|
| 18 |
import numpy |
| 19 |
|
| 20 |
from cclib.method import Electrons |
| 21 |
from cclib.parser import Gaussian |
| 22 |
from cclib.parser import QChem |
| 23 |
|
| 24 |
sys.path.insert(1, "..") |
| 25 |
|
| 26 |
from ..test_data import getdatafile |
| 27 |
|
| 28 |
|
| 29 |
class ElectronsTest(unittest.TestCase): |
| 30 |
|
| 31 |
def test_count(self): |
| 32 |
"""Test electron count for logfiles without pseudopotentials.""" |
| 33 |
data, logfile = getdatafile(QChem, "basicQChem4.2", ["water_mp4sdq.out"]) |
| 34 |
self.assertEqual(Electrons(data).count(), 10) |
| 35 |
self.assertEqual(Electrons(data).count(core=True), 10) |
| 36 |
data, logfile = getdatafile(Gaussian, "basicGaussian09", ["water_cis.log"]) |
| 37 |
self.assertEqual(Electrons(data).count(), 10) |
| 38 |
self.assertEqual(Electrons(data).count(core=True), 10) |
| 39 |
|
| 40 |
def test_count_pseudopotential(self): |
| 41 |
"""Test electron count for logfiles with pseudopotentials.""" |
| 42 |
data, logfile = getdatafile(Gaussian, "basicGaussian09", ["Mo4OCl4-sp.log"]) |
| 43 |
self.assertEqual(Electrons(data).count(), 120) |
| 44 |
self.assertEqual(Electrons(data).count(core=True), 188) |
| 45 |
|
| 46 |
def test_alpha_beta(self): |
| 47 |
"""Test number of alpha and beta electrons""" |
| 48 |
# Systems with alpha == beta |
| 49 |
data, logfile = getdatafile(QChem, "basicQChem4.2", ["water_mp4sdq.out"]) |
| 50 |
self.assertEqual(Electrons(data).alpha(), 5) |
| 51 |
self.assertEqual(Electrons(data).beta(), 5) |
| 52 |
data, logfile = getdatafile(Gaussian, "basicGaussian09", ["water_cis.log"]) |
| 53 |
self.assertEqual(Electrons(data).alpha(), 5) |
| 54 |
self.assertEqual(Electrons(data).beta(), 5) |
| 55 |
# Systems with alpha != beta |
| 56 |
data, logfile = getdatafile(QChem, "basicQChem4.2", ["dvb_sp_un.out"]) |
| 57 |
self.assertEqual(Electrons(data).alpha(), 35) |
| 58 |
self.assertEqual(Electrons(data).beta(), 34) |
| 59 |
data, logfile = getdatafile(Gaussian, "basicGaussian09", ["dvb_un_sp.log"]) |
| 60 |
self.assertEqual(Electrons(data).alpha(), 35) |
| 61 |
self.assertEqual(Electrons(data).beta(), 34) |
| 62 |
|
| 63 |
if __name__ == "__main__": |
| 64 |
unittest.TextTestRunner(verbosity=2).run(unittest.makeSuite(ElectronsTest)) |