-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdisplay_sim_data.py
65 lines (38 loc) · 1.67 KB
/
display_sim_data.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
import matplotlib.pyplot as plt
import cantera as ct
import numpy as np
import pickle
# ------------EDITABLE INPUT VALUES FOR SIMULATION RESULTS DISPLAY-------------
specs = ['CH4', 'OH', 'H2O', 'CO2']
results_path = 'SL_GPS Simulation Data/results_c_100_a_0.001_n_16.pkl'
# ------------------------------END OF INPUTS---------------------------------
def display_sim_data(specs, results_path):
result_file = open(results_path, 'rb')
results = pickle.load(result_file)
results_dict = results[0]
mech_times = results[1]
rxn_nums = results[2]
spec_nums = results[3]
soln = ct.Solution(results_dict['mechanism'])
fig, axs = plt.subplots(5, 1, sharex=True)
fig.set_figheight(12)
fig.set_figwidth(8)
axs[0].plot(results_dict['axis0'], results_dict['temperature'])
axs[0].set_ylabel('Temperature (K)')
axs[1].plot(results_dict['axis0'], results_dict['heat_release_rate'])
axs[1].set_yscale('log')
axs[1].set_ylabel('Heat Release Rate ' + r'$J/(s*m^2)$')
legend_lst = []
for i, spec in enumerate(specs):
axs[2].plot(results_dict['axis0'], results_dict['mole_fraction'][:, soln.species_names.index(spec)])
legend_lst.append(spec)
axs[2].legend(legend_lst)
axs[2].set_ylabel('Mole Fraction (-)')
axs[3].plot(mech_times, spec_nums, 'g-o')
axs[3].set_ylabel('# of Species')
axs[4].plot(mech_times, rxn_nums, 'b-o')
axs[4].set_ylabel('# of Reactions')
axs[4].set_xlabel('Time (s)')
plt.show()
if __name__ == '__main__':
display_sim_data(specs, results_path)