-
Notifications
You must be signed in to change notification settings - Fork 0
/
vis.py
531 lines (449 loc) · 21.6 KB
/
vis.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import matplotlib.patches as patches
from matplotlib.collections import PatchCollection
from scipy.interpolate import griddata
import numpy as np
import vtk
from vtk.util.numpy_support import vtk_to_numpy
import glob
from collections import namedtuple
from math import pi
import xml.etree.ElementTree
import itertools
ParticlesData = namedtuple('ParticlesData', ['x', 'y', 'angle', 'count','stokes_vel_x','stokes_vel_y','electro_vel_x','electro_vel_y','charge'])
#plt.rc('text', usetex=True)
#plt.rc('font', family='serif')
def get_simulation_data(filename,particle_types=['particles','fibres','dead_particles']):
# load a xml file as input
root = xml.etree.ElementTree.parse(filename).getroot()
ret = []
for particle_type in particle_types:
particles = root.find(particle_type)
position = particles.find('position')
n_particles = int(position.find('count').text)
print 'found',n_particles,'particles'
x = np.zeros(n_particles)
y = np.zeros(n_particles)
for i,xy in enumerate(position.findall('item')):
x[i] = float(xy[0][1].text)
y[i] = float(xy[0][2].text)
angle_xml = particles.find('angle')
angle = np.zeros(n_particles)
for i,a in enumerate(angle_xml.iter('item')):
angle[i] = float(a.text);
count_xml = particles.find('count')
count = np.zeros(n_particles)
for i,c in enumerate(angle_xml.iter('item')):
count[i] = float(c.text);
ret.append(ParticlesData(x,y,angle,count))
return ret
def get_particle_data(filename):
# load a vtk file as input
reader = vtk.vtkXMLUnstructuredGridReader()
reader.SetFileName(filename)
reader.Update()
# Get the coordinates of nodes in the mesh
nodes_vtk_array= reader.GetOutput().GetPoints().GetData()
#The "Temperature" field is the third scalar in my vtk file
angle_vtk_array = reader.GetOutput().GetPointData().GetArray("angle")
angle_numpy_array = vtk_to_numpy(angle_vtk_array)
count_vtk_array = reader.GetOutput().GetPointData().GetArray("count")
count_numpy_array = vtk_to_numpy(count_vtk_array)
stokes_vtk_array = reader.GetOutput().GetPointData().GetArray("stokes_velocity")
stokes_numpy_array = vtk_to_numpy(stokes_vtk_array)
electro_vtk_array = reader.GetOutput().GetPointData().GetArray("electro_velocity")
electro_numpy_array = vtk_to_numpy(electro_vtk_array)
charge_vtk_array = reader.GetOutput().GetPointData().GetArray("charge")
charge_numpy_array = vtk_to_numpy(charge_vtk_array)
#Get the coordinates of the nodes and their temperatures
nodes_nummpy_array = vtk_to_numpy(nodes_vtk_array)
x,y,z= nodes_nummpy_array[:,0] , nodes_nummpy_array[:,1] , nodes_nummpy_array[:,2]
return ParticlesData(x,y,angle_numpy_array,count_numpy_array,stokes_numpy_array[:,0],stokes_numpy_array[:,1],electro_numpy_array[:,0],electro_numpy_array[:,1],charge_numpy_array)
def circles(ax, x, y, s, c='b', vmin=None, vmax=None, **kwargs):
"""
Make a scatter plot of circles.
Similar to plt.scatter, but the size of circles are in data scale.
Parameters
----------
x, y : scalar or array_like, shape (n, )
Input data
s : scalar or array_like, shape (n, )
Radius of circles.
c : color or sequence of color, optional, default : 'b'
`c` can be a single color format string, or a sequence of color
specifications of length `N`, or a sequence of `N` numbers to be
mapped to colors using the `cmap` and `norm` specified via kwargs.
Note that `c` should not be a single numeric RGB or RGBA sequence
because that is indistinguishable from an array of values
to be colormapped. (If you insist, use `color` instead.)
`c` can be a 2-D array in which the rows are RGB or RGBA, however.
vmin, vmax : scalar, optional, default: None
`vmin` and `vmax` are used in conjunction with `norm` to normalize
luminance data. If either are `None`, the min and max of the
color array is used.
kwargs : `~matplotlib.collections.Collection` properties
Eg. alpha, edgecolor(ec), facecolor(fc), linewidth(lw), linestyle(ls),
norm, cmap, transform, etc.
Returns
-------
paths : `~matplotlib.collections.PathCollection`
Examples
--------
a = np.arange(11)
circles(a, a, s=a*0.2, c=a, alpha=0.5, ec='none')
plt.colorbar()
License
--------
This code is under [The BSD 3-Clause License]
(http://opensource.org/licenses/BSD-3-Clause)
"""
if np.isscalar(c):
kwargs.setdefault('color', c)
c = None
if 'fc' in kwargs:
kwargs.setdefault('facecolor', kwargs.pop('fc'))
if 'ec' in kwargs:
kwargs.setdefault('edgecolor', kwargs.pop('ec'))
if 'ls' in kwargs:
kwargs.setdefault('linestyle', kwargs.pop('ls'))
if 'lw' in kwargs:
kwargs.setdefault('linewidth', kwargs.pop('lw'))
# You can set `facecolor` with an array for each patch,
# while you can only set `facecolors` with a value for all.
zipped = np.broadcast(x, y, s)
pats = [patches.Circle((x_, y_), s_)
for x_, y_, s_ in zipped]
collection = PatchCollection(pats, **kwargs)
if c is not None:
c = np.broadcast_to(c, zipped.shape).ravel()
collection.set_array(c)
collection.set_clim(vmin, vmax)
ax.add_collection(collection)
ax.autoscale_view()
plt.draw_if_interactive()
#if c is not None:
#plt.sci(collection)
return collection
def plot_microstructure(fibres,filename):
print 'plotting',filename
fig = plt.figure(figsize=(6, 8))
vis_ax = plt.gca()
#vis_ax.tick_params(axis='both',which='both',bottom='off',top='off',labelbottom='off')
vis_ax.axis('off')
circles(vis_ax,fibres.x,fibres.y,0.3,'k',lw = 0)
vis_ax.add_patch(patches.Rectangle((0,-1),10,12,fill=False))
vis_ax.set_aspect('equal', 'datalim')
vis_ax.set_xlim(-1,11)
vis_ax.set_ylim(-2,12)
plt.tight_layout()
plt.savefig(filename)
plt.close()
def plot_charge(fibres,filename):
print 'plotting',filename
fig = plt.figure(figsize=(6, 8))
vis_ax = plt.gca()
#vis_ax.tick_params(axis='both',which='both',bottom='off',top='off',labelbottom='off')
vis_ax.axis('off')
circles(vis_ax,fibres.x,fibres.y,0.3,c=fibres.charge,lw = 0)
vis_ax.add_patch(patches.Rectangle((0,-1),10,12,fill=False))
vis_ax.set_aspect('equal', 'datalim')
vis_ax.set_xlim(-1,11)
vis_ax.set_ylim(-2,12)
plt.tight_layout()
plt.savefig(filename)
plt.close()
def plot_velocity_fields(fibres,particles,filename,is_stokes):
print 'plotting',filename
fig = plt.figure(figsize=(6, 8))
vis_ax = plt.gca()
#vis_ax.tick_params(axis='both',which='both',bottom='off',top='off',labelbottom='off')
vis_ax.axis('off')
if is_stokes:
circles(vis_ax,fibres.x,fibres.y,0.3,c='k',lw = 0)
else:
circles(vis_ax,fibres.x,fibres.y,0.3,c=fibres.charge,lw = 0)
vis_ax.add_patch(patches.Rectangle((0,-1),10,12,fill=False))
vis_ax.set_aspect('equal', 'datalim')
vis_ax.set_xlim(-1,11)
vis_ax.set_ylim(-2,12)
X = particles.x
Y = particles.y
if is_stokes:
U = particles.stokes_vel_x
V = particles.stokes_vel_y
else:
U = particles.electro_vel_x
V = particles.electro_vel_y
C = np.sqrt(U**2 + V**2)
vis_ax.quiver(X,Y,U,V,C)
plt.tight_layout()
plt.savefig(filename)
plt.close()
def plot_main(particles,fibres,dparticles,filename,just_lhs=False):
print 'plotting',filename
if just_lhs:
fig = plt.figure(figsize=(6, 8))
vis_ax = plt.gca()
else:
fig = plt.figure(figsize=(12, 8))
gs = gridspec.GridSpec(2, 4)
vis_ax = plt.subplot(gs[:, 0:2])
angle_ax = plt.subplot(gs[0, 2:4])
xcoord_ax = plt.subplot(gs[1, 2])
ycoord_ax = plt.subplot(gs[1, 3])
#vis_ax.tick_params(axis='both',which='both',bottom='off',top='off',labelbottom='off')
vis_ax.axis('off')
vis_ax.scatter(particles.x,particles.y,7,'k',lw = 0)
#vis_ax.scatter(fibres.x,fibres.y,300+70*(10-fibres.y),fibres.count,lw = 0)
#vis_ax.scatter(fibres.x,fibres.y,300,fibres.count,lw = 0)
circles(vis_ax,fibres.x,fibres.y,s=0.3,c=fibres.count,lw = 0)
#vis_ax.scatter(dparticles.x,dparticles.y,7,'r',lw = 0)
vis_ax.arrow(0.1, -1.5, 0, 1, head_width=0.1, head_length=0.2, fc='k', ec='k')
vis_ax.arrow(0.1, -1.5, 1, 0, head_width=0.1, head_length=0.2, fc='k', ec='k')
vis_ax.text(-0.3,-0.6,'y')
vis_ax.text(1,-1.9,'x')
vis_ax.set_xlim([0,10])
vis_ax.set_ylim([-1,11])
vis_ax.set_aspect('equal', 'datalim')
if not just_lhs:
angles = dparticles.angle-pi/2
angles[angles<-pi] = 2*pi+angles[angles<-pi]
angle_ax.hist(np.abs(angles),10,range=(0,pi),normed=1,color='r')
angle_ax.set_xlabel('angle to fibre centre')
angle_ax.set_ylabel('normed count')
angle_ax.set_ylim([0,0.7])
angle_ax.set_xlim([0,pi])
angle_ax.set_xticks([0,pi/2,pi])
angle_ax.set_xticklabels(['N','E/W','S'])
xcoord_ax.hist(dparticles.x,10,range=(0,10),normed=1,color='r')
xcoord_ax.set_xlabel('xcoordinate')
xcoord_ax.set_ylabel('normed count')
xcoord_ax.set_ylim([0,0.2])
xcoord_ax.set_xlim([0,10])
ycoord_ax.hist(dparticles.y,10,range=(0,10),normed=1,color='r')
ycoord_ax.set_xlabel('ycoordinate')
ycoord_ax.set_ylabel('normed count')
ycoord_ax.set_ylim([0,0.5])
ycoord_ax.set_xlim([0,10])
plt.tight_layout()
plt.savefig(filename)
plt.close()
def plot_compare_elec(all_random_dparticles,values,filename):
print 'plotting',filename
linewidth = 3
fig = plt.figure(figsize=(8, 8))
gs = gridspec.GridSpec(2, 2)
angle_ax = plt.subplot(gs[0, 0:2])
xcoord_ax = plt.subplot(gs[1, 0])
ycoord_ax = plt.subplot(gs[1, 1])
for random_dparticles,value in zip(all_random_dparticles,values):
angles = random_dparticles.angle-pi/2
angles[angles<-pi] = 2*pi+angles[angles<-pi]
angle_ax.hist(np.abs(angles),10,histtype='step',range=(0,pi),normed=1,label='$\phi_0=%f$'%value,lw=linewidth)
angle_ax.set_xlabel('angle to fibre centre')
angle_ax.set_ylabel('normed count')
angle_ax.set_ylim([0,0.7])
angle_ax.set_xlim([0,pi])
angle_ax.set_xticks([0,pi/2,pi])
angle_ax.set_xticklabels(['N','E/W','S'])
for random_dparticles,value in zip(all_random_dparticles,values):
xcoord_ax.hist(random_dparticles.x,10,range=(0,10),histtype='step',normed=1,label='$\phi_0=%f$'%value,lw=linewidth)
xcoord_ax.set_xlabel('xcoordinate')
xcoord_ax.set_ylabel('normed count')
xcoord_ax.set_ylim([0,0.2])
xcoord_ax.set_xlim([0,10])
for random_dparticles,value in zip(all_random_dparticles,values):
ycoord_ax.hist(random_dparticles.y,10,range=(0,10),histtype='step',normed=1,label='$\phi_0=%f$'%value,lw=linewidth)
ycoord_ax.set_xlabel('ycoordinate')
ycoord_ax.set_ylabel('normed count')
ycoord_ax.set_ylim([0,0.5])
ycoord_ax.set_xlim([0,10])
ycoord_ax.legend(loc='upper left')
plt.tight_layout()
plt.savefig(filename)
plt.close()
def plot_compare(hexagon_dparticles,regular_dparticles,random_dparticles,filename):
print 'plotting',filename
linewidth = 3
fig = plt.figure(figsize=(8, 8))
gs = gridspec.GridSpec(2, 2)
angle_ax = plt.subplot(gs[0, 0:2])
xcoord_ax = plt.subplot(gs[1, 0])
ycoord_ax = plt.subplot(gs[1, 1])
angles = hexagon_dparticles.angle-pi/2
angles[angles<-pi] = 2*pi+angles[angles<-pi]
angle_ax.hist(np.abs(angles),10,histtype='step',range=(0,pi),normed=1,label='hexagon',lw=linewidth)
angles = regular_dparticles.angle-pi/2
angles[angles<-pi] = 2*pi+angles[angles<-pi]
angle_ax.hist(np.abs(angles),10,histtype='step',range=(0,pi),normed=1,label='regular',lw=linewidth)
angles = random_dparticles.angle-pi/2
angles[angles<-pi] = 2*pi+angles[angles<-pi]
angle_ax.hist(np.abs(angles),10,histtype='step',range=(0,pi),normed=1,label='random',lw=linewidth)
angle_ax.set_xlabel('angle to fibre centre')
angle_ax.set_ylabel('normed count')
angle_ax.set_ylim([0,0.7])
angle_ax.set_xlim([0,pi])
angle_ax.set_xticks([0,pi/2,pi])
angle_ax.set_xticklabels(['N','E/W','S'])
xcoord_ax.hist(hexagon_dparticles.x,10,range=(0,10),histtype='step',normed=1,label='hexagon',lw=linewidth)
xcoord_ax.hist(regular_dparticles.x,10,range=(0,10),histtype='step',normed=1,label='regular',lw=linewidth)
xcoord_ax.hist(random_dparticles.x,10,range=(0,10),histtype='step',normed=1,label='random',lw=linewidth)
xcoord_ax.set_xlabel('xcoordinate')
xcoord_ax.set_ylabel('normed count')
xcoord_ax.set_ylim([0,0.2])
xcoord_ax.set_xlim([0,10])
ycoord_ax.hist(hexagon_dparticles.y,10,range=(0,10),histtype='step',normed=1,label='hexagon',lw=linewidth)
ycoord_ax.hist(regular_dparticles.y,10,range=(0,10),histtype='step',normed=1,label='regular',lw=linewidth)
ycoord_ax.hist(random_dparticles.y,10,range=(0,10),histtype='step',normed=1,label='random',lw=linewidth)
ycoord_ax.set_xlabel('ycoordinate')
ycoord_ax.set_ylabel('normed count')
ycoord_ax.set_ylim([0,0.5])
ycoord_ax.set_xlim([0,10])
ycoord_ax.legend(loc='upper left')
plt.tight_layout()
plt.savefig(filename)
plt.close()
random_sims = ['%02drandom'%i for i in range(0,21)]
random_hexagon_sims = ['%02dhexagon'%i for i in range(0,21)]
hexagon_dead_particles_files = sorted(glob.glob('./hexagon_dead_particles*.vtu'))
regular_dead_particles_files = sorted(glob.glob('./regular_dead_particles*.vtu'))
hexagon_fibre_files = sorted(glob.glob('./00hexagon_fibre*.vtu'))
regular_fibre_files = sorted(glob.glob('./regular_fibre*.vtu'))
random_fibre_files = sorted(glob.glob('./00random_fibre*.vtu'))
regular_simulation_files = sorted(glob.glob('./regular_simulation*.xml'))
hexagon_simulation_files = sorted(glob.glob('./hexagon_simulation*.xml'))
random_simulation_files_tmp = []
random_dead_particles_files_tmp = []
for i in random_sims:
random_simulation_files_tmp.append(sorted(glob.glob('./%s_simulation*.xml'%i)))
random_dead_particles_files_tmp.append(sorted(glob.glob('./%s_dead_particles*.vtu'%i)))
random_simulation_files = []
random_dead_particles_files = []
for tpl in itertools.izip(*random_simulation_files_tmp):
random_simulation_files.append(tpl)
for tpl in itertools.izip(*random_dead_particles_files_tmp):
random_dead_particles_files.append(tpl)
random_hexagon_simulation_files_tmp = []
random_hexagon_dead_particles_files_tmp = []
for i in random_hexagon_sims:
random_hexagon_simulation_files_tmp.append(sorted(glob.glob('./%s_simulation*.xml'%i)))
random_hexagon_dead_particles_files_tmp.append(sorted(glob.glob('./%s_dead_particles*.vtu'%i)))
random_hexagon_simulation_files = []
random_hexagon_dead_particles_files = []
for tpl in itertools.izip(*random_hexagon_simulation_files_tmp):
random_hexagon_simulation_files.append(tpl)
for tpl in itertools.izip(*random_hexagon_dead_particles_files_tmp):
random_hexagon_dead_particles_files.append(tpl)
print random_hexagon_dead_particles_files
print hexagon_dead_particles_files
print random_dead_particles_files
if len(hexagon_fibre_files) > 0:
plot_microstructure(get_particle_data(hexagon_fibre_files[0]),'microstructureH.pdf')
plot_charge(get_particle_data(hexagon_fibre_files[0]),'microstructure_charge_H.pdf')
if len(regular_fibre_files) > 0:
plot_microstructure(get_particle_data(regular_fibre_files[0]),'microstructureS.pdf')
plot_charge(get_particle_data(regular_fibre_files[0]),'microstructure_charge_S.pdf')
if len(random_fibre_files) > 0:
plot_microstructure(get_particle_data(random_fibre_files[0]),'microstructureR.pdf')
plot_charge(get_particle_data(random_fibre_files[0]),'microstructure_charge_R.pdf')
#elec_dirs = ['electro_0_0.0', 'electro_1_0.04','electro_1_0.08','electro_1_0.1']
elec0_dirs = ['electro_0_0.0']
elec1_dirs = ['electro_1_0.03_1.0','electro_1_0.06_1.0','electro_1_0.1_1.0']
elec2_dirs = ['electro_2_0.03_1.0','electro_2_0.06_1.0','electro_2_0.1_1.0']
elec_value = [0.0,0.03,0.06,0.1]
elec_hex1 = []
elec_hex2 = []
#for elec_dir in elec0_dirs:
# print elec_dir
# hexagon = get_particle_data('./%s/hexagon_dead_particles19800.vtu'%elec_dir)
# elec_hex1.append(hexagon)
# elec_hex2.append(hexagon)
#for i,elec_dir in enumerate(elec1_dirs+elec2_dirs):
# print elec_dir
# hex_files = sorted(glob.glob('./%s/*hexagon_dead_particles19800.vtu'%elec_dir))
# hexx = ParticlesData(np.zeros(0),np.zeros(0),np.zeros(0),np.zeros(0),np.zeros(0),np.zeros(0),np.zeros(0),np.zeros(0),np.zeros(0))
# for hex_file in hex_files:
# print hex_file
# tmp = get_particle_data(hex_file)
# hexx = ParticlesData(np.concatenate([hexx.x,tmp.x]),
# np.concatenate([hexx.y,tmp.y]),
# np.concatenate([hexx.angle,tmp.angle]),
# np.concatenate([hexx.count,tmp.count]),
# np.concatenate([hexx.stokes_vel_x,tmp.stokes_vel_x]),
# np.concatenate([hexx.stokes_vel_y,tmp.stokes_vel_y]),
# np.concatenate([hexx.electro_vel_x,tmp.electro_vel_x]),
# np.concatenate([hexx.electro_vel_y,tmp.electro_vel_y]),
# np.concatenate([hexx.charge,tmp.charge])
# )
#
# if i >= len(elec1_dirs):
# elec_hex2.append(hexx)
# else:
# elec_hex1.append(hexx)
#
#plot_compare_elec(elec_hex1,elec_value,'compare_elec_hexagon1.pdf')
#plot_compare_elec(elec_hex2,elec_value,'compare_elec_hexagon2.pdf')
#for hexagon_file,regular_file,random_files,i in zip(hexagon_dead_particles_files,regular_dead_particles_files,random_dead_particles_files,range(len(hexagon_dead_particles_files))):
# print hexagon_file
# hexagon = get_particle_data(hexagon_file)
# print regular_file
# regular = get_particle_data(regular_file)
# random = ParticlesData(np.zeros(0),np.zeros(0),np.zeros(0),np.zeros(0),np.zeros(0),np.zeros(0),np.zeros(0),np.zeros(0),np.zeros(0))
# for random_file in random_files:
# print random_file
# tmp = get_particle_data(random_file)
# random = ParticlesData(np.concatenate([random.x,tmp.x]),
# np.concatenate([random.y,tmp.y]),
# np.concatenate([random.angle,tmp.angle]),
# np.concatenate([random.count,tmp.count]),
# np.concatenate([random.stokes_vel_x,tmp.stokes_vel_x]),
# np.concatenate([random.stokes_vel_y,tmp.stokes_vel_y]),
# np.concatenate([random.electro_vel_x,tmp.electro_vel_x]),
# np.concatenate([random.electro_vel_y,tmp.electro_vel_y]),
# np.concatenate([random.charge,tmp.charge])
# )
# plot_compare(hexagon,regular,random,'compare%05d.pdf'%(i))
#for hexagon_file,regular_file,random_files,i in zip(hexagon_simulation_files,regular_simulation_files,random_simulation_files,range(len(hexagon_simulation_files))):
# print hexagon_file
# hexagon, = get_simulation_data(hexagon_file,['dead_particles'])
# print regular_file
# regular, = get_simulation_data(regular_file,['dead_particles'])
# print random_files
# random = ParticlesData(np.zeros(0),np.zeros(0),np.zeros(0),np.zeros(0))
# for random_file in random_files:
# tmp, = get_simulation_data(random_file,['dead_particles'])
# random = ParticlesData(np.concatenate([random.x,tmp.x]),
# np.concatenate([random.y,tmp.y]),
# np.concatenate([random.angle,tmp.angle]),
# np.concatenate([random.count,tmp.count]))
# plot_compare(hexagon,regular,random,'compare%05d.pdf'%(i))
for simtype in ['hexagon','regular']+random_sims+random_hexagon_sims:
#for simtype in ['hexagon']+random_sims:
#for simtype in ['regular']:
print simtype
particles_files = sorted(glob.glob('./%s_particles19800.vtu'%simtype))
fibres_files = sorted(glob.glob('./%s_fibres19800.vtu'%simtype))
dead_particles_files = sorted(glob.glob('./%s_dead_particles19800.vtu'%simtype))
print particles_files
for particles_file,fibres_file,dead_particles_file,i in zip(particles_files,fibres_files,dead_particles_files,range(len(particles_files))):
print particles_file
particles = get_particle_data(particles_file)
print fibres_file
fibres = get_particle_data(fibres_file)
print dead_particles_file
dparticles = get_particle_data(dead_particles_file)
plot_velocity_fields(fibres,particles,'%s_velocity_stokes%05d.pdf'%(simtype,i),True)
plot_velocity_fields(fibres,particles,'%s_velocity_electro%05d.pdf'%(simtype,i),False)
plot_main(particles,fibres,dparticles,'%s_main%05d.pdf'%(simtype,i))
plot_main(particles,fibres,dparticles,'%s_main_just_lhs%05d.pdf'%(simtype,i),True)
#for simtype in ['hexagon','regular']+random_sims:
#for simtype in ['hexagon']+random_sims:
# sim_files = sorted(glob.glob('./%s_simulation*.xml'%simtype))
# for sim_file,i in zip(sim_files,range(len(sim_files))):
# print sim_file
# particles,fibres,dparticles = get_simulation_data(sim_file)
# plot_main(particles,fibres,dparticles,'%s_main%05d.pdf'%(simtype,i))
# plot_main(particles,fibres,dparticles,'%s_main_just_lhs%05d.pdf'%(simtype,i),True)