16import matplotlib.pyplot
as plt
23from functions_main
import Filename_Generate
24from 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)
124Mesh =
'cyl-small.xml'
127Max_N_Z =
'output_72.txt'
130Conditions_File =
'conditions_80.xml'
133Scheme =
'IterativeStaticCond'
143Compare_Serial =
False
149Parallelisation =
'Hybrid_Socket'
152Compare_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)
167output_path =
'Output/Figures/Max_Min_CG/'
168if 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)
174if not os.path.exists(output_path):
175 os.mkdir(output_path)
177output_path =
'Output/Figures/Stats/'
178if 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)
184if not os.path.exists(output_path):
185 os.mkdir(output_path)
187output_path =
'Output/Figures/Settling_Time/'
188if 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)
194if not os.path.exists(output_path):
195 os.mkdir(output_path)
215Max_Velocity_1_CG = []
216Max_Velocity_2_CG = []
217Max_Velocity_3_CG = []
220Min_Velocity_1_CG = []
221Min_Velocity_2_CG = []
222Min_Velocity_3_CG = []
228for 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)
241for 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)
377max_modes = len(Pressure[len(Timing_Files) - 1]) + 1
383for i
in range(1, max_modes + 1):
396data_mean = [[], [], [], []]
397data_std_dev = [[], [], [], []]
398data_var = [[], [], [], []]
401for 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))
451fig, ax = plt.subplots()
452ax.plot(modes, data_mean[0], label =
'Pressure')
453ax.plot(modes, data_mean[1], label =
'Velocity 1')
454ax.plot(modes, data_mean[2], label =
'Velocity 2')
455ax.plot(modes, data_mean[3], label =
'Velocity 3')
456ax.set_xlabel(
'Plane Number')
458ax.set_title(
'Mean of Maximum Iterations vs Plane Number')
461if (Scheme ==
'IterativeFull' and Mesh ==
'Pipe'):
462 ax.set_ylim([0,1000])
464if (Scheme ==
'IterativeFull' and Mesh ==
'Cylinder'):
465 ax.set_ylim([0,1000])
467if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Pipe'):
470if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Cylinder'):
473fig.savefig(
'Output/Figures/Stats/Max_Mean.png')
477fig, ax = plt.subplots()
478ax.plot(modes, data_std_dev[0], label =
'Pressure')
479ax.plot(modes, data_std_dev[1], label =
'Velocity 1')
480ax.plot(modes, data_std_dev[2], label =
'Velocity 2')
481ax.plot(modes, data_std_dev[3], label =
'Velocity 3')
482ax.set_xlabel(
'Plane Number')
483ax.set_ylabel(
'Standard Deviation')
484ax.set_title(
'Standard Deviation of Maximum Iterations vs Plane Number')
487if (Scheme ==
'IterativeFull' and Mesh ==
'Pipe'):
488 ax.set_ylim([-1,100])
490if (Scheme ==
'IterativeFull' and Mesh ==
'Cylinder'):
493if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Pipe'):
496if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Cylinder'):
499fig.savefig(
'Output/Figures/Stats/Max_Std_Dev.png')
503fig, ax = plt.subplots()
504ax.plot(modes, data_var[0], label =
'Pressure')
505ax.plot(modes, data_var[1], label =
'Velocity 1')
506ax.plot(modes, data_var[2], label =
'Velocity 2')
507ax.plot(modes, data_var[3], label =
'Velocity 3')
508ax.set_xlabel(
'Plane Number')
509ax.set_ylabel(
'Variance')
510ax.set_title(
'Variance of Maximum Iterations vs Plane Number')
512if (Scheme ==
'IterativeFull' and Mesh ==
'Pipe'):
513 ax.set_ylim([-1,100])
515if (Scheme ==
'IterativeFull' and Mesh ==
'Cylinder'):
518if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Pipe'):
521if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Cylinder'):
524fig.savefig(
'Output/Figures/Stats/Max_Variance_Velocity_1.png')
532data_mean = [[], [], [], []]
533data_std_dev = [[], [], [], []]
534data_var = [[], [], [], []]
537for 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))
587fig, ax = plt.subplots()
588ax.plot(modes, data_mean[0], label =
'Pressure')
589ax.plot(modes, data_mean[1], label =
'Velocity 1')
590ax.plot(modes, data_mean[2], label =
'Velocity 2')
591ax.plot(modes, data_mean[3], label =
'Velocity 3')
592ax.set_xlabel(
'Plane Number')
594ax.set_title(
'Mean of Minimum Iterations vs Plane Number')
597if (Scheme ==
'IterativeFull' and Mesh ==
'Pipe'):
598 ax.set_ylim([0,1000])
600if (Scheme ==
'IterativeFull' and Mesh ==
'Cylinder'):
601 ax.set_ylim([0,1000])
603if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Pipe'):
606if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Cylinder'):
609fig.savefig(
'Output/Figures/Stats/Min_Mean.png')
613fig, ax = plt.subplots()
614ax.plot(modes, data_std_dev[0], label =
'Pressure')
615ax.plot(modes, data_std_dev[1], label =
'Velocity 1')
616ax.plot(modes, data_std_dev[2], label =
'Velocity 2')
617ax.plot(modes, data_std_dev[3], label =
'Velocity 3')
618ax.set_xlabel(
'Plane Number')
619ax.set_ylabel(
'Standard Deviation')
620ax.set_title(
'Standard Deviation of Minimum Iterations vs Plane Number')
623if (Scheme ==
'IterativeFull' and Mesh ==
'Pipe'):
624 ax.set_ylim([-1,100])
626if (Scheme ==
'IterativeFull' and Mesh ==
'Cylinder'):
629if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Pipe'):
632if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Cylinder'):
635fig.savefig(
'Output/Figures/Stats/Min_Std_Dev.png')
639fig, ax = plt.subplots()
640ax.plot(modes, data_var[0], label =
'Pressure')
641ax.plot(modes, data_var[1], label =
'Velocity 1')
642ax.plot(modes, data_var[2], label =
'Velocity 2')
643ax.plot(modes, data_var[3], label =
'Velocity 3')
644ax.set_xlabel(
'Plane Number')
645ax.set_ylabel(
'Variance')
646ax.set_title(
'Variance of Minimum Iterations vs Plane Number')
649if (Scheme ==
'IterativeFull' and Mesh ==
'Pipe'):
650 ax.set_ylim([-1,100])
652if (Scheme ==
'IterativeFull' and Mesh ==
'Cylinder'):
655if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Pipe'):
658if (Scheme ==
'IterativeStaticCond' and Mesh ==
'Cylinder'):
661fig.savefig(
'Output/Figures/Stats/Min_Variance_Velocity_1.png')
669modes = [x - 1
for x
in modes]
672for 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)
def Parse_Nektar_Output(Input_Filename, Skip_Steps)
def Filename_Generate(Mesh, Max_N_Z, Conditions_File)
def Find_Nektar_Files(Input_Filename)