From b7f324850e66cf1769afe6e4433dc2790a896a61 Mon Sep 17 00:00:00 2001 From: Junfeng Qiao Date: Fri, 6 Dec 2024 10:17:06 +0100 Subject: [PATCH] Use reference bands to count num valence --- src/aiida_wannier90_workflows/workflows/split.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/aiida_wannier90_workflows/workflows/split.py b/src/aiida_wannier90_workflows/workflows/split.py index b9fcb5f..9d22d8b 100644 --- a/src/aiida_wannier90_workflows/workflows/split.py +++ b/src/aiida_wannier90_workflows/workflows/split.py @@ -396,7 +396,12 @@ def inspect_valcond(self): # pylint: disable=inconsistent-return-statements fermi_energy = get_workchain_fermi_energy(workchain) self.ctx.fermi_energy = fermi_energy - bands: orm.BandsData = workchain.outputs.band_structure + # Prioritize reference bands, since Wannier-interpolated bands might have + # interpolation error + if self.ctx.ref_bands is None: + bands: orm.BandsData = workchain.outputs.band_structure + else: + bands: orm.BandsData = self.ctx.ref_bands bands_arr = bands.get_bands() try: homo, lumo = get_homo_lumo(bands_arr, fermi_energy) @@ -408,7 +413,7 @@ def inspect_valcond(self): # pylint: disable=inconsistent-return-statements if band_gap < gap_threshold: self.report(f"{homo=}, {lumo=}, {band_gap=}, seems metal?") - num_wann = bands.creator.inputs.parameters.get_dict()["num_wann"] + num_wann = workchain.inputs.wannier90.wannier90.parameters["num_wann"] num_val = np.count_nonzero(np.all(bands_arr <= fermi_energy, axis=0)) self.ctx.num_val = num_val self.ctx.num_cond = num_wann - num_val