Projector

class py4vasp.data.Projector(raw_data)

Bases: py4vasp.data._base.DataBase

The projectors used for atom and orbital resolved quantities.

This is a common class used by all quantities that contains some projected quantity, e.g., the electronic band structure and the DOS. It provides utility functionality to access specific indices of the projected arrays based on a simple mini language specifying the atom or orbital names.

Parameters

raw_proj (RawProjector) – Dataclass containing data about the elements, the orbitals, and the spin for which projectors are available.

Methods Summary

from_dict(dict_)

Initialize refinement class from data dictionary

from_file([file])

Read the data dictionary from the given file.

parse_selection(selection)

Generate all possible indices where the projected information is stored.

print()

Print a string representation of this class to standard output.

read([selection, projections])

Read the selected data from an array and store it in a dictionary.

select([atom, orbital, spin])

Map selection strings onto corresponding Selection objects.

to_dict([selection, projections])

Read the selected data from an array and store it in a dictionary.

Methods Documentation

classmethod from_dict(dict_)

Initialize refinement class from data dictionary

Parameters

data_dict (dict) – Data dictionary that contains one or more different raw data sources.

classmethod from_file(file=None)

Read the data dictionary from the given file.

You want to use this method if you want to avoid using the Calculation wrapper, for example because you renamed the output of the VASP calculation.

Parameters

file (str or Path or raw.File) – Filename from which the data is extracted. If not present the default filename is used. Alternatively, you can open the file yourself and pass the File object. In that case, you need to take care the file is properly closed again and be aware the generated instance of this class becomes unusable after the file is closed.

Returns

The returned instance handles opening and closing the file for every function called on it, unless a File object in which case this is left to the user.

Return type

DataBase

parse_selection(selection)

Generate all possible indices where the projected information is stored.

Given a string specifying which atoms, orbitals, and spin should be selected an iterable object is created that contains the indices compatible with the selection.

Parameters
  • selection (str) –

    A string specifying the projection of the orbitals. There are three distinct possibilities:

    • To specify the atom, you can either use its element name (Si, Al, …) or its index as given in the input file (1, 2, …). For the latter option it is also possible to specify ranges (e.g. 1:4).

    • To select a particular orbital you can give a string (s, px, dxz, …) or select multiple orbitals by their angular momentum (s, p, d, f).

    • For the spin, you have the options up, down, or total.

    You separate multiple selections by commas or whitespace and can nest them using parenthesis, e.g. Sr(s, p) or s(up), p(down). The order of the selections does not matter, but it is case sensitive to distinguish p (angular momentum l = 1) from P (phosphorus).

  • source (str, optional) – If you used a KPOINTS_OPT file to use a second k-point mesh, you can provide a keyword argument source=”kpoints_opt” to use the k-points defined in that file instead of the one specified in KPOINTS.

Yields

Iterable[Index] – Indices of the atom, the orbital and the spin compatible with a specific selection.

print()

Print a string representation of this class to standard output.

read(selection=None, projections=None)

Read the selected data from an array and store it in a dictionary.

Parameters
  • selection (str) –

    A string specifying the projection of the orbitals. There are three distinct possibilities:

    • To specify the atom, you can either use its element name (Si, Al, …) or its index as given in the input file (1, 2, …). For the latter option it is also possible to specify ranges (e.g. 1:4).

    • To select a particular orbital you can give a string (s, px, dxz, …) or select multiple orbitals by their angular momentum (s, p, d, f).

    • For the spin, you have the options up, down, or total.

    You separate multiple selections by commas or whitespace and can nest them using parenthesis, e.g. Sr(s, p) or s(up), p(down). The order of the selections does not matter, but it is case sensitive to distinguish p (angular momentum l = 1) from P (phosphorus).

  • projections (np.ndarray or None) – Array containing projected data.

  • source (str, optional) – If you used a KPOINTS_OPT file to use a second k-point mesh, you can provide a keyword argument source=”kpoints_opt” to use the k-points defined in that file instead of the one specified in KPOINTS.

Returns

Dictionary where the label of the selection is linked to a particular column of the array. If a particular selection includes multiple indices these elements are added. If the projections are not present, the relevant indices are returned.

Return type

dict

select(atom='__all__', orbital='__all__', spin='__all__')

Map selection strings onto corresponding Selection objects.

With the selection strings, you specify which atom, orbital, and spin component you are interested in.

Parameters
  • atom (str) – Element name or index of the atom in the input file of Vasp. If a range is specified (e.g. 1:3) a pointer to multiple indices will be created.

  • orbital (str) – Character identifying the angular momentum of the orbital. You may select a specific one (e.g. px) or all of the same character (e.g. d).

  • spin (str) – Select “up” or “down” for a specific spin component or “total” for the sum of both.

  • source (str, optional) – If you used a KPOINTS_OPT file to use a second k-point mesh, you can provide a keyword argument source=”kpoints_opt” to use the k-points defined in that file instead of the one specified in KPOINTS.

Returns

Indices to access the selected projection from an array and an associated label.

Return type

Index

to_dict(selection=None, projections=None)

Read the selected data from an array and store it in a dictionary.

Parameters
  • selection (str) –

    A string specifying the projection of the orbitals. There are three distinct possibilities:

    • To specify the atom, you can either use its element name (Si, Al, …) or its index as given in the input file (1, 2, …). For the latter option it is also possible to specify ranges (e.g. 1:4).

    • To select a particular orbital you can give a string (s, px, dxz, …) or select multiple orbitals by their angular momentum (s, p, d, f).

    • For the spin, you have the options up, down, or total.

    You separate multiple selections by commas or whitespace and can nest them using parenthesis, e.g. Sr(s, p) or s(up), p(down). The order of the selections does not matter, but it is case sensitive to distinguish p (angular momentum l = 1) from P (phosphorus).

  • projections (np.ndarray or None) – Array containing projected data.

  • source (str, optional) – If you used a KPOINTS_OPT file to use a second k-point mesh, you can provide a keyword argument source=”kpoints_opt” to use the k-points defined in that file instead of the one specified in KPOINTS.

Returns

Dictionary where the label of the selection is linked to a particular column of the array. If a particular selection includes multiple indices these elements are added. If the projections are not present, the relevant indices are returned.

Return type

dict