romerogroup / pyprocar

A Python library for electronic structure pre/post-processing
GNU General Public License v3.0
172 stars 76 forks source link

DOS error when including spin-orbit coupling #92

Open PyFiSciFi opened 1 year ago

PyFiSciFi commented 1 year ago

When attempting to plot the DOS of a band calculation that includes SOC, I get an error 'spin 3' that comes from parsing the vasprun.xml. Error Output: File "C:\Users\alexs\anaconda3\envs\working\lib\site-packages\pyprocar\scriptBandsDosplot.py", line 274, in bandsdosplot dos_plot = DosPlot(dos=vaspxml.dos, structure=vaspxml.structure)

File "C:\Users\alexs\anaconda3\envs\working\lib\site-packages\pyprocar\vaspxml\vaspxml.py", line 99, in dos energies = self.dos_total['energies']

File "C:\Users\alexs\anaconda3\envs\working\lib\site-packages\pyprocar\vaspxml\vaspxml.py", line 127, in dos_total dos_total, labels = self._get_dos_total()

File "C:\Users\alexs\anaconda3\envs\working\lib\site-packages\pyprocar\vaspxml\vaspxml.py", line 62, in _get_dos_total dos_total[self.spins_dict[ispin]] = np.array(

KeyError: 'spin 3'

I don't have this error for the same pyprocar inputs on an equivalent non-SOC calculation. I ran the command:

pyprocar.bandsdosplot(folder + 'PROCAR-rep',outcar=folder+'OUTCAR',elimit=[-1,1], bands_mode='plain',code='vasp',kpointsfile=folder+'KPOINTS',grid=False, kdirect=False,dos_file=folder+'vasprun.xml',dos_mode='plain',dos_spins=[0,1,2,3])

or

pyprocar.dosplot(filename=folder+'vasprun.xml',mode='plain',elimit=[-1, 1],spins=[0,1,2,3], orientation='vertical')

though I have tried it with variations of dos_spins=[0,1] or [0] or [1] or [1,2,3,4] or ['spin 1',[...]].

I notice that throughout my vasprun.xml there is a line that says and also does this for spin 2, spin 3, and spin 4, on separate lines repeated several times. I think this makes sense for an SOC calculation. (Also one place where it has "spin1", "spin2", "spin3", and "spin4", not all in a row but separately.). I assume that's where the "spin 3" error comes from?

So, how can I plot the DOS when SOC is included, or how can you help with this error? Thanks.