Closed Lattay closed 2 weeks ago
Hi @Lattay, thanks for this bug report. Can you confirm that your reciprocal k-points for QE are correct. I see that they span into the neighbouring Brillouin zone (0 to 0.67343506 in fractional coordinates). Is this definitely right?
Actually, I just figured it out. The QE k-points are off by a factor of 1/sqrt(2).
If you update it to:
kpts = data["kpts"] / np.sqrt(2)
That will fix your issue. Also, FYI, the lattice used in the BandStructure
object is supposed to be the reciprocal lattice. It doesn't matter in this case since we're already in fractional coordinates, but a more robust function would look like:
def load_banstructure(path, cart_coords=True):
data = dict(np.load(path, allow_pickle=True))
kpts = data["kpts"] / np.sqrt(2)
lattice = Lattice(data["lattice"])
struct = Structure.from_dict(data["struct"][()])
eigs = data["eigs"]
efermi = data["efermi"]
return BandStructure(
kpts,
{Spin.up: data["eigs"]},
lattice.reciprocal_lattice,
efermi,
structure=struct,
coords_are_cartesian=False
)
Actually, I just figured it out. The QE k-points are off by a factor of 1/sqrt(2).
Oh, that's anoying... thank you for catching that!
Edit: turns out the bug was in the QE reader from ASE: https://gitlab.com/ase/ase/-/merge_requests/3527
Also, FYI, the lattice used in the BandStructure object is supposed to be the reciprocal lattice.
That is what is stored in the (arguably poorly named) data["lattice"]
field.
Describe the bug Despite being able to load data from other codes through the Pymatgen BandStructure object, IFermi produces absurd results when provided with a K mesh different from VASP's.
In particular, I tried to do the same computation in VASP and Quantum-espresso, computing the Fermi surface of metal copper.
With VASP no problem, but with QE I get completely absurd result. I tracked down the problem to the fact that interpolation produce very high and very low energies in all bands, causing each band to intersect the Fermi level.
I am trying to understand what is going wrong in the interpolation, but I think it is related to the fact that QE and VASP uses different IBZ (see following picture).
To Reproduce
from pymatgen.core import Lattice, Structure from pymatgen.electronic_structure.bandstructure import BandStructure, Spin
from ifermi.surface import FermiSurface from ifermi.interpolate import FourierInterpolator from ifermi.plot import FermiSurfacePlotter, show_plot from ifermi.kpoints import kpoints_from_bandstructure
def load_banstructure(path): data = dict(np.load(path, allow_pickle=True)) kpts = data["kpts"] lattice = Lattice(data["lattice"]) struct = Structure.from_dict(data["struct"][()])
def plot_fermi_surface(bs: BandStructure): for i, band in enumerate(bs.bands[Spin.up]): print(np.min(band - bs.efermi), np.max(band - bs.efermi))
if name == "main": if "-h" in sys.argv or "--help" in sys.argv or len(sys.argv) < 2: print("usage: fermi_surface.py")
sys.exit(0)
bs = load_banstructure(sys.argv[1])
plot_fermi_surface(bs)