tightbinder.result.Spectrum#

class Spectrum(eigen_energy=None, eigen_states=None, kpoints=None, system=None)[source]#

Bases: object

The Spectrum class is designed to store the results from the Hamiltonian diagonalization, and to perform manipulations on the eigenvectors and eigenvalues and extract information about the system.

Parameters:
  • eigen_energy (ndarray) – Array (n, nk) with the energies for each kpoint stored as columns.

  • eigen_states (ndarray) – Array (nk, n, n) with the eigenvectors for each kpoint.

  • kpoints (ndarray) – Array with kpoints where the Bloch Hamiltonian was evaluated.

  • system (System) – System used in the calculation.

Methods

calculate_average_ipr

Method to compute the average IPR associated to a group of states.

calculate_fermi_energy

Routine to compute the Fermi level energy according to the given filling .

calculate_gap

Routine to compute the gap of a material based on its Fermi level/filling.

calculate_ipr

Method to compute the inverse participation ratio (IPR) from the eigenvectors.

calculate_occupation

Method to compute the occupation for all the states in the spectrum on the specified atoms.

identify_edge_states

Routine to identify edge states according to a given penetration parameter.

is_edge_state

Routine to check if an eigenstate can be regarded as edge state (as in localized at the edge).

plot_along_path

Method to plot the bands along a path in reciprocal space, normally along high symmetry points.

plot_bands

Method to plot bands from diagonalization in the whole Brillouin zone.

plot_bands_w_atomic_occupation

Method to plot bands as function of k, but also as a colormap to show edge occupation of each state.

plot_quantity

Method to plot an array of some quantity for each state in the spectrum as a bar plot

plot_spectrum

Routine to plot all the eigenvalues coming from the Bloch Hamiltonian diagonalization in an ordered way.

rescale_bands_to_fermi_level

Routine to set the Fermi energy to zero.

write_bands_to_file

TODO write_bands_to_file

write_states_to_file

TODO write_states_to_file

calculate_average_ipr(states)[source]#

Method to compute the average IPR associated to a group of states.

Parameters:

states (Union[ndarray, list]) – list with the eigenvectors of the states.

Return type:

List[float]

Returns:

Average IPR of the given states.

calculate_fermi_energy(filling, bottom=True)[source]#

Routine to compute the Fermi level energy according to the given filling . Fermi energy is set systematically in-between the last occupied state and the first unoccupied state (midgap for insulators and approximately last filled for metals).

Parameters:
  • filling (int) – Total number of electrons in the system.

  • bottom (bool) – Whether to set Fermi energy at maximum of valence band, or in the middle between the valence band maximum and the next state (usually the conduction band minimum). Defaults to True.

Return type:

float

Returns:

Value of Fermi energy.

calculate_gap()[source]#

Routine to compute the gap of a material based on its Fermi level/filling.

Return type:

float

Returns:

Gap value.

calculate_ipr()[source]#

Method to compute the inverse participation ratio (IPR) from the eigenvectors.

Return type:

List[float]

Returns:

list with all ipr for all states

calculate_occupation(atom_indices)[source]#

Method to compute the occupation for all the states in the spectrum on the specified atoms.

Parameters:

atom_indices (List[int]) – List with the indices of the atoms where we want to obtain the occupation.

Return type:

ndarray

Returns:

Matrix with the occupations of the states, with the shape of eigen_energy.

identify_edge_states(system, penetration=0.1)[source]#

Routine to identify edge states according to a given penetration parameter. To be used with OBC only.

Parameters:
  • system (System) – System of interest.

  • penetration (float) – Maximum probability allowed for the states to be in non-edge atoms. Defaults to 0.1

Return type:

List[int]

Returns:

List of states located at the edge.

static is_edge_state(state, norbitals, edge_indices, penetration=0.1)[source]#

Routine to check if an eigenstate can be regarded as edge state (as in localized at the edge). TODO: norbitals should be a list with the orbitals for all species.

Parameters:
  • state (ndarray) – Array with coefficients of eigenstate.

  • norbitals (int) – Number of orbitals per atom. NB: Must be changed to list.

  • edge_indices (List[int]) – List with indices of atoms in the edge.

  • penetration (float) – Maximum probability allowed for the state to be in non-edge atoms. Defaults to 0.1

Return type:

bool

Returns:

True or False.

plot_along_path(labels, title='', edge_states=False, rescale=True, ax=None, e_values=[], fontsize=10, linewidth=2, edgecolor='red')[source]#

Method to plot the bands along a path in reciprocal space, normally along high symmetry points.

Parameters:
  • labels (List[str]) – Labels of the High Symmetry Points of the path.

  • title (str) – Title of the plot. Defaults to empty string.

  • edge_states (bool) – Boolean parameter to toggle on or off edge bands in a different color. Edge bands are defined as those immediately above and below the Fermi level. Defaults to False.

  • rescale (bool) – Boolean to rescale the energy spectrum to the Fermi energy. I.e. highest occupied state has energy zero. Defaults to True.

  • ax (Axes) – Axes object from matplotlib to plot bands there. Useful for figures with subplots.

  • e_values (List[float]) – List with two values, [e_min, e_max] to show bands only in that energy range.

  • linewidth (float) – Linewidth. Defaults to 2.

  • fontsize (float) – Adjusts size of lines and text.

  • edgecolor – Color of the edge bands if edge_states=True.

Return type:

None

plot_bands(title='', ax=None)[source]#

Method to plot bands from diagonalization in the whole Brillouin zone.

Parameters:
  • title (str) – Title for plot. Defaults to empty string.

  • ax (Axes) – Axes object. Defaults to None.

Return type:

None

plot_bands_w_atomic_occupation(labels, atom_indices, title='', rescale=True, ax=None, e_values=[], fontsize=10)[source]#

Method to plot bands as function of k, but also as a colormap to show edge occupation of each state.

Parameters:
  • labels – Labels of the High Symmetry Points of the path.

  • atom_indices – List of indices of atoms where we want to measure the occupation.

  • title – Title of the plot. Defaults to empty string.

  • edge_states – Boolean parameter to toggle on or off edge bands in a different color. Edge bands are defined as those immediately above and below the Fermi level. Defaults to False.

  • rescale – Boolean to rescale the energy spectrum to the Fermi energy. I.e. highest occupied state has energy zero. Defaults to True.

  • ax – Axes object from matplotlib to plot bands there. Useful for figures with subplots.

  • e_values – List with two values, [e_min, e_max] to show bands only in that energy range.

  • fontsize – Adjusts size of lines and text.

static plot_quantity(array, name=None, sort=False, ax=None)[source]#

Method to plot an array of some quantity for each state in the spectrum as a bar plot

Parameters:
  • array (Union[list, ndarray]) – Array with values to be plotted.

  • name (str) – Optional title for the plot. Defaults to None.

  • sort (bool) – If True, sorts the values of array. Defaults to False.

  • ax (Axes) – Axes object to plot in.

Return type:

None

plot_spectrum(title='', ax=None, fontsize=10)[source]#

Routine to plot all the eigenvalues coming from the Bloch Hamiltonian diagonalization in an ordered way. Specially suitable for open systems, although it can be used for periodic systems as well.

Parameters:
  • title (str) – Optional title for the plot.

  • ax (Axes) – Matplotlib Axes object to the plot.

  • fontsize (int) – Fontsize for plot labels. Defaults to 10.

Return type:

None

rescale_bands_to_fermi_level()[source]#

Routine to set the Fermi energy to zero.

Return type:

None

write_bands_to_file(file)[source]#

TODO write_bands_to_file

write_states_to_file(file)[source]#

TODO write_states_to_file