2
$\begingroup$

I am new to using PyProcar and am getting the following error when trying to plot band-structure using it:

Here is my input:

pyprocar.bandsplot('PROCAR-repaired',outcar='OUTCAR',mode='plain',kpointsfile='KPOINTS')

where my KPOINTS file is:

KPOINTS generated by PyProcar
40 ! Grid points
Line_mode
reciprocal
0.000000 0.000000 0.000000 ! GAMMA
0.500000 0.000000 0.000000 ! M

0.500000 0.000000 0.000000 ! M
0.333333 0.333333 0.000000 ! K

0.333333 0.333333 0.000000 ! K
0.000000 0.000000 0.000000 ! GAMMA

My PROCAR-repaired file is very large (I put only 3 bands of 40 bands):

PROCAR lm decomposed
# of k-points:   18         # of bands:   40         # of ions:   10

 k-point     1 :    0.00000000 0.00000000 0.00000000     weight = 0.01000000

band     1 # energy  -14.31028158 # occ.  1.00000000
 
ion      s     py     pz     px    dxy    dyz    dz2    dxz  x2-y2    tot
    1  0.014  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.014
    2  0.014  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.014
    3  0.080  0.000  0.001  0.000  0.000  0.000  0.000  0.000  0.000  0.080
    4  0.080  0.000  0.001  0.000  0.000  0.000  0.000  0.000  0.000  0.080
    5  0.072  0.000  0.001  0.000  0.000  0.000  0.000  0.000  0.000  0.073
    6  0.072  0.000  0.001  0.000  0.000  0.000  0.000  0.000  0.000  0.073
    7  0.072  0.000  0.001  0.000  0.000  0.000  0.000  0.000  0.000  0.073
    8  0.072  0.000  0.001  0.000  0.000  0.000  0.000  0.000  0.000  0.073
    9  0.072  0.000  0.001  0.001  0.000  0.000  0.000  0.000  0.000  0.073
   10  0.072  0.000  0.001  0.001  0.000  0.000  0.000  0.000  0.000  0.073
tot    0.619  0.002  0.005  0.002  0.000  0.000  0.000  0.000  0.000  0.629
 
band     2 # energy  -13.34389563 # occ.  1.00000000
 
ion      s     py     pz     px    dxy    dyz    dz2    dxz  x2-y2    tot
    1  0.000  0.000  0.007  0.000  0.000  0.000  0.000  0.000  0.000  0.007
    2  0.000  0.000  0.007  0.000  0.000  0.000  0.000  0.000  0.000  0.007
    3  0.044  0.000  0.002  0.000  0.000  0.000  0.001  0.000  0.000  0.047
    4  0.044  0.000  0.002  0.000  0.000  0.000  0.001  0.000  0.000  0.047
    5  0.092  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.093
    6  0.092  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.093
    7  0.092  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.093
    8  0.092  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.093
    9  0.092  0.000  0.000  0.001  0.000  0.000  0.000  0.000  0.000  0.093
   10  0.092  0.000  0.000  0.001  0.000  0.000  0.000  0.000  0.000  0.093
tot    0.642  0.002  0.018  0.002  0.000  0.000  0.002  0.000  0.000  0.665
 
band     3 # energy  -12.27910796 # occ.  1.00000000
 
ion      s     py     pz     px    dxy    dyz    dz2    dxz  x2-y2    tot
    1  0.000  0.006  0.000  0.002  0.000  0.000  0.000  0.001  0.001  0.011
    2  0.000  0.006  0.000  0.002  0.000  0.000  0.000  0.001  0.001  0.011
    3  0.000  0.002  0.000  0.005  0.000  0.000  0.000  0.000  0.001  0.008
    4  0.000  0.002  0.000  0.005  0.000  0.000  0.000  0.000  0.001  0.008
    5  0.170  0.000  0.001  0.000  0.000  0.000  0.000  0.000  0.000  0.171
    6  0.170  0.000  0.001  0.000  0.000  0.000  0.000  0.000  0.000  0.171
    7  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000
    8  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000
    9  0.170  0.000  0.001  0.000  0.000  0.000  0.000  0.000  0.000  0.170
   10  0.170  0.000  0.001  0.000  0.000  0.000  0.000  0.000  0.000  0.170
