16 import matplotlib.pyplot
as plt
23 from functions_main
import Filename_Generate
24 from functions_main
import Find_Nektar_Files
34 f = open(Input_Filename,
"r")
51 for i
in range(0, len(a)):
54 if (a[i] ==
'Pressure'):
63 if (count <= Skip_Steps):
66 if (a[i] ==
'Velocity'):
75 if Velocity
is True and plane ==
'0':
83 if plane
in Pressure.keys():
84 Pressure[plane].append(int(a[i + 4]))
87 Pressure[plane] = [int(a[i + 4])]
90 if plane
in Velocity_1.keys():
91 Velocity_1[plane].append(int(a[i + 4]))
94 Velocity_1[plane] = [int(a[i + 4])]
97 if plane
in Velocity_2.keys():
98 Velocity_2[plane].append(int(a[i + 4]))
101 Velocity_2[plane] = [int(a[i + 4])]
104 if plane
in Velocity_3.keys():
105 Velocity_3[plane].append(int(a[i + 4]))
108 Velocity_3[plane] = [int(a[i + 4])]
113 return(Pressure, Velocity_1, Velocity_2, Velocity_3)
124 Mesh =
'cyl-small.xml'
127 Max_N_Z =
'output_72.txt'
130 Conditions_File =
'conditions_80.xml'
133 Scheme =
'IterativeStaticCond'
136 Consider_Modes = [80]
143 Compare_Serial =
False
149 Parallelisation =
'Hybrid_Socket'
152 Compare_Parallel =
True
161 (Mesh_File, Input_Nektar_Max, Conditions, Loc_Serial_Timing_Files, Loc_Parallel_Timing_Files, Benchmark_PBS, MPI_Benchmark, Node_Map) =
Filename_Generate(Mesh, Max_N_Z, Conditions_File)
167 output_path =
'Output/Figures/Max_Min_CG/'
168 if os.path.exists(output_path):
169 cmd_string_clear =
'rm -r Output/Figures/Max_Min_CG/ \n'
170 process = Popen([cmd_string_clear],shell=
True, stdout=PIPE, stdin=PIPE)
172 os.mkdir(output_path)
174 if not os.path.exists(output_path):
175 os.mkdir(output_path)
177 output_path =
'Output/Figures/Stats/'
178 if os.path.exists(output_path):
179 cmd_string_clear =
'rm -r Output/Figures/Stats/ \n'
180 process = Popen([cmd_string_clear],shell=
True, stdout=PIPE, stdin=PIPE)
182 os.mkdir(output_path)
184 if not os.path.exists(output_path):
185 os.mkdir(output_path)
187 output_path =
'Output/Figures/Settling_Time/'
188 if os.path.exists(output_path):
189 cmd_string_clear =
'rm -r Output/Figures/Settling_Time/ \n'
190 process = Popen([cmd_string_clear],shell=
True, stdout=PIPE, stdin=PIPE)
192 os.mkdir(output_path)
194 if not os.path.exists(output_path):
195 os.mkdir(output_path)
215 Max_Velocity_1_CG = []
216 Max_Velocity_2_CG = []
217 Max_Velocity_3_CG = []
220 Min_Velocity_1_CG = []
221 Min_Velocity_2_CG = []
222 Min_Velocity_3_CG = []
228 for i
in range(0, len(Timing_Files)):
229 (pressure, velocity_1, velocity_2, velocity_3) =
Parse_Nektar_Output(Loc_Serial_Timing_Files + Timing_Files[i], Skip_Steps)
231 Pressure.append(pressure)
232 Velocity_1.append(velocity_1)
233 Velocity_2.append(velocity_2)
234 Velocity_3.append(velocity_3)
241 for i
in range(0, len(Timing_Files)):
248 key_P = map(int, Pressure[i].keys())
249 key_V_1 = map(int, Velocity_1[i].keys())
250 key_V_2 = map(int, Velocity_2[i].keys())
251 key_V_3 = map(int, Velocity_3[i].keys())
263 CG_Min_Velocity_1 = []
264 CG_Max_Velocity_1 = []
266 CG_Min_Velocity_2 = []
267 CG_Max_Velocity_2 = []
269 CG_Min_Velocity_3 = []
270 CG_Max_Velocity_3 = []
273 for j
in range(0, len(key_V_2)):
274 CG_Max_Pressure.append(max(Pressure[i][str(key_P[j])]))
275 CG_Min_Pressure.append(min(Pressure[i][str(key_P[j])]))
277 CG_Max_Velocity_1.append(max(Velocity_1[i][str(key_V_1[j])]))
278 CG_Min_Velocity_1.append(min(Velocity_1[i][str(key_V_1[j])]))
280 CG_Max_Velocity_2.append(max(Velocity_2[i][str(key_V_2[j])]))
281 CG_Min_Velocity_2.append(min(Velocity_2[i][str(key_V_2[j])]))
283 CG_Max_Velocity_3.append(max(Velocity_3[i][str(key_V_3[j])]))
284 CG_Min_Velocity_3.append(min(Velocity_3[i][str(key_V_3[j])]))
287 Max_Pressure_CG.append(CG_Max_Pressure)
288 Min_Pressure_CG.append(CG_Min_Pressure)
290 Max_Velocity_1_CG.append(CG_Max_Velocity_1)
291 Min_Velocity_1_CG.append(CG_Min_Velocity_1)
293 Max_Velocity_2_CG.append(CG_Max_Velocity_2)
294 Min_Velocity_2_CG.append(CG_Min_Velocity_2)
296 Max_Velocity_3_CG.append(CG_Max_Velocity_3)
297 Min_Velocity_3_CG.append(CG_Min_Velocity_3)
300 key_P = [x + 1
for x
in key_P]
301 key_V_1 = [x + 1
for x
in key_V_1]
302 key_V_2 = [x + 1
for x
in key_V_2]
303 key_V_3 = [x + 1
for x
in key_V_3]
306 Pressure_Key.append(key_P)
307 Velocity_1_Key.append(key_V_1)
308 Velocity_2_Key.append(key_V_2)
309 Velocity_3_Key.append(key_V_3)
312 savefile =
'Output/Figures/Max_Min_CG/Min_CG' +
'_' + str(Nektar_Modes[i]) +
'.png'
313 title =
'Minimum CG Iterations: ' +
'Planes = ' + str(Nektar_Modes[i])
316 fig, ax = plt.subplots()
317 ax.plot(key_P, CG_Min_Pressure, label =
'Pressure')
318 ax.plot(key_V_1, CG_Min_Velocity_1, label =
'Velocity_1')
319 ax.plot(key_V_2, CG_Min_Velocity_2, label =
'Velocity_2')
320 ax.plot(key_V_3, CG_Min_Velocity_3, label =
'Velocity_3')
321 ax.set_xlabel(
'Plane Number')
322 ax.set_ylabel(
'Minimum CG Iterations')
326 if (Scheme ==
'IterativeFull' and Mesh ==
'Pipe'):
327 ax.set_ylim([0,1000])
329 if (Scheme ==
'IterativeFull' and Mesh ==
'Cylinder'):
330 ax.set_ylim([0,1000])
332 if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Pipe'):
335 if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Cylinder'):
338 fig.savefig(savefile)
342 savefile =
'Output/Figures/Max_Min_CG/Max_CG' +
'_' + str(Nektar_Modes[i]) +
'.png'
343 title =
'Maximum CG Iterations: ' +
'Planes = ' + str(Nektar_Modes[i])
346 fig, ax = plt.subplots()
347 ax.plot(key_P, CG_Max_Pressure, label =
'Pressure')
348 ax.plot(key_V_1, CG_Max_Velocity_1, label =
'Velocity_1')
349 ax.plot(key_V_2, CG_Max_Velocity_2, label =
'Velocity_2')
350 ax.plot(key_V_3, CG_Max_Velocity_3, label =
'Velocity_3')
351 ax.set_xlabel(
'Plane Number')
352 ax.set_ylabel(
'Maximum CG Iterations')
356 if (Scheme ==
'IterativeFull' and Mesh ==
'Pipe'):
357 ax.set_ylim([0,1000])
359 if (Scheme ==
'IterativeFull' and Mesh ==
'Cylinder'):
360 ax.set_ylim([0,1000])
362 if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Pipe'):
365 if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Cylinder'):
369 fig.savefig(savefile)
377 max_modes = len(Pressure[len(Timing_Files) - 1]) + 1
383 for i
in range(1, max_modes + 1):
396 data_mean = [[], [], [], []]
397 data_std_dev = [[], [], [], []]
398 data_var = [[], [], [], []]
401 for j
in range(0, len(Pressure[len(Timing_Files) - 1])):
410 for i
in range(0, len(Timing_Files)):
414 Data_P.append(Max_Pressure_CG[i][j])
419 Data_V_1.append(Max_Velocity_1_CG[i][j])
424 Data_V_2.append(Max_Velocity_2_CG[i][j])
429 Data_V_3.append(Max_Velocity_3_CG[i][j])
434 data_mean[0].append(np.mean(Data_P))
435 data_std_dev[0].append(np.std(Data_P))
436 data_var[0].append(np.var(Data_P))
438 data_mean[1].append(np.mean(Data_V_1))
439 data_std_dev[1].append(np.std(Data_V_1))
440 data_var[1].append(np.var(Data_V_1))
442 data_mean[2].append(np.mean(Data_V_2))
443 data_std_dev[2].append(np.std(Data_V_2))
444 data_var[2].append(np.var(Data_V_2))
446 data_mean[3].append(np.mean(Data_V_3))
447 data_std_dev[3].append(np.std(Data_V_3))
448 data_var[3].append(np.var(Data_V_3))
451 fig, ax = plt.subplots()
452 ax.plot(modes, data_mean[0], label =
'Pressure')
453 ax.plot(modes, data_mean[1], label =
'Velocity 1')
454 ax.plot(modes, data_mean[2], label =
'Velocity 2')
455 ax.plot(modes, data_mean[3], label =
'Velocity 3')
456 ax.set_xlabel(
'Plane Number')
457 ax.set_ylabel(
'Mean')
458 ax.set_title(
'Mean of Maximum Iterations vs Plane Number')
461 if (Scheme ==
'IterativeFull' and Mesh ==
'Pipe'):
462 ax.set_ylim([0,1000])
464 if (Scheme ==
'IterativeFull' and Mesh ==
'Cylinder'):
465 ax.set_ylim([0,1000])
467 if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Pipe'):
470 if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Cylinder'):
473 fig.savefig(
'Output/Figures/Stats/Max_Mean.png')
477 fig, ax = plt.subplots()
478 ax.plot(modes, data_std_dev[0], label =
'Pressure')
479 ax.plot(modes, data_std_dev[1], label =
'Velocity 1')
480 ax.plot(modes, data_std_dev[2], label =
'Velocity 2')
481 ax.plot(modes, data_std_dev[3], label =
'Velocity 3')
482 ax.set_xlabel(
'Plane Number')
483 ax.set_ylabel(
'Standard Deviation')
484 ax.set_title(
'Standard Deviation of Maximum Iterations vs Plane Number')
487 if (Scheme ==
'IterativeFull' and Mesh ==
'Pipe'):
488 ax.set_ylim([-1,100])
490 if (Scheme ==
'IterativeFull' and Mesh ==
'Cylinder'):
493 if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Pipe'):
496 if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Cylinder'):
499 fig.savefig(
'Output/Figures/Stats/Max_Std_Dev.png')
503 fig, ax = plt.subplots()
504 ax.plot(modes, data_var[0], label =
'Pressure')
505 ax.plot(modes, data_var[1], label =
'Velocity 1')
506 ax.plot(modes, data_var[2], label =
'Velocity 2')
507 ax.plot(modes, data_var[3], label =
'Velocity 3')
508 ax.set_xlabel(
'Plane Number')
509 ax.set_ylabel(
'Variance')
510 ax.set_title(
'Variance of Maximum Iterations vs Plane Number')
512 if (Scheme ==
'IterativeFull' and Mesh ==
'Pipe'):
513 ax.set_ylim([-1,100])
515 if (Scheme ==
'IterativeFull' and Mesh ==
'Cylinder'):
518 if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Pipe'):
521 if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Cylinder'):
524 fig.savefig(
'Output/Figures/Stats/Max_Variance_Velocity_1.png')
532 data_mean = [[], [], [], []]
533 data_std_dev = [[], [], [], []]
534 data_var = [[], [], [], []]
537 for j
in range(0, len(Pressure[len(Timing_Files) - 1])):
546 for i
in range(0, len(Timing_Files)):
550 Data_P.append(Min_Pressure_CG[i][j])
555 Data_V_1.append(Min_Velocity_1_CG[i][j])
560 Data_V_2.append(Min_Velocity_2_CG[i][j])
565 Data_V_3.append(Min_Velocity_3_CG[i][j])
570 data_mean[0].append(np.mean(Data_P))
571 data_std_dev[0].append(np.std(Data_P))
572 data_var[0].append(np.var(Data_P))
574 data_mean[1].append(np.mean(Data_V_1))
575 data_std_dev[1].append(np.std(Data_V_1))
576 data_var[1].append(np.var(Data_V_1))
578 data_mean[2].append(np.mean(Data_V_2))
579 data_std_dev[2].append(np.std(Data_V_2))
580 data_var[2].append(np.var(Data_V_2))
582 data_mean[3].append(np.mean(Data_V_3))
583 data_std_dev[3].append(np.std(Data_V_3))
584 data_var[3].append(np.var(Data_V_3))
587 fig, ax = plt.subplots()
588 ax.plot(modes, data_mean[0], label =
'Pressure')
589 ax.plot(modes, data_mean[1], label =
'Velocity 1')
590 ax.plot(modes, data_mean[2], label =
'Velocity 2')
591 ax.plot(modes, data_mean[3], label =
'Velocity 3')
592 ax.set_xlabel(
'Plane Number')
593 ax.set_ylabel(
'Mean')
594 ax.set_title(
'Mean of Minimum Iterations vs Plane Number')
597 if (Scheme ==
'IterativeFull' and Mesh ==
'Pipe'):
598 ax.set_ylim([0,1000])
600 if (Scheme ==
'IterativeFull' and Mesh ==
'Cylinder'):
601 ax.set_ylim([0,1000])
603 if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Pipe'):
606 if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Cylinder'):
609 fig.savefig(
'Output/Figures/Stats/Min_Mean.png')
613 fig, ax = plt.subplots()
614 ax.plot(modes, data_std_dev[0], label =
'Pressure')
615 ax.plot(modes, data_std_dev[1], label =
'Velocity 1')
616 ax.plot(modes, data_std_dev[2], label =
'Velocity 2')
617 ax.plot(modes, data_std_dev[3], label =
'Velocity 3')
618 ax.set_xlabel(
'Plane Number')
619 ax.set_ylabel(
'Standard Deviation')
620 ax.set_title(
'Standard Deviation of Minimum Iterations vs Plane Number')
623 if (Scheme ==
'IterativeFull' and Mesh ==
'Pipe'):
624 ax.set_ylim([-1,100])
626 if (Scheme ==
'IterativeFull' and Mesh ==
'Cylinder'):
629 if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Pipe'):
632 if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Cylinder'):
635 fig.savefig(
'Output/Figures/Stats/Min_Std_Dev.png')
639 fig, ax = plt.subplots()
640 ax.plot(modes, data_var[0], label =
'Pressure')
641 ax.plot(modes, data_var[1], label =
'Velocity 1')
642 ax.plot(modes, data_var[2], label =
'Velocity 2')
643 ax.plot(modes, data_var[3], label =
'Velocity 3')
644 ax.set_xlabel(
'Plane Number')
645 ax.set_ylabel(
'Variance')
646 ax.set_title(
'Variance of Minimum Iterations vs Plane Number')
649 if (Scheme ==
'IterativeFull' and Mesh ==
'Pipe'):
650 ax.set_ylim([-1,100])
652 if (Scheme ==
'IterativeFull' and Mesh ==
'Cylinder'):
655 if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Pipe'):
658 if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Cylinder'):
661 fig.savefig(
'Output/Figures/Stats/Min_Variance_Velocity_1.png')
669 modes = [x - 1
for x
in modes]
672 for i
in range(0, len(modes)):
675 Settling_Deviation_P = []
676 Settling_Deviation_V_1 = []
677 Settling_Deviation_V_2 = []
678 Settling_Deviation_V_3 = []
687 Data_P = Pressure[-1][str(modes[i])]
688 Data_V_1 = Velocity_1[-1][str(modes[i])]
689 Data_V_2 = Velocity_2[-1][str(modes[i])]
690 Data_V_3 = Velocity_3[-1][str(modes[i])]
697 for j
in range(0, len(Data_P) - 50):
700 Settling_Time.append(j)
710 for k
in range(j, j + 50):
711 Data_2_P.append(Data_P[k])
712 Data_2_V_1.append(Data_V_1[k])
713 Data_2_V_2.append(Data_V_2[k])
714 Data_2_V_3.append(Data_V_3[k])
717 Settling_Deviation_P.append(np.std(Data_2_P))
718 Settling_Deviation_V_1.append(np.std(Data_2_V_1))
719 Settling_Deviation_V_2.append(np.std(Data_2_V_2))
720 Settling_Deviation_V_3.append(np.std(Data_2_V_3))
723 Settling_Time = [x + Skip_Steps + 1
for x
in Settling_Time]
726 savefile =
'Output/Figures/Settling_Time/Set_Std_Dev' +
'_' + str(modes[i] + 1) +
'.png'
727 title =
'Standard Deviation vs Timestep Cutoff: ' +
'Plane = ' + str(modes[i] + 1)
730 fig, ax = plt.subplots()
731 ax.plot(Settling_Time, Settling_Deviation_P, label =
'Pressure')
732 ax.plot(Settling_Time, Settling_Deviation_V_1, label =
'Velocity 1')
733 ax.plot(Settling_Time, Settling_Deviation_V_2, label =
'Velocity 2')
734 ax.plot(Settling_Time, Settling_Deviation_V_3, label =
'Velocity 3')
737 ax.set_xlabel(
'Time Step')
738 ax.set_ylabel(
'Standard Deviation')
741 if (Scheme ==
'IterativeFull' and Mesh ==
'Pipe'):
744 if (Scheme ==
'IterativeFull' and Mesh ==
'Cylinder'):
747 if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Pipe'):
750 if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Cylinder'):
753 fig.savefig(savefile)