forked from contrailcirrus/pycontrails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp3t3_graph_creation_report.py
309 lines (277 loc) · 12 KB
/
p3t3_graph_creation_report.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
import pandas as pd
from scipy.interpolate import interp1d
import matplotlib.pyplot as plt
import numpy as np
from emission_index import p3t3_nox, p3t3_nvpm_meem, p3t3_nvpm_meem_mass, thrust_setting
import pickle
def ei_nox_sls(tt3, pt3, far):
return 1.4094 * pt3** 0.1703 * np.exp(0.0011 * tt3) * 12.2308 ** (16.4302 * far)
"""PW1127G"""
# Read the file
file_path = 'P3T3_SLS_GRAPHS_PW1127G_V4_Final.csv'
data = pd.read_csv(file_path, delimiter=';', decimal=',')
data = data.drop(index=0).reset_index(drop=True)
data['TT3'] = pd.to_numeric(data['TT3'].str.replace(',', '.'))
data = data[data['TT3'] <= 850]
# Convert columns to numeric after replacing ',' with '.'
# data['TT3'] = pd.to_numeric(data['TT3'].str.replace(',', '.'))
data['FAR'] = pd.to_numeric(data['FAR'].str.replace(',', '.'))
data['PT3'] = pd.to_numeric(data['PT3'].str.replace(',', '.'))
data['FGR'] = pd.to_numeric(data['FGR'].str.replace(',', '.'))
# Extract the 'TT3', 'FAR', and 'PT3' columns
TT3 = data['TT3'].values
FAR = data['FAR'].values
PT3 = data['PT3'].values
FGR = data['FGR'].values
FGR_r = FGR / 120.4
# Apply the ei_nox_sls function to each row
data['EI_NOx_SLS'] = data.apply(lambda row: ei_nox_sls(row['TT3'], row['PT3'], row['FAR']), axis=1)
NOX = data['EI_NOx_SLS'].values
# Create interpolation functions
interp_func_FAR = interp1d(TT3, FAR, kind='linear')
interp_func_PT3 = interp1d(TT3, PT3, kind='linear')
interp_func_NOX = interp1d(TT3, NOX, kind='linear')
interp_func_FGR_r = interp1d(TT3, FGR_r, kind='linear')
# Define points for red dots
highlight_tt3 = [835.38, 805.03, 643.29, 485.36]
# 835,38
# 805,03
# 643,29
# 485,36
# Interpolated values for red dots
highlight_FAR = interp_func_FAR(highlight_tt3)
highlight_PT3 = interp_func_PT3(highlight_tt3)
highlight_NOX = interp_func_NOX(highlight_tt3)
highlight_FGR_r= interp_func_FGR_r(highlight_tt3)
print(highlight_NOX)
"""GTF2035"""
file_path_1 = 'P3T3_SLS_GRAPHS_GTF2035_final.csv'
data_2035 = pd.read_csv(file_path_1, delimiter=';', decimal=',')
data_2035 = data_2035.drop(index=0).reset_index(drop=True)
data_2035['TT3'] = pd.to_numeric(data_2035['TT3'].str.replace(',', '.'))
data_2035 = data_2035[data_2035['TT3'] <= 900]
# Convert columns to numeric after replacing ',' with '.'
# data['TT3'] = pd.to_numeric(data['TT3'].str.replace(',', '.'))
data_2035['FAR'] = pd.to_numeric(data_2035['FAR'].str.replace(',', '.'))
data_2035['PT3'] = pd.to_numeric(data_2035['PT3'].str.replace(',', '.'))
data_2035['FGR'] = pd.to_numeric(data_2035['FGR'].str.replace(',', '.'))
# Extract the 'TT3', 'FAR', and 'PT3' columns
TT3_2035 = data_2035['TT3'].values
FAR_2035 = data_2035['FAR'].values
PT3_2035 = data_2035['PT3'].values
FGR_2035 = data_2035['FGR'].values
FGR_2035_r = FGR_2035 / 120.4
# Apply the ei_nox_sls function to each row
data_2035['EI_NOx_SLS'] = data_2035.apply(lambda row: ei_nox_sls(row['TT3'], row['PT3'], row['FAR']), axis=1)
NOX_2035 = data_2035['EI_NOx_SLS'].values
# Create interpolation functions
interp_func_FAR_2035 = interp1d(TT3_2035, FAR_2035, kind='linear')
interp_func_PT3_2035 = interp1d(TT3_2035, PT3_2035, kind='linear')
interp_func_NOX_2035 = interp1d(TT3_2035, NOX_2035, kind='linear')
interp_func_FGR_2035_r = interp1d(TT3_2035, FGR_2035_r, kind='linear')
# Define points for red dots
highlight_tt3_2035 = [875.67, 843.57, 672.96, 498.62]
# 835,38
# 805,03
# 643,29
# 485,36
# Interpolated values for red dots
highlight_FAR_2035 = interp_func_FAR_2035(highlight_tt3_2035)
highlight_PT3_2035 = interp_func_PT3_2035(highlight_tt3_2035)
highlight_NOX_2035 = interp_func_NOX_2035(highlight_tt3_2035)
highlight_FGR_2035_r = interp_func_FGR_2035_r(highlight_tt3_2035)
print(highlight_NOX_2035)
data_1124 = {
"LTOstage": ["T/O", "CLIMB", "APPR", "IDLE"],
"TT3": [810.26, 780.38, 629.21, 466.85],
"PT3": [29.05609, 25.08446, 9.43599, 3.50655],
"FAR": [2.52E-02, 2.36E-02, 2.00E-02, 1.48E-02],
"TT4": [1636.67, 1565.47, 1331.05, 1023.14]
}
df_1124 = pd.DataFrame(data_1124)
data_1129 = {
"LTOstage": ["T/O", "CLIMB", "APPR", "IDLE"],
"TT3": [852.04, 819.51, 656.8, 488.04],
"PT3": [34.70164, 29.84731, 10.88136, 3.88328],
"FAR": [2.86E-02, 2.68E-02, 2.25E-02, 1.65E-02],
"TT4": [1767.34, 1688.55, 1429.96, 1096.17]
}
df_1129 = pd.DataFrame(data_1129)
# Data for 1133
data_1133 = {
"LTOstage": ["T/O", "CLIMB", "APPR", "IDLE"],
"TT3": [877.87, 843.15, 662.78, 492.97],
"PT3": [38.97456, 33.48126, 12.63606, 4.10652],
"FAR": [3.14E-02, 2.88E-02, 2.03E-02, 1.60E-02],
"TT4": [1862.62, 1764.29, 1365.43, 1086.04]
}
df_1133 = pd.DataFrame(data_1133)
df_1124['EI_NOx_SLS'] = df_1124.apply(lambda row: ei_nox_sls(row['TT3'], row['PT3'], row['FAR']), axis=1)
df_1129['EI_NOx_SLS'] = df_1129.apply(lambda row: ei_nox_sls(row['TT3'], row['PT3'], row['FAR']), axis=1)
df_1133['EI_NOx_SLS'] = df_1133.apply(lambda row: ei_nox_sls(row['TT3'], row['PT3'], row['FAR']), axis=1)
# Plot 1: PT3 as a function of TT3
plt.figure(figsize=(10, 6))
plt.plot(TT3, PT3, label='GTF')
plt.scatter(highlight_tt3, highlight_PT3, color='tab:blue', label='GTF LTO stages', zorder=5)
plt.plot(TT3_2035, PT3_2035, label='GTF2035')
plt.scatter(highlight_tt3_2035, highlight_PT3_2035, color='tab:orange', label='GTF2035 LTO stages', zorder=5)
# plt.scatter(df_1124['TT3'], df_1124['PT3'], label='PW1124G, OPR t/o: 28.8', color='tab:red')
# plt.scatter(df_1129['TT3'], df_1129['PT3'], label='PW1129G, OPR t/o: 34.0', color='tab:green')
# plt.scatter(df_1133['TT3'], df_1133['PT3'], label='PW1133G, OPR t/o: 38.2', color='tab:purple')
plt.title(r'$P_{t3,GR}$ versus $T_{t3}$ Map')
plt.xlabel(r'$T_{t3}$ (k)')
plt.ylabel(r'$P_{t3,GR}$ (bar)')
plt.legend()
plt.grid(True)
# plt.xlim(0, 900)
plt.savefig('results_report/p3t3_graph/pt3_tt3_sls.png', format='png')
# Plot 2: FAR as a function of TT3
plt.figure(figsize=(10, 6))
plt.plot(TT3, FAR, label='GTF')
plt.scatter(highlight_tt3, highlight_FAR, color='tab:blue', label='GTF LTO stages', zorder=5)
plt.plot(TT3_2035, FAR_2035, label='GTF2035')
plt.scatter(highlight_tt3_2035, highlight_FAR_2035, color='tab:orange', label='GTF2035 LTO stages', zorder=5)
# plt.scatter(df_1124['TT3'], df_1124['FAR'], label='PW1124G, OPR t/o: 28.8', color='tab:red')
# plt.scatter(df_1129['TT3'], df_1129['FAR'], label='PW1129G, OPR t/o: 34.0', color='tab:green')
# plt.scatter(df_1133['TT3'], df_1133['FAR'], label='PW1133G, OPR t/o: 38.2', color='tab:purple')
plt.title(r'$FAR_{GR}$ versus $T_{t3}$ Map')
plt.xlabel(r'$T_{t3}$ (k)')
plt.ylabel(r'$FAR_{GR}$ (-)')
plt.legend()
plt.grid(True)
# plt.xlim(0, 900)
plt.savefig('results_report/p3t3_graph/far_tt3_sls.png', format='png')
# Plot 3: ei nox as a function of TT3
plt.figure(figsize=(10, 6))
plt.plot(TT3, NOX, label='GTF')
plt.scatter(highlight_tt3, highlight_NOX, color='tab:blue', label='GTF LTO stages', zorder=5)
plt.plot(TT3_2035, NOX_2035, label='GTF2035')
plt.scatter(highlight_tt3_2035, highlight_NOX_2035, color='tab:orange', label='GTF LTO stages', zorder=5)
# plt.scatter(df_1124['TT3'], df_1124['EI_NOx_SLS'], label='PW1124G, OPR t/o: 28.8', color='tab:red')
# plt.scatter(df_1129['TT3'], df_1129['EI_NOx_SLS'], label='PW1129G, OPR t/o: 34.0', color='tab:green')
# plt.scatter(df_1133['TT3'], df_1133['EI_NOx_SLS'], label='PW1133G, OPR t/o: 38.2', color='tab:purple')
plt.title(r'$EI_{NOx,sls}$ versus $T_{t3}$ Map')
plt.xlabel(r'$T_{t3}$ (k)')
plt.ylabel(r'$EI_{NOx,GR}$ (g / kg Fuel)')
plt.legend()
plt.grid(True)
# plt.xlim(0, 900)
plt.savefig('results_report/p3t3_graph/nox_tt3_sls.png', format='png')
# Plot 3: ei nox as a function of TT3
plt.figure(figsize=(10, 6))
plt.plot(TT3, FGR_r, label='GTF')
plt.scatter(highlight_tt3, highlight_FGR_r, color='tab:blue', label='GTF LTO stages', zorder=5)
plt.plot(TT3_2035, FGR_2035_r, label='GTF2035')
plt.scatter(highlight_tt3_2035, highlight_FGR_2035_r, color='tab:orange', label='GTF LTO stages', zorder=5)
# plt.scatter(df_1124['TT3'], df_1124['EI_NOx_SLS'], label='PW1124G, OPR t/o: 28.8', color='tab:red')
# plt.scatter(df_1129['TT3'], df_1129['EI_NOx_SLS'], label='PW1129G, OPR t/o: 34.0', color='tab:green')
# plt.scatter(df_1133['TT3'], df_1133['EI_NOx_SLS'], label='PW1133G, OPR t/o: 38.2', color='tab:purple')
plt.title(r'$\frac{F_{GR}}{F_{00}}$ versus $T_{t3}$ Map')
plt.xlabel(r'$T_{t3}$ (k)')
plt.ylabel(r'$\frac{F_{GR}}{F_{00}}$ (-)')
plt.legend()
plt.grid(True)
# plt.xlim(0, 900)
plt.savefig('results_report/p3t3_graph/fgr_r_tt3_sls.png', format='png')
file_path_3 = f'main_results_figures/results/malaga/malaga/emissions/GTF2035_SAF_0_A20N_full_WAR_0_0_0.csv'
df = pd.read_csv(file_path_3)
engine_model = 'GTF2035'
if engine_model in ('GTF'):
with open('p3t3_graphs_sls_gtf_corr.pkl', 'rb') as f:
loaded_functions = pickle.load(f)
elif engine_model in ('GTF2035', 'GTF2035_wi'):
print('yes')
with open('p3t3_graphs_sls_gtf_2035.pkl', 'rb') as f:
loaded_functions = pickle.load(f)
elif engine_model in ('GTF1990', 'GTF2000'):
with open('p3t3_graphs_sls_1990_2000.pkl', 'rb') as f:
loaded_functions = pickle.load(f)
else:
raise ValueError(f"Unsupported engine_model: {engine_model}.")
interp_func_far = loaded_functions['interp_func_far']
interp_func_pt3 = loaded_functions['interp_func_pt3']
df['thrust_setting_meem_2035_gr'] = df.apply(
lambda row: thrust_setting(
engine_model,
row['TT3'],
interp_func_pt3
),
axis=1
)
"""NOx p3t3"""
df['ei_nox_p3t3_2035_gr'] = df.apply(
lambda row: p3t3_nox(
row['PT3'],
row['TT3'],
interp_func_far,
interp_func_pt3,
row['specific_humidity'],
row['WAR_gsp'],
engine_model
),
axis=1
)
#
"""P3T3 _MEEM"""
df['ei_nvpm_number_p3t3_meem_2035_gr'] = df.apply(
lambda row: p3t3_nvpm_meem(
row['PT3'],
row['TT3'],
row['FAR'],
interp_func_far,
interp_func_pt3,
row['SAF'],
row['thrust_setting_meem'],
engine_model
),
axis=1
)
df['ei_nvpm_mass_p3t3_meem_2035_gr'] = df.apply(
lambda row: p3t3_nvpm_meem_mass(
row['PT3'],
row['TT3'],
row['FAR'],
interp_func_far,
interp_func_pt3,
row['SAF'],
row['thrust_setting_meem'],
engine_model
),
axis=1
)
file_path_gtf = f'main_results_figures/results/malaga/malaga/emissions/GTF_SAF_0_A20N_full_WAR_0_0_0.csv'
df_gtf = pd.read_csv(file_path_gtf)
# Plot EI NOx
plt.figure(figsize=(10, 6))
plt.plot(df_gtf.index, df_gtf['ei_nox_p3t3'], label='GTF')
# plt.plot(df.index, df['ei_nox_p3t3'], label='GTF2035 (GTF P3T3 SLS Maps)')
plt.plot(df.index, df['ei_nox_p3t3_2035_gr'], label='GTF2035 (GTF2035 P3T3 SLS Maps)')
plt.xlabel("Time (minutes)")
plt.ylabel(f"$EI_{{\\mathrm{{NOx}}}}$ (g / kg fuel)")
plt.title(f"$EI_{{\\mathrm{{NOx}}}}$ for different engines")
plt.legend(title="Engine")
plt.grid()
# plt.savefig(f'../results_report/performance_emissions_chapter/EI_nox_engines_gtf_gtf2035.png', format='png')
# Plot EI nvPM Number
plt.figure(figsize=(10, 6))
plt.plot(df_gtf.index, df_gtf['ei_nvpm_number_p3t3_meem'], label='GTF')
# plt.plot(df.index, df['ei_nvpm_number_p3t3_meem'], label='GTF2035 (GTF P3T3 SLS Maps)')
plt.plot(df.index, df['ei_nvpm_number_p3t3_meem_2035_gr'], label='GTF2035 (GTF2035 P3T3 SLS Maps)')
plt.xlabel("Time (minutes)")
plt.ylabel(f'$EI_{{\\mathrm{{nvPM,number}}}}$ (# / kg Fuel)')
plt.title(f"$EI_{{\\mathrm{{nvPM,number}}}}$ for different engines")
plt.legend(title="Engine")
plt.grid()
# plt.savefig(f'../results_report/performance_emissions_chapter/EI_nvpm_number_engines_gtf_gtf2035.png', format='png')
# Plot EI nvPM Mass
plt.figure(figsize=(10, 6))
plt.plot(df_gtf.index, df_gtf['ei_nvpm_mass_p3t3_meem'], label='GTF')
# plt.plot(df.index, df['ei_nvpm_mass_p3t3_meem'], label='GTF2035 (GTF P3T3 SLS Maps)')
plt.plot(df.index, df['ei_nvpm_mass_p3t3_meem_2035_gr'], label='GTF2035 (GTF2035 P3T3 SLS Maps)')
plt.xlabel("Time (minutes)")
plt.ylabel(f'$EI_{{\\mathrm{{nvPM,mass}}}}$ (mg / kg Fuel)')
plt.title(f"$EI_{{\\mathrm{{nvPM,mass}}}}$ for different engines")
plt.legend(title="Engine")
plt.grid()
# plt.savefig(f'../results_report/performance_emissions_chapter/EI_nvpm_mass_engines_gtf_gtf2035.png', format='png')
plt.show()