aiida_vasp.utils.compare_bands#

Utils for comparing band structures.

Utilities for comparing band structures. Mostly present for legacy purposes. Will be rewritten or moved in the future.

Module Contents#

Functions#

_firstspin

Get only the bands for the first spin if multiple are contained.

make_reference_bands_inline

Compare bandstructure results from wannier and vasp.

get_outer_window

Get the outer_window parameter as a tuple (min, max), if it was given.

band_gap

Find the band gap in a bandstructure.

band_error

bands_error

Band for band rms error sqrt((|B1_i - B2_i|^2)/n) where BX_i is the i-th band of Band Structure Node X.

compare_bands

Compare a band structure from vasp with different ones from wannier90 obtained for different window parameters.

compare_from_window_wf

Find the relevant bands in the window workflow and compare them.

plot_errors_vs_iwsize

Plot Band structure errors versus size of the inner window parameter for wannier90.

get_band_properties_from_data

Acquire bands information from BandsData.

get_band_properties

Get some key information about the band structure.

Data#

API#

aiida_vasp.utils.compare_bands.BANDS_CLS = 'DataFactory(...)'#
aiida_vasp.utils.compare_bands._firstspin(bands: numpy.ndarray) numpy.ndarray[source]#

Get only the bands for the first spin if multiple are contained.

aiida_vasp.utils.compare_bands.make_reference_bands_inline(wannier_bands: aiida.orm.BandsData, vasp_bands: aiida.orm.BandsData, efermi: aiida.orm.Float | None = None) dict[str, Any][source]#

Compare bandstructure results from wannier and vasp.

Takes two input array.bands nodes, stores them if they’re not already stored. Takes the relevant bands from the vasp bandstructure and stores and outputs them in a node with linkname ‘bandcmp’.

Also returns a parameter data node with linkname ‘bandinfo’ containing fermi energy, bandgap etc of the reference bandstructure.

aiida_vasp.utils.compare_bands.get_outer_window(bands_node: aiida.orm.BandsData, silent: bool = False) tuple[float, float] | None[source]#

Get the outer_window parameter as a tuple (min, max), if it was given.

Check if bands_node

  • is a child of a calculation and

  • that calculation has a parameter data input node with linkname parameters and

  • that node has the keys ‘dis_win_min’ and ‘dis_win_max’.

If that is the case, output outer_window = (min, max).

aiida_vasp.utils.compare_bands.band_gap(bands: numpy.ndarray, occ: numpy.ndarray, efermi: float | None = None) dict[str, Any][source]#

Find the band gap in a bandstructure.

Parameters:
  • bands (numpy.array) – 2D bands array (as from BandsData.get_bands())

  • occ (numpy.array) – 2D occupations array matching bands

  • efermi (float) – optional: Fermi Energy level

Returns:

{‘gap’: gap energy difference,

’direct’: bool wether it’s a direct band gap ‘vector’: start and end points to draw the band gap as an arrow in the bandstructure plot. the points consist of (k, Dispersion) coordinates }

aiida_vasp.utils.compare_bands.band_error(band1: numpy.ndarray, band2: numpy.ndarray) float[source]#
aiida_vasp.utils.compare_bands.bands_error(bands1: aiida.orm.BandsData, bands2: aiida.orm.BandsData) numpy.ndarray[source]#

Band for band rms error sqrt((|B1_i - B2_i|^2)/n) where BX_i is the i-th band of Band Structure Node X.

Only works for BandsData nodes with 2d band arrays.

aiida_vasp.utils.compare_bands.compare_bands(vasp_bands: aiida.orm.BandsData, wannier_bands_list: list[aiida.orm.BandsData], plot_folder: str | None = None) dict[int, Any][source]#

Compare a band structure from vasp with different ones from wannier90 obtained for different window parameters.

Parameters:
  • vasp_bands – band structure output node from vasp calculation

  • wannier_bands_list – list of band structure output nodes from wannier90 calculations

  • plot_folder – if given, create a plot for each comparison in that folder

Returns:

aiida_vasp.utils.compare_bands.compare_from_window_wf(workflow: aiida.orm.WorkflowNode, **kwargs: Any) dict[int, Any][source]#

Find the relevant bands in the window workflow and compare them.

aiida_vasp.utils.compare_bands.plot_errors_vs_iwsize(comparison_info: dict[int, Any]) tuple[Any, Any][source]#

Plot Band structure errors versus size of the inner window parameter for wannier90.

aiida_vasp.utils.compare_bands.get_band_properties_from_data(bandsdata: aiida.orm.BandsData) dict[str, Any][source]#

Acquire bands information from BandsData.

Parameters:

bandsdata (BandsData) – A BandsData node to be processed

Returns:

Same output as get_band_properties

Return type:

dict

aiida_vasp.utils.compare_bands.get_band_properties(eigenvalues: numpy.ndarray, occupations: numpy.ndarray) dict[str, Any][source]#

Get some key information about the band structure.

Parameters:
  • eigenvalues (np.ndarray) – The eigenvalue array has shape (NS, NB, NK) or (NB, NK), where NS is the number of spins, NB is the number of bands and NK is the number of kpoints.

  • occupations (np.ndarray) – Same format as eigenvalues but instead holds occupation numbers.

Returns:

A dictionary holds information about VBM and CBM locations and bandgaps.

Return type:

dict