forked from benwmcdowell/monitor_VASP_convergence
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_SCF_energies
56 lines (50 loc) · 1.51 KB
/
plot_SCF_energies
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
import matplotlib.pyplot as plt
import sys
import getopt
import numpy as np
def plot_SCF_energies(outcar):
y=[]
with open(outcar) as file:
while True:
line=file.readline()
if not line:
break
line=line.split()
try:
if line[1]=='Iteration' and line[3]=='0)':
y=[]
except IndexError:
pass
if 'energy-change' in line:
if len(line)==6:
y.append(abs(float(line[4][1:])))
if len(line)==7:
y.append(abs(float(line[5])))
if 'EDIFF' in line and line[-1]=='ELM':
ediff=float(line[2])
x=[i for i in range(len(y))]
x=np.array(x)
y=np.array(y)
y=np.log10(y)
plt.figure()
plt.scatter(x,y,label='change in SCF energy')
plt.plot([x[0],x[-1]],[ediff,ediff],linestyle='dashed',label='convergence')
plt.legend()
plt.ylabel('log|change in energy|')
plt.xlabel('number of SCF steps')
plt.show()
if __name__=='__main__':
outcar='./OUTCAR'
try:
opts,args=getopt.getopt(sys.argv[1:],'h',['help'])
except getopt.GetoptError:
print('error in command line syntax')
sys.exit(2)
for i,j in opts:
if i in ['-h','--help']:
print('''
help options:
-h, --help display this help message
''')
sys.exit()
plot_SCF_energies(outcar)