Skip to content

A bug in banstructure.py script #1

@uwhbliu

Description

@uwhbliu

Hi Germain,
Thank you for your nice code. I want to report a bug and also ask a question about the bandstructure.py script.
In line 504,
make_dos_plot(ax0, dosrun, Spin.down, **dosopt, reverse=True)
There is an error "Invalid syntax", I think it should be changed to
make_dos_plot(ax0, dosrun, Spin.down, reverse=True, **dosopt)
to match the augment sequence when you define the function.

Another question is about the element projected DOS.
In my system, I have 5 elements, so I use elements = [mg.Element("Pb"), mg.Element("I"), mg.Element("C"),mg.Element("N"),mg.Element("H")] before I call the bands_plot,
However, I got an index error as follow:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
/Users/hbliu/vasp_bandos_plot.py in <module>()
    553                make_dos_plot=make_el_dos_plot, figsize=(11.69, 8.27),
    554                bandopt=bandopt, dosopt=dosopt, ylim=(-7, 3),
--> 555                legendopt=legendopt)

/Users/hbliu/vasp_bandos_plot.py in bands_plot(bandpath, dospath, make_bs_plot, make_dos_plot, title, figsize, ylim, bandopt, dosopt, legendopt)
    488     # band structure plot
    489     print("Making band structure plot")
--> 490     make_bs_plot(ax1, bands, yticklabels=yticklabels, **bandopt)
    491 
    492     # Density of states plot

/Users/hbliu/vasp_bandos_plot.py in make_el_band_plot(ax, bands, yticklabels, **kargs)
    405 
    406         # compute s, p, d normalized contributions
--> 407         contrib = compute_contrib_el(bands, spin, elements)
    408 
    409         # plot bands

/Users/hbliu/vasp_bandos_plot.py in compute_contrib_el(bands, spin, elements)
    292             for i, el in enumerate(elements):
    293                 if tot != 0.0:
--> 294                     contrib[b, k, i] = elbands[spin][b][k][el.symbol]**2 / tot
    295 
    296     return contrib

IndexError: index 3 is out of bounds for axis 2 with size 3 

Then I changed contrib = np.zeros((bands.nb_bands, len(bands.kpoints), 3)) to contrib = np.zeros((bands.nb_bands, len(bands.kpoints), 5)) in compute_contrib_el, this time I successfully make the plot, however there are only three legends of the elements. The last two elements are missing. Do you know which part of the code should I modify to adapt the system with more atoms? Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions