Coverage for cclib/method/electrons.py : 90%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
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.
8"""Calculate properties for electrons."""
10import logging
12import numpy
14from cclib.method.calculationmethod import Method
17class Electrons(Method):
18 """A container for methods pertaining to electrons."""
20 def __init__(self, data, progress=None, loglevel=logging.INFO, logname="Log"):
22 self.required_attrs = ('atomnos','charge','coreelectrons','homos')
24 super(Electrons, self).__init__(data, progress, loglevel, logname)
26 def __str__(self):
27 """Returns a string representation of the object."""
28 return "Electrons"
30 def __repr__(self):
31 """Returns a representation of the object."""
32 return "Electrons"
34 def alpha(self):
35 """Number of alpha electrons"""
36 return self.data.homos[0] + 1
38 def beta(self):
39 """Number of beta electrons"""
40 return self.data.homos[-1] + 1
42 def count(self, core=False):
43 """Returns the electron count in system.
45 Normally returns electrons used in calculation, but will include
46 core electrons in pseudopotentials if core is True.
47 """
48 nelectrons = sum(self.data.atomnos) - self.data.charge
49 if core:
50 nelectrons += sum(self.data.coreelectrons)
51 return nelectrons