romerogroup / pyprocar

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

Unexpected "stack_orbitals" behavior in dosplot() #149

Closed snark00 closed 5 months ago

snark00 commented 5 months ago

Issue

Using dosplot() in version 6.1.7 with mode="stack_orbitals" results in a DOS profile that sums to the total:

image

After upgrading to version 6.1.9, the DOS profile occasionally does not sum to the total:

image

This appears to be a severe undercounting of the p-orbitals, which are mostly associated the tellurium in this structure: atoms=[a for a in range(48, 96)]

Reproducing

  1. Download and unzip compressed KPOINTS, OUTCAR, POSCAR, PROCAR, and vasprun.xml files. HgTe-run.zip HgTe-PRO.zip HgTe-K-OUT-POS.zip
  2. Have environments ready for both pyprocar version 6.1.7 and 6.1.9 (I used two clean conda environments and swapped kernels in Spyder).
  3. To produce the figures above, I used:
    
    import matplotlib.pyplot as plt
    import pyprocar as pro

vasp_out1 = "./my/data/here/"

figure = plt.figure(dpi=300) ax1 = figure.gca()

pro.dosplot(code="vasp", dirname=vasp_out1, dos_limit=[-80, 80], mode="stack_orbitals",

spins=[0],

        elimit = [-0.2, 1.0],
        ax=ax1,
        fermi=-3.0673,
        show=False)

plt.show()


4. Swap versions and ponder.
lllangWV commented 5 months ago

Thanks for sharing your observations.

I took a closer look at the issues you mentioned with the graphs. The problem originated from the way we normalized the data. Specifically, there was a division by zero error that led to inflated values on the graph. We addressed this in our initial fix, but it seems the issue was not completely resolved until the most recent update.

I replicated your plots using pyprocar==6.1.7 and pyprocar==6.1.9, and noticed the discrepancies with the projections as well. It appears that my results look quite different from yours. To ensure we're aligned, could you confirm if you used any additional or different calculations from the files you provided?

For your reference, here are the plots from pyprocar==6.1.7 and pyprocar==6.1.9:

Below are the plots for pyprocar==6.1.10. Here is the plain mode version: image

Here is the stack_orbital mode version image

The new version 6.1.10 has been pushed to PyPI, and it should be available on Anaconda within the next day or so.

Please let me know if the new version resolves the issue or if there's anything else you'd like to discuss.

Best Regards, Logan Lang

snark00 commented 5 months ago

Good morning,

I should have been more careful - the files I provided were from HgTe with a Hg vacancy, while my plots were for a pristine surface. Regardless, I'm glad you were able to reproduce the issue.

Version 6.1.10 has indeed resolved the issue. As a user for the past few months, it's great to see the package being so well maintained. Thank you!