tot    0.679  0.015  0.002  0.014  0.002  0.001  0.000  0.002  0.004  0.719

and I get the following:

Script initiated...
PROCAR repaired. Run with repair=False next time.
code           :  vasp
input file     :  PROCAR-repaired
mode           :  plain
spin comp.     :  0
atoms list     :  [-1]
orbs. list     :  [-1]
fermi energy   :  None
energy range   :  [-2, 2]
colormap       :  jet
markersize     :  0.02
permissive     :  False
vmax           :  None
vmin           :  None
grid enabled   :  True
human          :  False
savefig        :  None
title          :  None
outcar         :  OUTCAR
k-grid         :  reduced
knames         :  ['$\\Gamma$', '$M$', '$K$', '$\\Gamma$']
kticks         :  [0, 39, 79, 119]
Fermi energy   :  -1.6624 eV (from OUTCAR)
spd shape      :  (18, 80, 2, 11, 11) [kpoints, bands, spins, atoms+1, orbitals+2]

with this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dell/anaconda3/lib/python3.9/site-packages/pyprocar/scriptBandsplot.py", line 417, in bandsplot
    fig, ax1 = plot.plotBands(
  File "/home/dell/anaconda3/lib/python3.9/site-packages/pyprocar/procarplot/procarplot.py", line 103, in plotBands
    ticks = [xaxis[x] for x in ticks]
  File "/home/dell/anaconda3/lib/python3.9/site-packages/pyprocar/procarplot/procarplot.py", line 103, in <listcomp>
    ticks = [xaxis[x] for x in ticks]
IndexError: index 39 is out of bounds for axis 0 with size 18

What could be causing this?

$\endgroup$
3
  • $\begingroup$ Without seeing your input, it's tough to say for sure what the problem is. Please edit your question to add the input you used. As an initial guess, it seems like some of the dimensions of the data you passed in are inconsistent with each other. $\endgroup$
    – Tyberius
    Apr 30 at 0:28
  • $\begingroup$ @david please add the input file: PROCAR-repaired as a code block $\endgroup$ Apr 30 at 8:34
  • 1
    $\begingroup$ @david please add the entire PROCAR file. You can add code blocks upto 30000 characters. Without the file it is not possible for anyone to debug your code. And if it is more than 30000 characters then you can upload the file to MMSE GitHub and share the link. Instructions for uploading to MMSE GitHub can be found here $\endgroup$ May 1 at 7:40

1 Answer 1

2
$\begingroup$

Reproducing your error

So I simulated this error using a PROCAR that I could find online here.

I used 90 as the number of grid points per line in the KPOINTS file, since I saw that there are 90 bands in the PROCAR file.

KPOINTS generated by PyProcar
90 ! Grid points
Line_mode
reciprocal
0.000000 0.000000 0.000000 ! GAMMA
0.500000 0.000000 0.000000 ! M

0.500000 0.000000 0.000000 ! M
0.333333 0.333333 0.000000 ! K

0.333333 0.333333 0.000000 ! K
0.000000 0.000000 0.000000 ! GAMMA

Then I tried to plot using:

pyprocar.bandsplot('PROCAR',mode='plain',kpointsfile='KPOINTS')

Then I get an error similar to what you got:

IndexError: index 179 is out of bounds for axis 0 with size 90

Solution

I solved this by reducing the number of grid points per line to 30 in the KPOINTS file.

Then I get a plot that looks like this:

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks so much! It really worked! For, my structure works for 6 grid points per line $\endgroup$ May 1 at 15:24
  • $\begingroup$ @DAVIDMOROCHOPOGO Could you please mark my answer as accepted by clicking the tick next to it? You will also get +2 points :) $\endgroup$ May 1 at 15:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .