Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CG_Iterations.py
Go to the documentation of this file.
1 # Andrew Gloster
2 # Summer 2016
3 # Python Version of Communication Model Implementation
4 # Code to examine CG iteration information generated by Nektar
5 
6 
7 # This code is stand alone and seperate from the main program, its
8 # is for showing the various features in the report relating to the
9 # CG iterations
10 
11 #------------------------------------
12 # Import relevant modules
13 #------------------------------------
14 
15 import os
16 import matplotlib.pyplot as plt
17 import numpy as np
18 
19 #------------------------------------
20 # Import relevant functions
21 #------------------------------------
22 
23 from functions_main import Filename_Generate
24 from functions_main import Find_Nektar_Files
25 
26 #------------------------------------
27 # New Function
28 #------------------------------------
29 
30 # Pharse the Nektar CG iterations information for all modes.
31 def Parse_Nektar_Output(Input_Filename, Skip_Steps):
32 
33  # Open file to be pharsed
34  f = open(Input_Filename, "r")
35 
36  # List for outputs
37  Times = []
38 
39  # We use dictionaries to generate look up tables of the CG information
40  Pressure = {}
41  Velocity_1 = {}
42  Velocity_2 = {}
43  Velocity_3 = {}
44 
45  # Count timestep we're on
46  count = 0
47 
48  # Pharse desired data
49  for line in f:
50  a = line.split()
51  for i in range(0, len(a)):
52 
53  # Iterate the timestep counter every time the file hits 'Pressure'
54  if (a[i] == 'Pressure'):
55  Velocity = False
56 
57  # Var is iterated depending on pressure or velocity being read in
58  var = 1
59  count += 1
60  continue
61 
62  # Skip these time steps as they contain all the start up computations
63  if (count <= Skip_Steps):
64  continue
65 
66  if (a[i] == 'Velocity'):
67  Velocity = True
68  var = 1
69  continue
70 
71  # Record the plane number
72  if (a[i] == 'Plane'):
73  plane = a[i + 1]
74 
75  if Velocity is True and plane == '0':
76  var += 1
77 
78  continue
79 
80  # Append each value of CG to the dictionaries
81  if (a[i] == 'CG'):
82  if (var == 1):
83  if plane in Pressure.keys():
84  Pressure[plane].append(int(a[i + 4]))
85  continue
86  else:
87  Pressure[plane] = [int(a[i + 4])]
88 
89  if (var == 2):
90  if plane in Velocity_1.keys():
91  Velocity_1[plane].append(int(a[i + 4]))
92  continue
93  else:
94  Velocity_1[plane] = [int(a[i + 4])]
95 
96  if (var == 3):
97  if plane in Velocity_2.keys():
98  Velocity_2[plane].append(int(a[i + 4]))
99  continue
100  else:
101  Velocity_2[plane] = [int(a[i + 4])]
102 
103  if (var == 4):
104  if plane in Velocity_3.keys():
105  Velocity_3[plane].append(int(a[i + 4]))
106  continue
107  else:
108  Velocity_3[plane] = [int(a[i + 4])]
109 
110 
111 
112  # Return the dictionaries of CG iteration
113  return(Pressure, Velocity_1, Velocity_2, Velocity_3)
114 
115 #------------------------------------
116 # Functions end here
117 #------------------------------------
118 
119 #------------------------------------
120 # Program begins here
121 #------------------------------------
122 
123 # Input the mesh file name, stored in Input/Mesh/
124 Mesh = 'cyl-small.xml'
125 
126 # Maximum value of N_Z
127 Max_N_Z = 'output_72.txt'
128 
129 # Input the conditions file name stored in Input/Conditions/
130 Conditions_File = 'conditions_80.xml'
131 
132 # Choose the numerical scheme you're using, IterativeFull or IterativeStaticCond
133 Scheme = 'IterativeStaticCond'
134 
135 # Select the values of N_Z you wish to calibrate the model with
136 Consider_Modes = [80]
137 
138 # Choose number of constant to fit to the serial model model, 1 or 2
139 Num_Constants = 2
140 
141 # Do you wish to run the clearcomparison between the calibrated serial model prediction and the collected data.
142 # Set to false if your serial data was collected to a different core than the one you are calibrating for.
143 Compare_Serial = False
144 
145 # Do you wish to run the parallel portion of the model
146 Parallel = True
147 
148 # Choose the Parallelisation method for the model to adopt, Modal, Elemental, Hybrid_Socket or Hybrid_Node
149 Parallelisation = 'Hybrid_Socket'
150 
151 # Do you wish to run the comparison between the full model prediction and the collected data
152 Compare_Parallel = True
153 
154 # Input number of nodes you are using (Can replace this with PBS_Job_Parse)
155 Num_Node = 1
156 
157 #------------------------------------
158 # Generate Input Filename Locations
159 #------------------------------------
160 
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)
162 
163 #------------------------------------
164 # Generate Output Locations
165 #------------------------------------
166 
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)
171  process.wait()
172  os.mkdir(output_path)
173 
174 if not os.path.exists(output_path):
175  os.mkdir(output_path)
176 
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)
181  process.wait()
182  os.mkdir(output_path)
183 
184 if not os.path.exists(output_path):
185  os.mkdir(output_path)
186 
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)
191  process.wait()
192  os.mkdir(output_path)
193 
194 if not os.path.exists(output_path):
195  os.mkdir(output_path)
196 
197 #------------------------------------
198 # Pharse Serial Nektar Inputs
199 #------------------------------------
200 
201 (Nektar_Modes, Timing_Files) = Find_Nektar_Files(Loc_Serial_Timing_Files)
202 
203 # Lists for holding data
204 Pressure = []
205 Velocity_1 = []
206 Velocity_2 = []
207 Velocity_3 = []
208 
209 Pressure_Key = []
210 Velocity_1_Key = []
211 Velocity_2_Key = []
212 Velocity_3_Key = []
213 
214 Max_Pressure_CG = []
215 Max_Velocity_1_CG = []
216 Max_Velocity_2_CG = []
217 Max_Velocity_3_CG = []
218 
219 Min_Pressure_CG = []
220 Min_Velocity_1_CG = []
221 Min_Velocity_2_CG = []
222 Min_Velocity_3_CG = []
223 
224 # Number of timesteps to be skipped by default, contain no useful information
225 Skip_Steps = 20
226 
227 # Phasre the data
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)
230 
231  Pressure.append(pressure)
232  Velocity_1.append(velocity_1)
233  Velocity_2.append(velocity_2)
234  Velocity_3.append(velocity_3)
235 
236 #------------------------------------
237 # Produce plots of Max/Min Iterations
238 #------------------------------------
239 
240 # Loop over files to produce plots of max and min CG iterations
241 for i in range(0, len(Timing_Files)):
242 
243 #------------------------------------
244 # Pressure
245 #------------------------------------
246 
247  # Find the available keys from the relevant dictionary
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())
252 
253  # Sort this list
254  key_P.sort()
255  key_V_1.sort()
256  key_V_2.sort()
257  key_V_3.sort()
258 
259  # Lists for max and min CG iterations
260  CG_Min_Pressure = []
261  CG_Max_Pressure = []
262 
263  CG_Min_Velocity_1 = []
264  CG_Max_Velocity_1 = []
265 
266  CG_Min_Velocity_2 = []
267  CG_Max_Velocity_2 = []
268 
269  CG_Min_Velocity_3 = []
270  CG_Max_Velocity_3 = []
271 
272  # Loop over the relevant data
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])]))
276 
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])]))
279 
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])]))
282 
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])]))
285 
286  # Store the max and min lists for later use
287  Max_Pressure_CG.append(CG_Max_Pressure)
288  Min_Pressure_CG.append(CG_Min_Pressure)
289 
290  Max_Velocity_1_CG.append(CG_Max_Velocity_1)
291  Min_Velocity_1_CG.append(CG_Min_Velocity_1)
292 
293  Max_Velocity_2_CG.append(CG_Max_Velocity_2)
294  Min_Velocity_2_CG.append(CG_Min_Velocity_2)
295 
296  Max_Velocity_3_CG.append(CG_Max_Velocity_3)
297  Min_Velocity_3_CG.append(CG_Min_Velocity_3)
298 
299  # Shift the key so they can be plotted correctly
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]
304 
305  # Store these for later use
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)
310 
311  # Generate Save File and Title
312  savefile = 'Output/Figures/Max_Min_CG/Min_CG' + '_' + str(Nektar_Modes[i]) + '.png'
313  title = 'Minimum CG Iterations: ' + 'Planes = ' + str(Nektar_Modes[i])
314 
315  # Produce the Plot
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')
323  plt.legend(loc=1)
324  ax.set_title(title)
325 
326  if (Scheme == 'IterativeFull' and Mesh == 'Pipe'):
327  ax.set_ylim([0,1000])
328 
329  if (Scheme == 'IterativeFull' and Mesh == 'Cylinder'):
330  ax.set_ylim([0,1000])
331 
332  if (Scheme == 'IterativeStaticCond' and Mesh == 'Pipe'):
333  ax.set_ylim([0,300])
334 
335  if (Scheme == 'IterativeStaticCond' and Mesh == 'Cylinder'):
336  ax.set_ylim([0,300])
337 
338  fig.savefig(savefile)
339  plt.close(fig)
340 
341  # Generate Save File and Title
342  savefile = 'Output/Figures/Max_Min_CG/Max_CG' + '_' + str(Nektar_Modes[i]) + '.png'
343  title = 'Maximum CG Iterations: ' + 'Planes = ' + str(Nektar_Modes[i])
344 
345  # Produce the Plot
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')
353  plt.legend(loc=1)
354  ax.set_title(title)
355 
356  if (Scheme == 'IterativeFull' and Mesh == 'Pipe'):
357  ax.set_ylim([0,1000])
358 
359  if (Scheme == 'IterativeFull' and Mesh == 'Cylinder'):
360  ax.set_ylim([0,1000])
361 
362  if (Scheme == 'IterativeStaticCond' and Mesh == 'Pipe'):
363  ax.set_ylim([0,300])
364 
365  if (Scheme == 'IterativeStaticCond' and Mesh == 'Cylinder'):
366  ax.set_ylim([0,300])
367 
368  ax.set_title(title)
369  fig.savefig(savefile)
370  plt.close(fig)
371 
372 # --------------------------------------
373 # Create a list of all the modes up to maximum
374 # --------------------------------------
375 
376 # Find the max
377 max_modes = len(Pressure[len(Timing_Files) - 1]) + 1
378 
379 # List of the modes
380 modes = []
381 
382 # Generate the data
383 for i in range(1, max_modes + 1):
384 
385  # This mode is never included
386  if (i == 2):
387  continue
388 
389  modes.append(i)
390 
391 # --------------------------------------
392 # Statistics of Max CG Iterations
393 # --------------------------------------
394 
395 # Lists to store the data
396 data_mean = [[], [], [], []]
397 data_std_dev = [[], [], [], []]
398 data_var = [[], [], [], []]
399 
400 # Find the relvant maximums across all the modes and find statistics of these
401 for j in range(0, len(Pressure[len(Timing_Files) - 1])):
402 
403  # List to hold the relvant data
404  Data_P = []
405  Data_V_1 = []
406  Data_V_2 = []
407  Data_V_3 = []
408 
409  # Loop finding the maximums for the given mode
410  for i in range(0, len(Timing_Files)):
411 
412  # Not all have the same number of modes available, hence try used here
413  try:
414  Data_P.append(Max_Pressure_CG[i][j])
415  except:
416  continue
417 
418  try:
419  Data_V_1.append(Max_Velocity_1_CG[i][j])
420  except:
421  continue
422 
423  try:
424  Data_V_2.append(Max_Velocity_2_CG[i][j])
425  except:
426  continue
427 
428  try:
429  Data_V_3.append(Max_Velocity_3_CG[i][j])
430  except:
431  continue
432 
433  # Find the mean, standard deviation and variance
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))
437 
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))
441 
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))
445 
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))
449 
450 # Produce the Plot
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')
459 plt.legend(loc=1)
460 
461 if (Scheme == 'IterativeFull' and Mesh == 'Pipe'):
462  ax.set_ylim([0,1000])
463 
464 if (Scheme == 'IterativeFull' and Mesh == 'Cylinder'):
465  ax.set_ylim([0,1000])
466 
467 if (Scheme == 'IterativeStaticCond' and Mesh == 'Pipe'):
468  ax.set_ylim([0,300])
469 
470 if (Scheme == 'IterativeStaticCond' and Mesh == 'Cylinder'):
471  ax.set_ylim([0,300])
472 
473 fig.savefig('Output/Figures/Stats/Max_Mean.png')
474 plt.close(fig)
475 
476 # Produce the Plot
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')
485 plt.legend(loc=1)
486 
487 if (Scheme == 'IterativeFull' and Mesh == 'Pipe'):
488  ax.set_ylim([-1,100])
489 
490 if (Scheme == 'IterativeFull' and Mesh == 'Cylinder'):
491  ax.set_ylim([-1,50])
492 
493 if (Scheme == 'IterativeStaticCond' and Mesh == 'Pipe'):
494  ax.set_ylim([-1,50])
495 
496 if (Scheme == 'IterativeStaticCond' and Mesh == 'Cylinder'):
497  ax.set_ylim([-1,10])
498 
499 fig.savefig('Output/Figures/Stats/Max_Std_Dev.png')
500 plt.close(fig)
501 
502 # Produce the Plot
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')
511 
512 if (Scheme == 'IterativeFull' and Mesh == 'Pipe'):
513  ax.set_ylim([-1,100])
514 
515 if (Scheme == 'IterativeFull' and Mesh == 'Cylinder'):
516  ax.set_ylim([-1,50])
517 
518 if (Scheme == 'IterativeStaticCond' and Mesh == 'Pipe'):
519  ax.set_ylim([-1,50])
520 
521 if (Scheme == 'IterativeStaticCond' and Mesh == 'Cylinder'):
522  ax.set_ylim([-1,10])
523 
524 fig.savefig('Output/Figures/Stats/Max_Variance_Velocity_1.png')
525 plt.close(fig)
526 
527 # --------------------------------------
528 # Statistics of Min CG Iterations
529 # --------------------------------------
530 
531 # Lists to store the data
532 data_mean = [[], [], [], []]
533 data_std_dev = [[], [], [], []]
534 data_var = [[], [], [], []]
535 
536 # Find the relvant maximums across all the modes and find statistics of these
537 for j in range(0, len(Pressure[len(Timing_Files) - 1])):
538 
539  # List to hold the relvant data
540  Data_P = []
541  Data_V_1 = []
542  Data_V_2 = []
543  Data_V_3 = []
544 
545  # Loop finding the maximums for the given mode
546  for i in range(0, len(Timing_Files)):
547 
548  # Not all have the same number of modes available, hence try used here
549  try:
550  Data_P.append(Min_Pressure_CG[i][j])
551  except:
552  continue
553 
554  try:
555  Data_V_1.append(Min_Velocity_1_CG[i][j])
556  except:
557  continue
558 
559  try:
560  Data_V_2.append(Min_Velocity_2_CG[i][j])
561  except:
562  continue
563 
564  try:
565  Data_V_3.append(Min_Velocity_3_CG[i][j])
566  except:
567  continue
568 
569  # Find the mean, standard deviation and variance
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))
573 
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))
577 
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))
581 
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))
585 
586 # Produce the Plot
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')
595 plt.legend(loc=1)
596 
597 if (Scheme == 'IterativeFull' and Mesh == 'Pipe'):
598  ax.set_ylim([0,1000])
599 
600 if (Scheme == 'IterativeFull' and Mesh == 'Cylinder'):
601  ax.set_ylim([0,1000])
602 
603 if (Scheme == 'IterativeStaticCond' and Mesh == 'Pipe'):
604  ax.set_ylim([0,300])
605 
606 if (Scheme == 'IterativeStaticCond' and Mesh == 'Cylinder'):
607  ax.set_ylim([0,300])
608 
609 fig.savefig('Output/Figures/Stats/Min_Mean.png')
610 plt.close(fig)
611 
612 # Produce the Plot
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')
621 plt.legend(loc=1)
622 
623 if (Scheme == 'IterativeFull' and Mesh == 'Pipe'):
624  ax.set_ylim([-1,100])
625 
626 if (Scheme == 'IterativeFull' and Mesh == 'Cylinder'):
627  ax.set_ylim([-1,50])
628 
629 if (Scheme == 'IterativeStaticCond' and Mesh == 'Pipe'):
630  ax.set_ylim([-1,50])
631 
632 if (Scheme == 'IterativeStaticCond' and Mesh == 'Cylinder'):
633  ax.set_ylim([-1,10])
634 
635 fig.savefig('Output/Figures/Stats/Min_Std_Dev.png')
636 plt.close(fig)
637 
638 # Produce the Plot
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')
647 plt.legend(loc=1)
648 
649 if (Scheme == 'IterativeFull' and Mesh == 'Pipe'):
650  ax.set_ylim([-1,100])
651 
652 if (Scheme == 'IterativeFull' and Mesh == 'Cylinder'):
653  ax.set_ylim([-1,50])
654 
655 if (Scheme == 'IterativeStaticCond' and Mesh == 'Pipe'):
656  ax.set_ylim([-1,50])
657 
658 if (Scheme == 'IterativeStaticCond' and Mesh == 'Cylinder'):
659  ax.set_ylim([-1,10])
660 
661 fig.savefig('Output/Figures/Stats/Min_Variance_Velocity_1.png')
662 plt.close(fig)
663 
664 # --------------------------------------
665 # Moving Window Standard Deviation
666 # --------------------------------------
667 
668 # Shift the modes back for this part
669 modes = [x - 1 for x in modes]
670 
671 # Loop over all the modes
672 for i in range(0, len(modes)):
673 
674  # Lists to hold the results for plotting
675  Settling_Deviation_P = []
676  Settling_Deviation_V_1 = []
677  Settling_Deviation_V_2 = []
678  Settling_Deviation_V_3 = []
679 
680  Settling_Time = []
681 
682  # Default Error to True
683  Error = True
684 
685  # Pick out the data for the plane currently being looped over
686  try:
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])]
691 
692  except:
693  Error = False
694 
695  # Loop over the data is no error thrown
696  if Error is True:
697  for j in range(0, len(Data_P) - 50):
698 
699  # Append the current timestep
700  Settling_Time.append(j)
701 
702  # List to hold the data of the concerned timesteps
703  Data_2_P = []
704  Data_2_V_1 = []
705  Data_2_V_2 = []
706  Data_2_V_3 = []
707 
708 
709  # Pick out the data from current timestep to the end
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])
715 
716  # Take the standard deviation of this
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))
721 
722  # Shift the settling time to account for the skipped steps
723  Settling_Time = [x + Skip_Steps + 1 for x in Settling_Time]
724 
725  # Generate Save File and Title
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)
728 
729  # Produce the Plot
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')
735  plt.legend(loc=1)
736 
737  ax.set_xlabel('Time Step')
738  ax.set_ylabel('Standard Deviation')
739  ax.set_title(title)
740 
741  if (Scheme == 'IterativeFull' and Mesh == 'Pipe'):
742  ax.set_ylim([-1,10])
743 
744  if (Scheme == 'IterativeFull' and Mesh == 'Cylinder'):
745  ax.set_ylim([-1,50])
746 
747  if (Scheme == 'IterativeStaticCond' and Mesh == 'Pipe'):
748  ax.set_ylim([-1,10])
749 
750  if (Scheme == 'IterativeStaticCond' and Mesh == 'Cylinder'):
751  ax.set_ylim([-1,10])
752 
753  fig.savefig(savefile)
754  plt.close(fig)
755 
756 #--------------------------------------
757 # End of Program
758 #--------------------------------------
def Parse_Nektar_Output