-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathprocess.py
More file actions
67 lines (60 loc) · 1.52 KB
/
process.py
File metadata and controls
67 lines (60 loc) · 1.52 KB
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
#!/global/homes/l/llentz/anaconda3/bin/python
import tempfile
import sys
import glob
import QE
from bandgapoccu import bg as BG
import os
import json
import re
def separate_aimd(fname='scf.out',tempfile='OUT.out',jfile='data.json'):
temp = [zz.split()[2] for zz in open(fname).read().split('\n') if 'temperature' in zz]
temp = [float(zz) for zz in temp if re.match('\d+.\d+$',zz)]
scf = open(fname,'r')
header = ''
for i in scf:
if 'PseudoPot' in i: break
header += i
data = []
rest = header + '\n\n'
tmp = ''
tmp += rest
cnt = 1
try:
for i in scf:
while '! total energy' not in i:
i = next(scf)
tmp += i
#data[cnt] = {}
t_ = {}
OUT = tempfile
output = open(OUT,'w')
output.write(tmp)
output.close()
x = QE.Struct()
x.File_Process(OUT)
atoms,cell = x.return_params()
t_['str'] = x.print()
t_['atoms'] = atoms
t_['cell'] = cell
del x
Gap = BG(OUT)
t_['gap'] = Gap.bg
try:
t_['temp'] = temp[cnt - 1] #[zz for zz in open(str(cnt) + '.out').read().split('\n') if 'temperature' in zz][-1].split()[2]
except:
t_['temp'] = 'NA'
cnt += 1
tmp = rest
data.append(t_)
with open(jfile, 'w') as outfile:
json.dump(data, outfile)
i = next(scf)
continue
scf.close()
except StopIteration:
scf.close()
with open(jfile, 'w') as outfile:
json.dump(data, outfile)
if __name__ == '__main__':
separate_aimd(fname=sys.argv[1])