def plot_bands( outcar="OUTCAR", savefig="wannier90_bands.pdf", show=False, elimit=None, compare=False, ): """This method plots wannier bands""" plt.rcParams["mathtext.default"] = "regular" plt.rcParams["font.family"] = "Arial" plt.rc("font", size=22) # controls default text sizes plt.rc("axes", titlesize=22) # fontsize of the axes title plt.rc("axes", labelsize=22) # fontsize of the x and y labels plt.rc("xtick", labelsize=22) # fontsize of the tick labels plt.rc("ytick", labelsize=22) # fontsize of the tick labels # Reading Fermi from OUTCAR fi = open(outcar, "r") for line in fi: if re.search("Fermi energy", line) or re.search("E-fermi", line): line_fermi = line val = re.search(r"(\-?\d+\.?\d*)", line_fermi) EFERMI = float(val.group(1)) fi.close() print("Fermi energy = {:4.4f} eV".format(EFERMI)) # Reading labels fi = open("wannier90_band.gnu", "r") data = fi.read() fi.close() label_line = re.findall(r'xtics\s*\(([\s"A-Z0-9.,|]*)\)', data) label_line_split = label_line[0].split(",") ticks = [] knames = [] for i in label_line_split: knames.append(i.split()[0]) ticks.append(float(i.split()[1])) knames = [i.strip('"') for i in knames] # Getting wannier band data x = [] y = [] with open("wannier90_band.dat", "r") as f: lines = f.readlines() x.append([]) y.append([]) i = 0 for line in lines: if line != " \n": x[i].append(float(line.split()[0])) y[i].append(float(line.split()[1])) else: x.append([]) y.append([]) i += 1 # There sometimes is an extra line in wannier90_band.dat. # We will remove it if it is there. if not x[-1]: x = np.array(x[:-1]) y = np.array(y[:-1]) else: x = np.array(x) y = np.array(y) if not compare: # Plotting fig = plt.figure(figsize=(13, 9)) ax = fig.add_subplot(111) fig.tight_layout() for i in range(len(x)): ax.plot(x[i], y[i] - EFERMI, color="blue") ax.set_xlim(x.min(), x.max()) if elimit: ax.set_ylim(elimit) ax.set_xticks(ticks) ax.set_xticklabels(knames) ax.set_xlabel(r"$k$-path") ax.set_ylabel(r"$E-E_F$ (eV)") ax.axhline(y=0, color="black", ls="--") ax.grid() for xc in ticks: ax.axvline(x=xc, color="k") if show: plt.show() return None, None else: plt.savefig(savefig, bbox_inches="tight") return fig, ax else: # Comparison with DFT bands from PyProcar # Input axis from PyProcar plot to get x axis ticks fig, ax = pyprocar.bandsplot( "PROCAR", outcar=outcar, kpointsfile="KPOINTS", elimit=elimit, mode="plain", color="red", show=False, verbose=False, ) ticks_pyprocar = [ax.lines[-i].get_xdata()[0] for i in range(2, len(ticks) + 2)] ticks_pyprocar.sort() x_new = np.zeros((x.shape), dtype="float64") for ix in range(len(x)): for iix in range(x.shape[1]): x_new[ix, iix] = kpoint_conversion(x[ix, iix], ticks, ticks_pyprocar) # Plotting for i in range(len(x_new)): ax.plot(x_new[i], y[i] - EFERMI, color="blue", linewidth=2) ax.set_xlim(x_new.min(), x_new.max()) if elimit: ax.set_ylim(elimit) ax.set_xticks(ticks) ax.set_xticklabels(knames) ax.set_xlabel(r"$k$-path") ax.set_ylabel(r"$E-E_F$ (eV)") ax.axhline(y=0, color="black", ls="--") ax.grid() # for xc in ticks: # ax.axvline(x=xc, color="k") # legend custom_lines = [ Line2D([0], [0], color="red", lw=2), Line2D([0], [0], color="blue", lw=2), ] plt.legend(custom_lines, ["DFT", "wannier90"]) # replot with PyProcar with new axis if show: savefig = None pyprocar.bandsplot( "PROCAR", outcar=outcar, kpointsfile="KPOINTS", elimit=elimit, mode="plain", color="red", show=show, ax=ax, savefig=savefig, verbose=False, )
import pyprocar pyprocar.bandsplot( procarfile="PROCAR", mode="scatter", atoms=[0], #Si #orbitals=[4, 5, 6, 7, 8], fermi=0.0, show = False, nbands=24, )
import pyprocar pyprocar.bandsplot( 'PROCAR', outcar='OUTCAR', elimit=[-14, 8], kticks=list(range(0, 400, 100)) + [399], # knames = [u'$L$',u'$\\Gamma$',u'$X$',u'$U|K$',u'$\\Gamma$'], cmap='Reds', # mode = 'scatter', # mode = 'atomic', mode='parametric', # markersize = 200, atoms=[1], # orbitals = [0], # orbitals = [1], # orbitals = [2], # orbitals = [3], # orbitals = [1,2,3], # orbitals = [4,5,6,7,8], orbitals=[0, 1, 2, 3, 4, 5, 6, 7, 8], kpointsfile='KPOINTS', )
import pyprocar #plot band structure M-G-K-M pyprocar.bandsplot('PROCAR', outcar='OUTCAR', kticks=[0, 39, 79, 119, 159], knames=['M', 'G', 'K', 'M'], elimit=[-2, 2], mode='plain', color='blue', code='vasp') #plot 2d band structure for e in [0, -0.3, -0.6, -1, -1.2]: pyprocar.fermi2D('2dband2/PROCAR', outcar='2dband2/OUTCAR', st=True, energy=e, noarrow=True, spin=1, code='vasp')
import pyprocar pyprocar.bandsplot( file='../examples/SrVO3/nospin/PROCAR3', mode='parametric', elimit=[-6, 6], orbitals=[4, 5, 6, 7, 8], vmin=0, vmax=1, #code = 'elk', kpointsfile='../examples/SrVO3/nospin/KPOINTS3', outcar='../examples/SrVO3/nospin/OUTCAR3', savefig='../tests/test.pdf')
# NiO procar_file = "/Users/uthpala/project-data/abinit/NiO/PROCAR" abinit_file = "/Users/uthpala/project-data/abinit/NiO/abinit.out" kpoints_file = "/Users/uthpala/project-data/abinit/NiO/KPOINTS" abinit_object = AbinitParser(abinit_output=abinit_file) recLat = abinit_object.reclat procarFile = ProcarParser() procarFile.readFile(procar_file) pyprocar.bandsplot( procar_file, abinit_output=abinit_file, kpointsfile=kpoints_file, code="abinit", mode="plain", elimit=[-20, 20], ) procar_file = "/Users/uthpala/project-data/PyProcar/fermi-surface/abinit/MgB2-G-centered-shifted/PROCAR" abinit_file = "/Users/uthpala/project-data/PyProcar/fermi-surface/abinit/MgB2-G-centered-shifted/abinit.out" abinit_object = AbinitParser(abinit_output=abinit_file) recLat = abinit_object.reclat procarFile = ProcarParser() procarFile.readFile(procar_file) pyprocar.fermi3D( procar_file,
import pyprocar pyprocar.bandsplot( procarfile="PROCAR", mode="scatter", atoms=[0,1], #CO orbitals=[0],#Orbital s fermi=0.0, show=False, nbands=24, #number bands )
import pyprocar import pdb #pdb.set_trace() pyprocar.bandsplot('PROCAR_2',outcar='OUTCAR_2',fermi=8.02,kticks=[0,119,239,359],knames=['G','X','W','K'],mode='parametric',spin='b',external_file='bsq_2.txt',vmin=-11,vmax=0) #pyprocar.bandsplot('PROCAR_3',outcar='OUTCAR_3',fermi=8.20,kticks=[0,39,79,119],knames=['G','X','W','K'],mode='plain',elimit=[-11,16])