-
Notifications
You must be signed in to change notification settings - Fork 1
/
parameters.py
406 lines (355 loc) · 13.6 KB
/
parameters.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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
# -*- coding: utf-8 -*-
"""
Created on Sun Aug 1 16:19:18 2021
@author: Matko
"""
# imports are defined IN the .py file they are used in, BEFORE definig func
import numpy as np
from ISAfunction import ISAfunny
from func_b2_constraint_analysis import tw_constant_level_velocity_turn
from func_b2_constraint_analysis import tw_desired_specific_energy_level
from func_b2_constraint_analysis import tw_desired_rate_of_climb
from func_b2_constraint_analysis import tw_desired_TO_distance
from func_b2_constraint_analysis import tw_desired_cruise_airspeed
from func_b2_constraint_analysis import tw_service_ceiling
from func_b2_constraint_analysis import clmax_ws_func
#
def mainparameters(sizing_input_dict):
"""
Main parameters function
Parameters
----------
alt : float
Altitude in [m].
mach : float
Velocity in Mach.
mtow : float
Maximum Take-Off Weight in [N].
ar : float
Aspect Ratio of wings.
C_Dmin : float
Zero-lift drag.
P_S : float
Turn excess energy.
Returns
-------
All other necessary stuff.
"""
ws_params = sizing_input_dict['ws_params']
alt = sizing_input_dict['alt']
V = sizing_input_dict['V']
mtow = sizing_input_dict['mtow']
ar = sizing_input_dict['ar']
C_Dmin = sizing_input_dict['C_Dmin']
n = sizing_input_dict['n']
P_S = sizing_input_dict['P_S']
V_v = sizing_input_dict['V_v']
C_DTO = sizing_input_dict['C_DTO']
C_LTO = sizing_input_dict['C_LTO']
S_G = sizing_input_dict['S_G']
mu_gr = sizing_input_dict['mu_gr']
V_LOF = sizing_input_dict['V_LOF']
V_vx = sizing_input_dict['V_vx']
alt_sc = sizing_input_dict['alt_sc']
alt_TO = sizing_input_dict['alt_TO']
V_stall = sizing_input_dict['V_stall']
eta_prop = sizing_input_dict['eta_prop']
#---------------------------------------------------------#
# Atmosphere
T,p,rho,mu,a = ISAfunny(alt)
# Velocity, TAS [m/s]
V = V # V = mach*a
# Weight, [N]
W = mtow
# Dynamic pressure
q = 0.5*rho*V**2
# Oswald's wing efficiency factor
e = 1.78*(1-0.045*ar**0.68)-0.64
# Lift-induced drag component
k = 1/(np.pi*ar*e)
T_TO,P_TO,rho_TO,mu_TO,a_TO = ISAfunny(alt_TO)
q2 = 0.5*rho_TO*V_vx**2
n2 = 1
V3 = V_LOF/ (2**0.5)
q3 = 0.5*rho_TO*V3**2
T_sc,P_sc,rho_sc,mu_sc,a_sc = ISAfunny(alt_sc)
# ws range
ws = np.linspace(ws_params[0],ws_params[1],ws_params[2])
tw_clvt_list = []
tw_dsel_list = []
tw_droc_list = []
tw_dtod_list = []
tw_dca_list = []
tw_sc_list = []
clmax_list = []
S_list = []
for ind, val in enumerate(ws):
tw_clvt = tw_constant_level_velocity_turn(q, C_Dmin, ws[ind], k, n)
tw_clvt_list.append(tw_clvt)
tw_dsel = tw_desired_specific_energy_level(q2, C_Dmin, ws[ind], k, n2, V_v, V_vx)
tw_dsel_list.append(tw_dsel)
# tw_droc = tw_desired_rate_of_climb(q, C_Dmin, ws[ind], k, V_v, rho)
# tw_droc_list.append(tw_droc)
tw_dtod = tw_desired_TO_distance(q3, C_DTO, C_LTO, ws[ind], S_G, mu_gr, V_LOF)
tw_dtod_list.append(tw_dtod)
tw_dca = tw_desired_cruise_airspeed(q, C_Dmin, ws[ind], k)
tw_dca_list.append(tw_dca)
tw_sc = tw_service_ceiling(C_Dmin, ws[ind], k, rho_sc)
tw_sc_list.append(tw_sc)
clmax = clmax_ws_func(ws[ind], rho_TO, V_stall)
clmax_list.append(clmax)
S = W/ws[ind]
S_list.append(S)
tohp = 1.341
#--------------------------------------------------
pw_clvt_list = []
pwsl_clvt_list = []
t_clvt_mass_list = []
p_clvt_mass_list = []
psl_clvt_mass_list = []
for tw in tw_clvt_list:
pw = 0.001*(tw*V)/eta_prop*1.341
pwSL = pw / ( 1.132*rho/rho_TO - 0.132 )
pw_clvt_list.append(pw)
pwsl_clvt_list.append(pwSL)
t_clvt_mass = tw*W
t_clvt_mass_list.append(t_clvt_mass)
p_clvt_mass = pw * W
p_clvt_mass_list.append(p_clvt_mass)
psl_clvt_mass = pwSL * W
psl_clvt_mass_list.append(psl_clvt_mass)
#--------------------------------------------------
pw_dsel_list = []
pwsl_dsel_list = []
t_dsel_mass_list = []
p_dsel_mass_list = []
psl_dsel_mass_list = []
for tw in tw_dsel_list:
pw = 0.001*(tw*V_vx)/eta_prop*1.341
pwSL = pw / ( 1.132*rho_TO/rho_TO - 0.132 )
pw_dsel_list.append(pw)
pwsl_dsel_list.append(pwSL)
t_dsel_mass = tw*W
t_dsel_mass_list.append(t_dsel_mass)
p_dsel_mass = pw * W
p_dsel_mass_list.append(p_dsel_mass)
psl_dsel_mass = pwSL * W
psl_dsel_mass_list.append(psl_dsel_mass)
#--------------------------------------------------
pw_dtod_list = []
pwsl_dtod_list = []
t_dtod_mass_list = []
p_dtod_mass_list = []
psl_dtod_mass_list = []
for tw in tw_dtod_list:
# thr = (item*W)
pw = 0.001*(tw*V_vx)/eta_prop*1.341
pwSL = pw / ( 1.132*rho_TO/rho_TO - 0.132 )
pw_dtod_list.append(pw)
pwsl_dtod_list.append(pwSL)
t_dtod_mass = tw*W
t_dtod_mass_list.append(t_dtod_mass)
p_dtod_mass = pw * W
p_dtod_mass_list.append(p_dtod_mass)
psl_dtod_mass = pwSL * W
psl_dtod_mass_list.append(psl_dtod_mass)
#--------------------------------------------------
pw_dca_list = []
pwsl_dca_list = []
t_dca_mass_list = []
p_dca_mass_list = []
psl_dca_mass_list = []
for tw in tw_dca_list:
# thr = (item*W)
pw = 0.001*(tw*V)/eta_prop*1.341
pwSL = pw / ( 1.132*rho/rho_TO - 0.132 )
pw_dca_list.append(pw)
pwsl_dca_list.append(pwSL)
t_dca_mass = tw*W
t_dca_mass_list.append(t_dca_mass)
p_dca_mass = pw * W
p_dca_mass_list.append(p_dca_mass)
psl_dca_mass = pwSL * W
psl_dca_mass_list.append(psl_dca_mass)
#--------------------------------------------------
pw_sc_list = []
pwsl_sc_list = []
t_sc_mass_list = []
p_sc_mass_list = []
psl_sc_mass_list = []
for tw in tw_sc_list:
# thr = (item*W)
pw = 0.001*(tw*V)/eta_prop*1.341
pwSL = pw / ( 1.132*rho_sc/rho_TO - 0.132 )
pw_sc_list.append(pw)
pwsl_sc_list.append(pwSL)
t_sc_mass = tw*W
t_sc_mass_list.append(t_sc_mass)
p_sc_mass = pw * W
p_sc_mass_list.append(p_sc_mass)
psl_sc_mass = pwSL * W
psl_sc_mass_list.append(psl_sc_mass)
#--------------------------------------------------
#--------------------------------------------------
#--------------- Packing results ---------------#
sizing_output_dict = dict()
sizing_output_dict['T'] = T
sizing_output_dict['p'] = p
sizing_output_dict['rho'] = rho
sizing_output_dict['mu'] = mu
sizing_output_dict['a'] = a
sizing_output_dict['V'] = V
sizing_output_dict['q'] = q
sizing_output_dict['e'] = e
sizing_output_dict['k'] = k
sizing_output_dict['ws'] = ws
sizing_output_dict['tw_clvt_list'] = tw_clvt_list
sizing_output_dict['tw_dsel_list'] = tw_dsel_list
sizing_output_dict['tw_dtod_list'] = tw_dtod_list
sizing_output_dict['tw_dca_list'] = tw_dca_list
sizing_output_dict['tw_sc_list'] = tw_sc_list
sizing_output_dict['pw_clvt_list'] = pw_clvt_list
sizing_output_dict['pwsl_clvt_list'] = pwsl_clvt_list
sizing_output_dict['t_clvt_mass_list'] = t_clvt_mass_list
sizing_output_dict['p_clvt_mass_list'] = p_clvt_mass_list
sizing_output_dict['psl_clvt_mass_list'] = psl_clvt_mass_list
sizing_output_dict['pw_dsel_list'] = pw_dsel_list
sizing_output_dict['pwsl_dsel_list'] = pwsl_dsel_list
sizing_output_dict['t_dsel_mass_list'] = t_dsel_mass_list
sizing_output_dict['p_dsel_mass_list'] = p_dsel_mass_list
sizing_output_dict['psl_dsel_mass_list'] = psl_dsel_mass_list
sizing_output_dict['pw_dtod_list'] = pw_dtod_list
sizing_output_dict['pwsl_dtod_list'] = pwsl_dtod_list
sizing_output_dict['t_dtod_mass_list'] = t_dtod_mass_list
sizing_output_dict['p_dtod_mass_list'] = p_dtod_mass_list
sizing_output_dict['psl_dtod_mass_list'] = psl_dtod_mass_list
sizing_output_dict['pw_dca_list'] = pw_dca_list
sizing_output_dict['pwsl_dca_list'] = pwsl_dca_list
sizing_output_dict['t_dca_mass_list'] = t_dca_mass_list
sizing_output_dict['p_dca_mass_list'] = p_dca_mass_list
sizing_output_dict['psl_dca_mass_list'] = psl_dca_mass_list
sizing_output_dict['pw_sc_list'] = pw_sc_list
sizing_output_dict['pwsl_sc_list'] = pwsl_sc_list
sizing_output_dict['t_sc_mass_list'] = t_sc_mass_list
sizing_output_dict['p_sc_mass_list'] = p_sc_mass_list
sizing_output_dict['psl_sc_mass_list'] = psl_sc_mass_list
sizing_output_dict['S_list'] = S_list
sizing_output_dict['clmax_list'] = clmax_list
return sizing_output_dict
# return T,p,rho,mu,a,V,q,e,k,ws,tw_clvt_list,tw_dsel_list,tw_dtod_list,tw_dca_list,tw_sc_list,pw_clvt_list,pwsl_clvt_list,t_clvt_mass_list,p_clvt_mass_list,psl_clvt_mass_list,pw_dsel_list,pwsl_dsel_list,t_dsel_mass_list,p_dsel_mass_list,psl_dsel_mass_list,pw_dtod_list,pwsl_dtod_list,t_dtod_mass_list,p_dtod_mass_list,psl_dtod_mass_list,pw_dca_list,pwsl_dca_list,t_dca_mass_list,p_dca_mass_list,psl_dca_mass_list,pw_sc_list,pwsl_sc_list,t_sc_mass_list,p_sc_mass_list,psl_sc_mass_list,S_list,clmax_list
def designpoint(sizing_input_dict):
DP_ws = sizing_input_dict['DP_ws']
DP_tw = sizing_input_dict['DP_tw']
ws_params = sizing_input_dict['ws_params']
alt = sizing_input_dict['alt']
V = sizing_input_dict['V']
mtow = sizing_input_dict['mtow']
ar = sizing_input_dict['ar']
C_Dmin = sizing_input_dict['C_Dmin']
n = sizing_input_dict['n']
P_S = sizing_input_dict['P_S']
V_v = sizing_input_dict['V_v']
C_DTO = sizing_input_dict['C_DTO']
C_LTO = sizing_input_dict['C_LTO']
S_G = sizing_input_dict['S_G']
mu_gr = sizing_input_dict['mu_gr']
V_LOF = sizing_input_dict['V_LOF']
V_vx = sizing_input_dict['V_vx']
alt_sc = sizing_input_dict['alt_sc']
alt_TO = sizing_input_dict['alt_TO']
V_stall = sizing_input_dict['V_stall']
eta_prop = sizing_input_dict['eta_prop']
"""
Parameters
----------
DP_ws : TYPE
DESCRIPTION.
DP_tw : TYPE
DESCRIPTION.
alt : TYPE
DESCRIPTION.
V : TYPE
DESCRIPTION.
mtow : TYPE
DESCRIPTION.
ar : TYPE
DESCRIPTION.
C_Dmin : TYPE
DESCRIPTION.
n : TYPE
DESCRIPTION.
P_S : TYPE
DESCRIPTION.
V_v : TYPE
DESCRIPTION.
C_DTO : TYPE
DESCRIPTION.
C_LTO : TYPE
DESCRIPTION.
S_G : TYPE
DESCRIPTION.
mu_gr : TYPE
DESCRIPTION.
V_LOF : TYPE
DESCRIPTION.
V_vx : TYPE
DESCRIPTION.
alt_sc : TYPE
DESCRIPTION.
alt_TO : TYPE
DESCRIPTION.
V_stall : TYPE
DESCRIPTION.
eta_prop : TYPE
DESCRIPTION.
Returns
-------
None.
"""
# Atmosphere
T,p,rho,mu,a = ISAfunny(alt)
# Velocity, TAS [m/s]
V = V # V = mach*a
# Dynamic pressure
q = 0.5*rho*V**2
# Oswald's wing efficiency factor
e = 1.78*(1-0.045*ar**0.68)-0.64
# Lift-induced drag component
k = 1/(np.pi*ar*e)
T_TO,P_TO,rho_TO,mu_TO,a_TO = ISAfunny(alt_TO)
q2 = 0.5*rho_TO*V_vx**2
n2 = 1
V3 = V_LOF/ (2**0.5)
q3 = 0.5*rho_TO*V3**2
T_sc,P_sc,rho_sc,mu_sc,a_sc = ISAfunny(alt_sc)
tw_clvt = tw_constant_level_velocity_turn(q, C_Dmin, DP_ws, k, n)
tw_dsel = tw_desired_specific_energy_level(q2, C_Dmin, DP_ws, k, n2, V_v, V_vx)
# tw_droc = tw_desired_rate_of_climb(q, C_Dmin, DP_ws, k, V_v, rho)
tw_dtod = tw_desired_TO_distance(q3, C_DTO, C_LTO, DP_ws, S_G, mu_gr, V_LOF)
tw_dca = tw_desired_cruise_airspeed(q, C_Dmin, DP_ws, k)
tw_sc = tw_service_ceiling(C_Dmin, DP_ws, k, rho_sc)
DP_pw = 0.001*(DP_tw*V)/eta_prop*1.341
DP_pwsl = DP_pw / ( 1.132*rho/rho_TO - 0.132 )
Thr = DP_tw*mtow
P_watt = (Thr*V)/eta_prop
P_kw = 0.001*P_watt
P_hp = P_kw*1.341
sigma = rho/rho_TO
P_hpSL = P_hp / ( 1.132*sigma - 0.132 ) # Gagg and Ferrar model for pistoned propellers, snorri equation (7-16)
DP_S = mtow/DP_ws
clmax = clmax_ws_func(DP_ws, rho_TO, V_stall)
designpoint_output_dict = dict()
designpoint_output_dict['tw_clvt'] = tw_clvt
designpoint_output_dict['tw_dsel'] = tw_dsel
designpoint_output_dict['tw_dtod'] = tw_dtod
designpoint_output_dict['tw_dca'] = tw_dca
designpoint_output_dict['tw_sc'] = tw_sc
designpoint_output_dict['DP_pw'] = DP_pw
designpoint_output_dict['DP_pwsl'] = DP_pwsl
designpoint_output_dict['Thr'] = Thr
designpoint_output_dict['P_kw'] = P_kw
designpoint_output_dict['P_hp'] = P_hp
designpoint_output_dict['P_hpSL'] = P_hpSL
designpoint_output_dict['DP_S'] = DP_S
designpoint_output_dict['clmax'] = clmax
return designpoint_output_dict