The function calculateEigenstateOccupations() calculates and returns the occupation of each eigenstate for a molecule.
List of arguments
An object returned from a previously performed self-consistent calculation on a MoleculeConfiguration object.
Default:
None
Definition of a function printSpectrumWithOccupations()
for printing a formatted list of molecular eigenenergies including their
respective occupations. The function works for both calculations that are
spin-polarized and not:
def f(x,pad=15): if isinstance(x,int): s = "%i" % x else: s = "%.4g" % x return s.rjust(pad) def printSpectrumWithOccupations(self_consistent_calculation): spectrum = calculateMolecularEnergySpectrum(self_consistent_calculation) energies = spectrum.energies() occ = calculateEigenstateOccupations(self_consistent_calculation) if len(energies.shape)==2: # spin-polarized print ' Spin Up Spin Down' print 'Level Energy (eV) Occupation Energy (eV) Occupation' print '----------------------------------------------------------------' for i in range(energies.shape[1]): print "%s%s%s%s%s" % ( f(i,2), f(energies[0,i].inUnitsOf(eV)),f(occ[0,i]), f(energies[1,i].inUnitsOf(eV)),f(occ[1,i]) ) else: # not spin-polarized print 'Level Energy (eV) Occupation' for i in range(len(energies)): print "%s%s%s" % ( f(i,2),f(energies[i].inUnitsOf(eV)),f(occ[i]) )
The function f()> is used for padding the numbers with
spaces, to make the columns right-justified.
The dimensionality of the returned NumPy array will be:
for spin-polarized molecular calculations;
for unpolarized molecular calculations;
for
spin-polarized bulk calculations;
for unpolarized bulk calculations;
where
is the number of eigenstates (for molecules),
and
is the number of energy bands (for bulk). Note
that the number of k-points,
, refers to
the Monkhorst-Pack sampling used for solving the self-consistent problem, and not
a specific band structure calculation. Use the shape
property to check if the calculation is spin-polarized or not (see example above).
For bulk systems, the dimensionality of the returned NumPy array will be:
for spin-polarized calculations.
for unpolarized calculations.
where
is the number of eigenstates. Use the
shape property to check if the calculation is
spin-polarized or not (see the example shown above).