accelerInt  v0.1
plotter.py
Go to the documentation of this file.
1 # imports
2 import matplotlib.pyplot as plt
3 import numpy as np
4 import os
5 
6 # load log files
7 files = [os.path.join('log', file) for file in os.listdir('./log/')
8  if file.endswith('.bin')]
9 files = [file for file in files if os.path.isfile(file)]
10 
11 linestyles = ['-', '--', '-.']
12 colorwheel = ['r', 'g', 'b', 'k']
13 
14 # load data
15 for i, file in enumerate(files):
16  arr = np.fromfile(file)
17  # reshape matrix (nsteps x 15)
18  arr = np.reshape(arr, (-1, 15))
19 
20  # get the solver name
21  label = file.split('-')[0]
22  label = label[label.index('/') + 1:]
23  label += '-GPU' if 'gpu' in file else ''
24 
25  # plot Temperature
26  plt.plot(arr[:, 0], arr[:, 1],
27  linestyle=linestyles[i % len(linestyles)],
28  label=label, color=colorwheel[i % len(colorwheel)])
29 
30 # make legend
31 plt.legend(loc=0)
32 
33 # title and labels
34 plt.title('H2/CO Constant Pressure Ignition')
35 plt.xlabel('Time(s)')
36 plt.ylabel('Temerature (K)')
37 
38 # and save fig
39 plt.savefig('h2ign.png', dpi=300, size=(5, 3))