-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcntchecker.py
executable file
·45 lines (31 loc) · 1.46 KB
/
cntchecker.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
#!/usr/bin/python3
import pandas as pd
def read_dump(filename):
text = open(filename).read().split('ITEM: TIMESTEP')
frames = []
for chunk in text[1:]:
data = pd.DataFrame([line.split() for line in chunk.splitlines()[9:]])
data.columns = ['id', 'type', 'xs', 'ys', 'zs']
data = data.astype({'id':int, 'type':int, 'xs':float, 'ys':float, 'zs':float})
data = data.sort_values('id').reset_index(drop=True)
#print(data)
frames.append(data)
return frames
def read_log(filename):
text = open(filename).read().splitlines()[68:-30]
rowholder = []
for i in range(0, len(text), 5):
#print(text[i][25:31])
t1 = text[i].split()[2]+' '
t2 = text[i+1].split()[2] +' '+text[i+1].split()[5]+' '+text[i+1].split()[8]+' '
t3 = text[i+2].split()[2] +' '+text[i+1].split()[5]+' '+text[i+1].split()[8]+' '
t4 = text[i+3].split()[2] +' '+text[i+1].split()[5]+' '+text[i+1].split()[8]+' '
t5 = text[i+4].split()[2] +' '+text[i+1].split()[5]+' '+text[i+1].split()[8]
row = t1+t2+t3+t4+t5
rowholder.append(row)
data = pd.DataFrame([x.split() for x in rowholder])
data.columns = ['Timestep','TotEng','KinEng','Temp','PotEng','E_bond','E_angle','E_dihed','E_impro','E_vdwl' ,'E_coul','E_long','Press']
print(data)
if __name__ == "__main__":
read_dump('generated/tubes350k/tube00deg/tube.dump')
read_log('generated/tubes350k/tube00deg/log.lammps')