-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdraw_band1.normal.py
67 lines (55 loc) · 2.17 KB
/
draw_band1.normal.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
from pymatgen.io.vasp.outputs import BSVasprun, Vasprun
from pymatgen.electronic_structure.plotter import BSPlotter
import matplotlib.pyplot as plt
print('Need to run inside a bs_non-self subfolder')
## (1) use vasprun to process data
v = BSVasprun('vasprun.xml')
bs = v.get_band_structure(kpoints_filename="KPOINTS",line_mode=True)
print('Fermi level in bs_non-self/ OUTCAR is ', bs.efermi) # print the fermi level
parent_efermi=Vasprun("../vasprun.xml").efermi
print('efermi in scf is %s' % (parent_efermi) )
bs.efermi=parent_efermi
print('shift Fermi level to be consistent as %.5f' % (bs.efermi) )
## (2) use plotter to get the plot
bsplot = BSPlotter(bs)
ticks=bsplot.get_ticks()
print(ticks)
# if want to show legends, change in this bs_labels. Use ax_legend() to omit showing this label
zero_to_efermi=True
bsplot.get_plot(ylim=(-6, 10), zero_to_efermi=zero_to_efermi) #, bs_labels=['wBeO']
## (3) add some plot features
ax = plt.gca()
#### omit showing legend
ax.get_legend().remove()
#### remove legend with this command
#ax.legend(fontsize=16)#, loc="upper left") # remove legend like 'band 0 up' # will get 'No handles with labels found to put in legend.'
#### labels of x and y axis
ax.set_xlabel('Wave Vector',rotation=0)
ax.set_ylabel('', rotation=0) # energies (eV) '$\mathrm{E}-\mathrm{E}_\mathrm{VBM} (eV)$' ,rotation=270
#### put y labels on the right
#ax.yaxis.set_label_position('right') # position of labels
#ax.yaxis.tick_right() # put the ticks on the right hand side
#### tick size
plt.yticks(fontsize=22)
#### set title
ax.set_title("Band Structure", fontsize=25)
#### Draw a horizontal line to represent fermi level when zero_to_efermi=True
if zero_to_efermi:
xlim = ax.get_xlim()
ax.hlines(0, xlim[0], xlim[1], linestyles="dashed", color="black")
ylimit=None
####################################
#### HERE!!! set ylimit
ylimit=[-5,9] ## Material project
#ylimit=[-1,0.5] ##cd3as2
#ylimit=[-2,1] ## BaMnSb2
#ylimit=[-1.5,1.5] ## 135
#ylimit=[-5,2]
####################################
if ylimit:
plt.ylim(ylimit)
## (4) save the plot
plt.tight_layout()
plt.savefig('bandstructure.pdf',dpi=600)
print('figure generated: bandstructure.pdf')
#bsplot.save_plot('bandstructure.png')