forked from zhenming-xu/VASP-3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nebvtst.py
89 lines (72 loc) · 2.51 KB
/
nebvtst.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
82
83
84
85
86
87
88
#!/bin/env python3
import sys
import re
from VASP import execCmd, CmdRrror
from multiprocessing import Pool
energyPattern = re.compile(r'=.*?([-.0-9]+)')
tangentPattern = re.compile(r'([-.0-9]+).*?([-.0-9]+)')
def getInfo(image_folder):
"""
:param image_folder: 00, 01, 02, ...
:return:
"""
cmd = 'grep "free energy " ./%02d/OUTCAR' % image_folder
try:
energy = execCmd(cmd)
except CmdRrror:
print(CmdRrror)
exit(1)
for i in range(len(energy)):
energy[i] = float(energyPattern.search(energy[i]).group(1))
# try:
# cmd = 'grep "distance to prev" ./%02d/OUTCAR' % image_folder
# except CmdRrror:
# print(CmdRrror)
# exit(1)
# dist = execCmd(cmd)
cmd = 'grep "projections on to tangent" ./%02d/OUTCAR' % image_folder
try:
tangent = execCmd(cmd)
except CmdRrror:
print(CmdRrror)
exit(1)
for i in range(len(tangent)):
tangent[i] = float(tangentPattern.search(tangent[i]).group(2))
cmd = 'grep "FORCES: max atom" ./%02d/OUTCAR' % image_folder
try:
force = execCmd(cmd)
except CmdRrror:
print(CmdRrror)
exit(1)
for i in range(len(force)):
force[i] = float(tangentPattern.search(force[i]).group(1))
return [energy, tangent, force]
if len(sys.argv) == 1:
print('')
print('Usage: %s number_of_images' % sys.argv[0].split('/')[-1])
print('')
exit(1)
print('##########This script is used to get information about energy, distance, force##########')
print('')
pool = Pool(4)
folder_ids = [folder_id for folder_id in range(1, int(sys.argv[1]) + 1)]
info = pool.map(getInfo, folder_ids)
best_ret = []
for step in range(len(info[0][0])):
print('step: %d' % (step + 1))
print(' Energy Tangent Max force')
for i, each_info in enumerate(info):
# energy, tangent, force
print('images: %d %10.5f %10.5f %10.5f' % (i + 1, each_info[0][step], each_info[1][step],
each_info[2][step]))
# step, tangent, force
best_ret.append([step + 1, i + 1, abs(each_info[1][step]), each_info[2][step]])
print('')
# sorted by tangent
best_ret.sort(key=lambda x: x[2])
print('')
print('-------------- Best Result --------------')
print(' Step Image_id Tangent Max force')
for i in range(min(10, len(best_ret))):
print('%5d %4d %10.5f %10.5f' % (best_ret[i][0], best_ret[i][1], best_ret[i][2], best_ret[i][3]))
print('')