Pymatgen Plotting DOS by Orbitals

Hello everyone,

I’m new in this world. I’m running some VASP calculations and I couldn’t find a guide that could help me to plot the DOS file by orbital.

I was able to plot the complete DOS and partial DOS for each atom. However, I would like to see each orbital. Is there a way that I could do that?

Thank you!

To get the overall orbitals dos:

dos_dict = my_complete_dos.get_spd_dos()
for orbital, dos in dos_dict.items():
    plotter.add_dos(dos, label=''{}".format(str(orbital)))
plotter.get_plot()

To get the orbitals for each atom type:

dos_dict = my_complete_dos.get_element_spd_dos()
for species in dos_dict:
    for orbital, dos in dos_dict[species].items():
        plotter.add_dos(dos, label=''{}:{}".format(str(species), str(orbital)))
plotter.get_plot()

To get the orbitals for 1 site (since all sites at once would probably get very messy)

dos_dict = my_complete_dos.get_site_spd_dos(YOUR_SITE_OF_INTEREST)
for orbital, dos in dos_dict.items():
    plotter.add_dos(dos, label=''{}:{}".format(str(YOUR_SITE_OF_INTEREST), str(orbital)))
plotter.get_plot()

Hopefully this gets you started

3 Likes
import matplotlib.pyplot as plt
from pymatgen.io.vasp.outputs import Vasprun
from pymatgen.electronic_structure.plotter import BSDOSPlotter,\
BSPlotter,BSPlotterProjected,DosPlotter

# read vasprun.xml,get band and dos information
bs_vasprun = Vasprun("./vasprun.xml",parse_projected_eigen=True)
bs_data = bs_vasprun.get_band_structure(line_mode=True)

dos_vasprun=Vasprun("./vasprun.xml")
dos_data=dos_vasprun.complete_dos

# set figure parameters, draw figure
pbandpdos_fig = BSDOSPlotter(bs_projection='elements', dos_projection='elements',\
                             vb_energy_range=5, fixed_cb_energy=5)
pbandpdos_fig.get_plot(bs=bs_data, dos=dos_data)
plt.savefig('pbandpdos_fig.png', img_format='png')

from this website:
(pymatgen画能带图方法-高通量计算初探 | 世事如棋)

1 Like

Thank you for your help.

But it doesn’t work. Could you give me an example? I think I made a mistake when I enter the information.

Thanks a lot!