File: testelectrons.py

package info (click to toggle)
cclib 1.6-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,296 kB
  • sloc: python: 15,486; sh: 101; makefile: 86
file content (48 lines) | stat: -rw-r--r-- 1,481 bytes parent folder | download
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
# -*- coding: utf-8 -*-
#
# Copyright (c) 2017, 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 the Electrons method in cclib"""

from __future__ import print_function

import sys
import os
import re
import logging
import unittest

import numpy

from cclib.method import Electrons
from cclib.parser import Gaussian
from cclib.parser import QChem

sys.path.insert(1, "..")

from ..test_data import getdatafile


class ElectronsTest(unittest.TestCase):

    def test_count(self):
        """Test electron count for logfiles without pseudopotentials."""
        data, logfile = getdatafile(QChem, "basicQChem4.2", "water_mp4sdq.out")
        self.assertEqual(Electrons(data).count(), 10)
        self.assertEqual(Electrons(data).count(core=True), 10)
        data, logfile = getdatafile(Gaussian, "basicGaussian09", "water_cis.log")
        self.assertEqual(Electrons(data).count(), 10)
        self.assertEqual(Electrons(data).count(core=True), 10)

    def test_count_pseudopotential(self):
        """Test electron count for logfiles with pseudopotentials."""
        data, logfile = getdatafile(Gaussian, "basicGaussian09", "Mo4OCl4-sp.log")
        self.assertEqual(Electrons(data).count(), 120)
        self.assertEqual(Electrons(data).count(core=True), 188)


if __name__ == "__main__":
    unittest.TextTestRunner(verbosity=2).run(unittest.makeSuite(ElectronsTest))