I am trying to plot DOS (density of states) with pymatgen but I can't make it work. First time encountering self
and class
functions in python so I am at a loss.
This link explains the package that has the function I need (I need to use get_site_t2g_eg_resolved_dos(site)
part of the class CompleteDos
). This link has the source code for those functions. Looking at the examples found online I have made this code
from pymatgen.electronic_structure.dos import CompleteDos
from pymatgen.electronic_structure.plotter import DosPlotter
from pymatgen.electronic_structure.core import Spin, Orbital
data = CompleteDos.get_site_t2g_eg_resolved_dos
plot = DosPlotter(data)
plot.get_plot(-5,5).show()
That code returns an error and I am sure it's because the function get_site_t2g_eg_resolved_dos
is not used correctly.
Even if you don't know pymatgen with the links provided I think you could help me in the proper way of using the functions, I'd highly appreciate it. Thanks in advance!
Edit: How the code I am trying looks like now, leave both because I am not sure if I am doing things correctly.
from pymatgen.electronic_structure.dos import CompleteDos
from pymatgen.electronic_structure.plotter import DosPlotter
from pymatgen.electronic_structure.core import Spin, Orbital
from pymatgen.io.vasp.outputs import Vasprun, Procar
from pymatgen.core.ion import Ion
vasprun = Vasprun("./vasprun.xml")
pdos = vasprun.pdos
tdos = vasprun.tdos
efermi = vasprun.efermi
energy = vasprun.eigenvalues
structure = vasprun.structures
a = CompleteDos(structure, tdos, pdos)
data = a.get_site_t2g_eg_resolved_dos(structure)
plot = DosPlotter(data)
plot.get_plot().show()
Error in output:
Traceback (most recent call last):
File "t2g2g.py", line 21, in <module>
data= a.get_site_t2g_eg_resolved_dos(structure)
File "/usr/local/lib/python2.7/dist-packages/pymatgen/electronic_structure/dos.py", line 351, in get_site_t2g_eg_resolved_dos
for s, atom_dos in self.pdos.items():
AttributeError: 'list' object has no attribute 'items'