-
Notifications
You must be signed in to change notification settings - Fork 1
/
analyzeH5.py
63 lines (36 loc) · 1.22 KB
/
analyzeH5.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
from __future__ import print_function
import numpy as np
import sys
import h5py
import matplotlib.pyplot as plt
c=['#000000','#E69F00','#56B4E9','#009E73','#F0E442','#0072B2','#D55E00','#CC79A7']
c=c+c+c+c+c
m=[ 'o', 's', 'v', '<' ,'>', 'D', 'p', (8, 1, 0)]
m=m+m+m+m+m+m
ls=['-', ':', '-.']
ls=ls+ls+ls+ls+ls+ls+ls+ls
def analyze(sim_ID):
print("opening ./{}.h5 ...".format(sim_ID))
h5_file = h5py.File("./{}.h5".format(sim_ID), "r")
time=h5_file['particles/atoms/charge/time']
pos=h5_file['particles/atoms/position/value']
# unwrap particle positions (they are wrapped in the box by default)
pos=np.array(pos) + np.array(h5_file['particles/atoms/image/value'])*np.array(h5_file['particles/atoms/box/edges'])
cations=np.arange(0,n_mono)
cm_x=np.mean(pos[:,cations,0],axis=1)
t=time
return np.array(cm_x), np.array(t)
fig_1 = plt.figure()
ax_1 = fig_1.add_subplot(111)
n_mono=5
if True:
for run_ID in [0]:
sim_ID="electrophoresis-{}N-{}R".format(n_mono, run_ID)
x,t=analyze(sim_ID)
print (x,t)
ax_1.plot(t, x, ls='-')
ax_1.legend(loc='best')
ax_1.set_ylabel(r'$x$ position: $x/\sigma$')
ax_1.set_xlabel(r'time: $ t $')
fig_1.savefig('migrate.pdf')
plt.close(fig_1)