Report of a few bugs in YamboElectronsDB
Posted: 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 :
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
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
and compare it with the corresponding output
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
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])
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()
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
Cheers