[docs]defbandgap(procar:str=None,dirname:str=None,outcar:str=None,code:str="vasp",fermi:float=None,repair:bool=True,):"""A function to find the band gap Parameters ---------- procar : str, optional The PROCAR filename, by default None outcar : str, optional The OUTCAR filename, by default None code : str, optional The code name, by default "vasp" fermi : float, optional The fermi energy, by default None repair : bool, optional Boolean to repair the PROCAR file, by default True Returns ------- float Returns the bandgap energy """bandGap=Noneparser=io.Parser(code=code,dirpath=dirname)ebs=parser.ebsiffermiisNone:fermi=ebs.efermibands=np.array(ebs.bands)subBands=np.subtract(bands,fermi)negArr=subBands[subBands<0]posArr=subBands[subBands>0]negVal=np.amax(negArr)posVal=np.amin(posArr)idx=np.where(subBands==negVal)[1][0]ifall(i>=0foriinsubBands[:,idx])orall(i<=0foriinsubBands[:,idx]):possibleGap=posVal-negValifbandGapisNone:bandGap=possibleGapelifpossibleGap<bandGap:bandGap=possibleGapelse:bandGap=0print("Band Gap = %s eV "%str(bandGap))returnbandGap