#!/usr/bin/python # Find the top of the valence band and the bottom of the conduction band from EIGENVAL # Usage: chmod +x gbandedges # gbandedges [path] [ef] # ef: trial Fermi energy # ef read from OUTCAR if not given # Last modified on Jun.21,2014 from sys import argv, exit from os import path from tklib.tkapplication import tkApplication from tklib.tkutils import terminate, pint, pfloat, getarg, getintarg, getfloatarg from tklib.tkcrystal.tkvasp import tkVASP infile = '.' EF = None infile = getarg(1, infile) EF = getfloatarg(2, EF) def usage(): print("Usage: gbandedges_tklib [path] [Ef]") print(" ef: trial Fermi energy") print(" ef will be taken from OUTCAR if not given") exit(0) if len(argv) == 1: app.terminate("", usage = usage, pause = True) app = tkApplication() logfile = 'gbandedges-out.txt' print(f"Open logfile [{logfile}]") app.redirect(targets = ["stdout", logfile], mode = 'w') vasp = tkVASP() CAR_path = vasp.getdir(infile) OUTCAR_path = vasp.get_OUTCAR(CAR_path) EIGENVAL_path = vasp.get_VASPPath(CAR_path, 'EIGENVAL') print("") print("args:", argv) print(f"infile: {infile}") print(f"CAR_path: {CAR_path}") print(f"OUTCAR_path: {OUTCAR_path}") print(f"EIGENVAL_path: {EIGENVAL_path}") if EF is None: print(f"EF will be taken from [{OUTCAR_path}]") else: print(f"EF: {EF} eV") inf = vasp.gbandedges(CAR_path, OUTCAR_path, EIGENVAL_path, EF) if inf is None: app.terminate('', pause = True) print("") print(f"nspin : {inf['nspin']}") print(f"nkpoint : {inf['nkpoint']}") print(f"nband : {inf['nband']}") print(f"nlines : {inf['nlines']}") print("") print(f"Efermi : {inf['EF']:.3f}") print(f"N band : {inf['nband']}") print(f"N kpoint : {inf['nkpoint']}") print(f"N spin : {inf['nspin']}") print("") print(f"Band gap : {inf['Eg']:.3f}") print("") print(f"CBM:") print(f" Energy : {inf['ECBM']:.3f}") print(f" K point: #{inf['ik_CBM']} k={inf['k_CBM']}") print(f" Band : {inf['iband_CBM']}") print(f" Spin : {inf['spin_CBM']}") print("") print(f"VBM:") print(f" Energy : {inf['EVBM']:.3f}") print(f" K point: #{inf['ik_VBM']} k={inf['k_VBM']}") print(f" Band : {inf['iband_VBM']}") print(f" Spin : {inf['spin_VBM']}") app.terminate(pause = True)