dosplot#
- pyprocar.scripts.dosplot(code: str = 'vasp', dirname: str | None = None, mode: str = 'plain', orientation: str = 'horizontal', spins: List[int] | None = None, atoms: List[int] | None = None, orbitals: List[int] | None = None, items: dict = {}, normalize_dos_mode: str | None = None, fermi: float | None = None, fermi_shift: float = 0, elimit: List[float] | None = None, dos_limit: List[float] | None = None, savefig: str | None = None, labels: List[str] | None = None, projection_mask=None, ax: Axes | None = None, show: bool = True, print_plot_opts: bool = False, export_data_file: str | None = None, export_append_mode: bool = True, **kwargs)[source]#
This function plots the density of states in different formats
- Parameters:
filename (str, optional (default
'vasprun.xml')) – The most important argument needed dosplot is filename. filename defines the path to vasprun.xml from the density of states calculation. If plotting is being carried out in the directory of the calculation, one does not need to specify this argument.e.g.
filename='~/SrVO3/DOS/vasprun.xml'dirname (str, optional (default
'vasprun.xml')) – This is used for qe and lobster codes. It specifies the directory the dosplot calculation was performed.e.g.
dirname='~/SrVO3/dos'mode (str, optional (default
'plain')) – mode defines the mode of the plot. This parameter will be explained in details with exmaples in the tutorial. options are'plain','parametric','parametric_line','stack','stack_orbitals','stack_species'.e.g.
mode='stack'
- orientationstr, optional (default
horizontal') The orientation of the DOS plot. options are
'horizontal', 'vertical'e.g.
orientation='vertical'- spinslist int, optional
spinsdefines plotting of different spins channels present in the calculation, If the calculation is spin non-polorized the spins will be set by default tospins=[0]. if the calculation is spin polorized this parameter can be set to 0 or 1 or both.e.g.
spins=[0, 1]- atomslist int, optional
atomsdefine the projection of the atoms in the Density of States. In other words it selects only the contribution of the atoms provided. Atoms has to be a python list(or numpy array) containing the atom indices. Atom indices has to be order of the input files of DFT package.atomsis only relevant inmode='parametric',mode='parametric_line',mode='stack_orbitals'. keep in mind that python counting starts from zero. e.g. for SrVO3 we are choosing only the oxygen atoms.atoms=[2, 3, 4], keep in mind that python counting starts from zero, for a POSCAR similar to following:Sr1 V1 O3 1.0 3.900891 0.000000 0.000000 0.000000 3.900891 0.000000 0.000000 0.000000 3.900891 Sr V O 1 1 3 direct 0.500000 0.500000 0.500000 Sr atom 0 0.000000 0.000000 0.000000 V atom 1 0.000000 0.500000 0.000000 O atom 2 0.000000 0.000000 0.500000 O atom 3 0.500000 0.000000 0.000000 O atom 4
if nothing is specified this parameter will consider all the atoms present.
- orbitalslist int, optional
orbitalsdefine the projection of orbitals in the density of States. In other words it selects only the contribution of the orbitals provided. Orbitals has to be a python list(or numpy array) containing the Orbital indices. Orbitals indices has to be order of the input files of DFT package. The following table represents the indecies for different orbitals in VASP.1+-----+-----+----+----+-----+-----+-----+-----+-------+ 2| s | py | pz | px | dxy | dyz | dz2 | dxz | x2-y2 | 3+-----+-----+----+----+-----+-----+-----+-----+-------+ 4| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 5+-----+-----+----+----+-----+-----+-----+-----+-------+
orbitalsis only relavent inmode='parametric',mode='parametric_line',mode='stack_species'.e.g.
orbitals=[1,2,3]will only select the p orbitals whileorbitals=[4,5,6,7,8]will select the d orbitals.If nothing is specified pyprocar will select all the present orbitals.
- normalize_dos_modestr, optional
This defines the mode of the normalization of the density of states. The default is None. If None, the density of states will not be normalized.
- elimitlist float, optional
Energy window limit asked to plot.
elimithas to be a two element python list(or numpy array).e.g.
elimit=[-2, 2]The default is set to the minimum and maximum of the energy window.- dos_limitlist float, optional
dos_limitdefines the density of states axis limits on the graph. It is automatically set to select 10% higher than the maximum of density of states in the specified energy window.e.g.
dos_limit=[0, 30]- labelslist str, optional
labelsis a list of strings that will be used as the legend of the plot. The length of the list should be equal to the number of curves being plotted. If not provided the default labels will be used.- savefigstr , optional (default None)
savefigdefines the file that the plot is going to be saved in.savefigaccepts all the formats accepted by matplotlib such as png, pdf, jpg, … If not provided the plot will be shown in the interactive matplotlib mode.e.g.
savefig='DOS.png',savefig='DOS.pdf'- plot_totalbool, optional (default
True) If the total density of states is plotted as well as other options. The entry should be python boolian.
e.g.
plot_total=True- codestr, optional (default
'vasp') Defines the Density Functional Theory code used for the calculation. The default of this argument is vasp, so if the cal is done in vasp one does not need to define this argumnet.
e.g.
code=vasp,code=elk,code=abinit- itemsdict, optional
itemsis only relavent formode='stack'. stack will plot the items defined with stacked filled areas under curve. For clarification visit the examples in the tutorial.itemsneed to be provided as a python dictionary, with keys being specific species and values being projections oforbitals. The following examples can clarify the python lingo.e.g.
items={'Sr':[0],'O':[1,2,3],'V':[4,5,6,7,8]}oritems=dict(Sr=[0],O=[1,2,3],V=[4,5,6,7,8]). The two examples are equivalent to each other. This will plot the following curves stacked on top of each other. projection of s orbital in Sr, projection of p orbitals in O and projection of d orbitals in V. The default is set to take every atom and every orbital. Which will be equivalent tomode='stack_species'- fermifloat, optional
fermidefines the fermi energy. If not provided the fermi energy will be read from the calculation directory- axmatplotlib ax object, optional
axis a matplotlib axes. In case one wants to put plot generated from this plot in a different figure and treat the output as a subplot in a larger plot.e.g.
>>> # Creates a figure with 3 rows and 2 colomuns >>> fig, axs = plt.subplots(3, 2) >>> x = np.linspace(-np.pi, np.pi, 1000) >>> y = np.sin(x) >>> axs[0, 0].plot(x, y) >>> pyprocar.dosplot(mode='plain',ax=axs[2, 2]),elimit=[-2,2]) >>> plt.show()
- plt_showbool, optional (default
True) whether to show the generated plot or skip to the saving.
e.g.
plt_show=True- export_data_filestr, optional
The file name to export the data to. If not provided the data will not be exported.
- export_append_modebool, optional
Boolean to append the mode to the file name. If not provided the data will be overwritten.
- print_plot_opts: bool, optional
Boolean to print the plotting options
- Returns:
fig (matplotlib figure) – The generated figure
ax (matplotlib ax object) – The generated ax for this density of states. If one chooses
plt_show=False, one can modify the plot using this returned object. e.g.>>> fig, ax = pyprocar.dosplot(mode='plain', plt_show=False) >>> ax.set_ylim(-2,2) >>> fig.show()