-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqe_kpdos.py
83 lines (64 loc) · 2.79 KB
/
qe_kpdos.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/python
#===========================================================================#
# #
# File: plot_kpdos.py #
# Dependence: none #
# Usage: plot k-resolved-pdos from input data #
# Author: Shunhong Zhang <[email protected]> #
# Date: Dec 15, 2016 #
# #
#===========================================================================#
#under development
#import xplot
import os
import matplotlib.pyplot as plot
import matplotlib.cm as cm
from matplotlib.colors import LogNorm
import numpy as np
import argparse
import arguments
import parse
import bzkpt
desc_str = '''plot the k-resolved DOS of crystals.'''
parser = argparse.ArgumentParser(prog='plot_kpdos.py', description = desc_str)
arguments.add_io_arguments(parser)
arguments.add_fig_arguments(parser)
arguments.add_plot_arguments(parser)
parser.add_argument('--sigma',type=float,default=0.001,help='smearing width of the ldos')
parser.add_argument('--nedos',type=float,default= 5000,help='number of grid of the ldos')
parser.add_argument('--contrast',type=float,default=0.07,help='magnify the lods by multiplying the factor')
parser.add_argument('--cmap',type=str,default='hot',help='color map for the plot')
parser.add_argument('--nnkpt',type=int,default=1,help='number of interpolated kpts on the path')
args=parser.parse_args()
if args.efermi==0:
try:
line=os.popen("grep fermi OUTCAR|tail -1").readline()
efermi=float(line.split()[2])
print 'fermi energy is',efermi
except:
print "Note: The fermi energy is 0!"
efermi=args.efermi
prefix='feo'
orb_type={0:'s',1:'p',2:'d'}
efermi=0
filename=prefix+'pdos_atm#2*_wfc#'+str(irob)+'('+orb_type[iorb]+')'
nedos=int(os.popen('wc -l '+filename).readline())-1
f=open(filename,'r')
print f.file()
headline=f.readline().split()
ncolumn=int(len(headline))-2
nspin=(ncolumn-1)/2
data = np.fromfile(f,sep=' ',dtype=float).reshape[nedos,ncolumn]
kpath=np.zeros(nedos)
dos=np.zeros(nedos,nspin)
pdos=np.zeros(nedos,nspin)
kpath=data[:,0]
for ispin in range(nspin):
dos[:,ispin]=data[:,ispin+1]
pdos[:,ispin]=data[:,ispin+2,]
fig, ax = plot.subplots(figsize=args.figsize)
cax = ax.imshow(ldos.T, extent=(kpath[0], kpath[-1], ymin, ymax), cmap=plot.get_cmap(args.cmap),aspect='auto')
fig.tight_layout()
cbar = fig.colorbar(cax,ticks=[np.amin(ldos), (np.amin(ldos)+np.amax(ldos))/2, np.amax(ldos)], orientation='horizontal')
cbar.ax.set_xticklabels(['Low', 'Medium', 'High']) # horizontal colorbar
plot.show()