dos

py4vasp.calculation.dos
class py4vasp.calculation._dos.Dos(data_context, **kwargs)

The density of states (DOS) describes the number of states per energy.

The DOS quantifies the distribution of electronic states within an energy range in a material. It provides information about the number of electronic states at each energy level and offers insights into the material’s electronic structure. On-site projections near the atoms (projected DOS) offer a more detailed view. This analysis breaks down the DOS contributions by atom, orbital and spin. Investigating the projected DOS is often a useful step to understand the electronic properties because it shows how different orbitals and elements contribute and influence the material’s properties.

VASP writes the DOS after every calculation and the projected DOS if you set LORBIT in the INCAR file. You can use this class to extract this data. Typically you want to run a non self consistent calculation with a denser mesh for a smoother DOS but the class will work independent of it. If you generated a projected DOS, you can use this class to select which subset of these orbitals to read or plot.

plot(*args, **kwargs)

Wrapper around the to_graph() function.

This will merge multiple graphs if you specify different sources with the selection arguments. All arguments are passed to the wrapped function.

print()

Print a string representation of this instance.

read(*args, **kwargs)

Convenient wrapper around to_dict. Check that function for examples and optional arguments.

selections()

Returns possible alternatives for this particular quantity VASP can produce.

The returned dictionary contains a single item with the name of the quantity mapping to all possible selections. Each of these selection may be passed to other functions of this quantity to select which output of VASP is used.

Returns:

The key indicates this quantity and the values possible choices for arguments to other functions of this quantity.

Return type:

dict

to_csv(*args, filename=None, **kwargs)

Converts data to a csv file.

Writes out a csv file for data stored in a dataframe generated with the to_frame() method. Useful for creating external plots for further analysis.

If no filename is provided a default filename is deduced from the name of the class.

Note that the filename must be a keyword argument, i.e., you explicitly need to write filename=”name_of_file” because the arguments are passed on to the to_graph() function. Please check the documentation of that function to learn which arguments are allowed.

Parameters:

filename (str | Path) – Name of the csv file which the data is exported to.

to_dict(selection=None)

Read the data into a dictionary.

Parameters:

selection (str) –

A string specifying the projection of the orbitals. There are four 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.

  • If you used a different k-point mesh choose “kpoints_opt” or “kpoints_wan” to select them instead of the default mesh specified in the KPOINTS file.

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).

It is possible to add or subtract different components, e.g., a selection of “Ti(d) - O(p)” would project onto the d orbitals of Ti and the p orbitals of O and then compute the difference of these two selections.

If you are unsure about the specific projections that are available, you can use

>>> calc.projector.selections()

to get a list of all available ones.

Returns:

Contains the energies at which the DOS was evaluated aligned to the Fermi energy and the total DOS or the spin-resolved DOS for spin-polarized calculations. If available and a selection is passed, the orbital resolved DOS for the selected orbitals is included.

Return type:

dict

Examples

Select the p orbitals of the first atom in the POSCAR file:

>>> calc.dos.to_dict(selection="1(p)")

Select the d orbitals of Mn, Co, and Fe:

>>> calc.dos.to_dict("d(Mn, Co, Fe)")

Select the spin-up contribution of the first three atoms combined

>>> calc.dos.to_dict("up(1:3)")

Add the contribution of three d orbitals

>>> calc.dos.to_dict("dxy + dxz + dyz")
to_frame(selection=None)

Read the data into a pandas DataFrame.

Parameters:

selection (str) –

A string specifying the projection of the orbitals. There are four 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.

  • If you used a different k-point mesh choose “kpoints_opt” or “kpoints_wan” to select them instead of the default mesh specified in the KPOINTS file.

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).

It is possible to add or subtract different components, e.g., a selection of “Ti(d) - O(p)” would project onto the d orbitals of Ti and the p orbitals of O and then compute the difference of these two selections.

If you are unsure about the specific projections that are available, you can use

>>> calc.projector.selections()

to get a list of all available ones.

Returns:

Contains the energies at which the DOS was evaluated aligned to the Fermi energy and the total DOS or the spin-resolved DOS for spin-polarized calculations. If available and a selection is passed, the orbital resolved DOS for the selected orbitals is included.

Return type:

pd.DataFrame

Examples

Select the p orbitals of the first atom in the POSCAR file:

>>> calc.dos.to_frame(selection="1(p)")

Select the d orbitals of Mn, Co, and Fe:

>>> calc.dos.to_frame("d(Mn, Co, Fe)")

Select the spin-up contribution of the first three atoms combined

>>> calc.dos.to_frame("up(1:3)")

Add the contribution of three d orbitals

>>> calc.dos.to_frame("dxy + dxz + dyz")
to_graph(selection=None)

Generate a graph of the selected data reading it from the VASP output.

Parameters:

selection (str) –

A string specifying the projection of the orbitals. There are four 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.

  • If you used a different k-point mesh choose “kpoints_opt” or “kpoints_wan” to select them instead of the default mesh specified in the KPOINTS file.

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).

It is possible to add or subtract different components, e.g., a selection of “Ti(d) - O(p)” would project onto the d orbitals of Ti and the p orbitals of O and then compute the difference of these two selections.

If you are unsure about the specific projections that are available, you can use

>>> calc.projector.selections()

to get a list of all available ones.

Returns:

Graph containing the total DOS. If the calculation was spin polarized, the resulting DOS is spin resolved and the spin-down DOS is plotted towards negative values. If a selection is given the orbital-resolved DOS is given for the specified projectors.

Return type:

Graph

Examples

Select the p orbitals of the first atom in the POSCAR file:

>>> calc.dos.to_graph(selection="1(p)")

Select the d orbitals of Mn, Co, and Fe:

>>> calc.dos.to_graph("d(Mn, Co, Fe)")

Select the spin-up contribution of the first three atoms combined

>>> calc.dos.to_graph("up(1:3)")

Add the contribution of three d orbitals

>>> calc.dos.to_graph("dxy + dxz + dyz")
to_image(*args, filename=None, **kwargs)

Read the data and generate an image writing to the given filename.

The filetype is automatically deduced from the filename; possible are common raster (png, jpg) and vector (svg, pdf) formats. If no filename is provided a default filename is deduced from the name of the class and the picture has png format.

Note that the filename must be a keyword argument, i.e., you explicitly need to write filename=”name_of_file” because the arguments are passed on to the to_graph() function. Please check the documentation of that function to learn which arguments are allowed.

to_plotly(*args, **kwargs)

Convert the graph of this quantity to a plotly figure.

The arguments to this function are automatically passed on to the to_graph() function. Please check the documentation of that function to learn which arguments are allowed.