Report of a few bugs in YamboElectronsDB

Post here any question you encounter when running the scripts of the yambo-py suite. Post here problem strictly to the python interface as problem coming from the yambo runs should go in the appropriate subforum.

Moderators: palful, amolina, mbonacci

Post Reply
lorenzo.sponza
Posts: 8
Joined: Tue Mar 21, 2023 10:52 am

Report of a few bugs in YamboElectronsDB

Post by lorenzo.sponza » Thu Apr 27, 2023 1:45 pm

Hello everybody,
I think I found some small bugs in YamboElectronsDB

The first is in the method setFermiFixed(), around line 255 :

Code: Select all

nbands = self.nelectrons/self.spin_degen
#top of valence
top = np.max(eigenvalues[:,nbands])
#bottom of conduction
bot = np.max(eigenvalues[:,nbands-1])
Even though nelectrons and spin_degen are integers, in my case nbands is automatically converted to a float. This raises an error when it is used as an index. Moreover, the top and bot variables are not computed correctly as they are (i) inverted and (ii) the bottom conduction is computed as the maximum of the band instead of the minimum. Changing the lines as follows fixes all these errors

Code: Select all

nbands = int( self.nelectrons/self.spin_degen )
#top of valence
top = np.max(eigenvalues[:,nbands-1])
#bottom of conduction
bot = np.min(eigenvalues[:,nbands])
 



Finally I compared the Fermi energy of a gapped material using the methods getFermi and the corrected setFermiFixed. Results are indeed close, but not enough in my opinion. I paid attention to prevent getFermi to set the Fermi level. Please, see the script below

Code: Select all

    yel = YamboElectronsDB(ylat,save=save_path)
    print(yel)
    print('i_v = ', yel.eigenvalues_ibz[:,i_v])
    print('i_c = ', yel.eigenvalues_ibz[:,i_c])
    yel.getFermi(0.00001,setfermi=False)
    print('yel.efermi after calling getFermi(setFermi=False))     = ',yel.efermi)
    yel.setFermiFixed()
    print('yel.efermi after calling the corrected setFermiFixed() = ',yel.efermi)
    yel.energy_gaps()
and compare it with the corresponding output

Code: Select all

======================YamboElectronsDB======================
spin_degen: 2
nelectrons: 208
nbands:   600
nkpoints: 48
i_v =  [-6.097253  -6.0047493 -5.956301  -6.067695  -6.058205  -5.8655705  -6.004752  -5.9562984]
i_c =  [-1.5558    -1.4688548 -1.4170614 -1.5492991 -1.4384433 -1.4240326  -1.468855  -1.417061 ]
print(fermi) added inside getFermi() before return     =  -3.1794028282165527
yel.efermi after calling getFermi(setFermi=False))     =  None
yel.efermi after calling the corrected setFermiFixed() =  -3.7106852531433105
DFT Energy gap: 4.3097706 eV
DFT Direct gap: 4.441538 eV
GW shift:       0.0 eV
Is this inconsistency acceptable within the precision of the algorithms used to find the Fermi level? If not, I hope you will find a way to solve it.
Cheers
Dr. Lorenzo Sponza
- Unversité Paris-Saclay, ONERA, CNRS, Laboratoire d'Etude des Microstructures (LEM)
92322 Châtillon, France
- European Theoretical Spectroscopy Facility (ETSF)
B-4000 Sart Tilman, Liège, Belgium

User avatar
palful
Posts: 68
Joined: Tue Jan 26, 2016 11:23 am
Location: Modena and Milan

Re: Report of a few bugs in YamboElectronsDB

Post by palful » Fri Apr 28, 2023 8:41 am

Hi Lorenzo,

Thank you so much for spotting these issues and providing a detailed analysis. I opened and bug issue on this topic and we will look into it at soon as possible.

Cheers,
Fulvio
Dr. Fulvio Paleari
S3-CNR Institute of Nanoscience and MaX Center
Modena, Italy

Post Reply