Hide keyboard shortcuts

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. 

7 

8"""Calculate properties for electrons.""" 

9 

10import logging 

11 

12import numpy 

13 

14from cclib.method.calculationmethod import Method 

15 

16 

17class Electrons(Method): 

18 """A container for methods pertaining to electrons.""" 

19 

20 def __init__(self, data, progress=None, loglevel=logging.INFO, logname="Log"): 

21 

22 self.required_attrs = ('atomnos','charge','coreelectrons','homos') 

23 

24 super(Electrons, self).__init__(data, progress, loglevel, logname) 

25 

26 def __str__(self): 

27 """Returns a string representation of the object.""" 

28 return "Electrons" 

29 

30 def __repr__(self): 

31 """Returns a representation of the object.""" 

32 return "Electrons" 

33 

34 def alpha(self): 

35 """Number of alpha electrons""" 

36 return self.data.homos[0] + 1 

37 

38 def beta(self): 

39 """Number of beta electrons""" 

40 return self.data.homos[-1] + 1 

41 

42 def count(self, core=False): 

43 """Returns the electron count in system. 

44 

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