Coverage for cclib/method/orbitals.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# This file is part of cclib (http://cclib.github.io), a library for parsing
4# and interpreting the results of computational chemistry packages.
5#
6# Copyright (C) 2017, the cclib development team
7#
8# The library is free software, distributed under the terms of
9# the GNU Lesser General Public version 2.1 or later. You should have
10# received a copy of the license along with cclib. You can also access
11# the full license online at http://www.gnu.org/copyleft/lgpl.html.
13"""Analyses related to orbitals."""
15import logging
17import numpy
19from cclib.method.calculationmethod import Method
22class Orbitals(Method):
23 """A class for orbital related methods."""
25 def __init__(self, data, progress=None, \
26 loglevel=logging.INFO, logname="Log"):
28 self.required_attrs = ('mocoeffs','moenergies','homos')
29 # Call the __init__ method of the superclass.
30 super(Orbitals, self).__init__(data, progress, loglevel, logname)
31 self.fragresults = None
33 def __str__(self):
34 """Return a string representation of the object."""
35 return "Orbitals"
37 def __repr__(self):
38 """Return a representation of the object."""
39 return "Orbitals"
41 def closed_shell(self):
42 """Return Boolean indicating if system is closed shell."""
44 # If there are beta orbitals, we can assume the system is closed
45 # shell if the orbital energies are identical within numerical accuracy.
46 if len(self.data.mocoeffs) == 2:
47 precision = 10e-6
48 return numpy.allclose(*self.data.moenergies, atol=precision)
50 # Restricted open shell will have one set of MOs but two HOMO indices,
51 # and the indices should be different (otherwise it's still closed shell).
52 if len(self.data.homos) == 2 and self.data.homos[0] != self.data.homos[1]:
53 return False
55 return True