-
Notifications
You must be signed in to change notification settings - Fork 3
/
CLCD_calc.py
237 lines (164 loc) · 6.08 KB
/
CLCD_calc.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 12 14:30:31 2018
@author: MatsKlijn
"""
from numpy import *
import matplotlib.pyplot as plt
from WeightBalance import cg
S = 30.00
b = 15.911
A = b**2/S #m^2
lbs_to_kg = 0.45359237
g = 9.81 #gravity constant
fuel_start = 4100*lbs_to_kg*g #fuel at start in N
weight_plane_empty = cg(0,0)[0]*g #Weight empty aircraft in N
R = 287.05
gamma = 1.4
p0 = 101325
T0 = 288.15
lamda = -0.0065
rho0 = 1.225
weights_passengers_notfloat = [82, 92, 60, 60, 77, 69, 67, 95, 84] #in kg
weights_passengers = []
for i in range(len(weights_passengers_notfloat)):
weights_passengers_notfloat[i] = float(weights_passengers_notfloat[i])
weights_passengers.append(weights_passengers_notfloat[i]*g) #in N
#print('weights passengers', weights_passengers)
fuel_used_lbs = [385, 416, 442, 471, 502, 544] #fuel used in lbs
fuel_used = [] #fuel used in kg
for i in range(len(fuel_used_lbs)):
fuel_used_lbs[i] = float(fuel_used_lbs[i])
fuel_used.append((fuel_used_lbs[i]*lbs_to_kg)*g) #in N
#print('fuel used', fuel_used)
fuel_stationarystart = [] #Total fuel in aircraft at start of stationary test i
for i in range(len(fuel_used)):
fuel_diff = fuel_start - fuel_used[i]
fuel_stationarystart.append(fuel_diff)
#print('fuel stationary', fuel_stationary)
lift_stationary = [] #Lift at start of stationary test i
for i in range(len(fuel_stationarystart)):
lift_stationary.append(fuel_stationarystart[i] + weight_plane_empty)
#print('lift value', lift_stationary)
V_kts = [249, 221, 191, 161, 141, 117] #kts
kts_to_ms = 0.51444444444 #kts to m/s
V = []
for i in range(len(V_kts)):
V.append((V_kts[i]*kts_to_ms))
V=array(V)
Vc = V-2*.51444444444
#print ('Vc is',Vc)
temp_0 = 273.15 #standard temperature Kelvin at sea level
total_temp_stationary = [7.3, 2.5, 1.0, -0.2, -1.0, -2.5] #Celsius of temperatures during test measured
for i in range(len(total_temp_stationary)):
total_temp_stationary[i] = array(total_temp_stationary[i] + temp_0) #Temperature in Kelvin per test
#print(total_temp_stationary)
### Rho values from Nick's program
from rho import rho1
hp = [2133.6, 2133.6, 2133.6, 2133.6, 2130.552, 2097.024]
#Ttot = [278.15, 275.65, 274.15, 272.95, 272.15, 270.65]
rho = []
for i in range(len(hp)):
rho2 = rho1(hp[i],Vc[i],total_temp_stationary[i])
rho.append(rho2)
#print('rho is',rho)
###Pressure calculation
p = []
for i in range(len(hp)):
p1 = p0*(1 + (lamda*hp[i])/T0)**(-g/(R*lamda))
p.append(p1)
#print ('p is', p)
#Mach number calculation
M = []
for i in range(len(p)):
M1 = 1+((gamma-1)/(2*gamma))*(rho0/p0)*Vc[i]**2
M2 = M1**(gamma/(gamma-1))
M3 = M2-1
M4 = 1+(p0/p[i])*M3
M5 = M4**((gamma-1)/gamma)
M6 = M5-1
M7 = (2/(gamma-1))*M6
M8 = sqrt(M7)
M.append(M8)
#print ('M is', M)
#Calibrated Temp
Temp_c = []
for i in range(len(M)):
Tc1 = total_temp_stationary[i]/(1+((gamma-1)/2)*M[i]**2)
Temp_c.append(Tc1)
#Speed of sound
aoa = []
for i in range(len(M)):
aoa1 = sqrt(gamma*R*Temp_c[i])
aoa.append(aoa1)
#True Airspeed
V_tas = []
for i in range(len(M)):
V_tas.append(aoa[i]*M[i])
### C_L Calculation
C_L = []
C_Lsquared = []
for i in range(len(lift_stationary)):
C_L_formula = lift_stationary[i]/(0.5*rho[i]*V_tas[i]**2*S) #C_L formula
C_L.append(C_L_formula) #C_L values for stationary flight data
C_L2 = (C_L_formula)**2
C_Lsquared.append(C_L2) #
#thrust_left = [3695.85, 2842.33, 2483.98, 2097.37, 1651.94, 2037.49]
#thrust_right = [3688.72, 2919.02, 2612.52, 2217.44, 1818.36, 2236.48]
thrust_total = [7236.03, 5761.35, 5096.5, 4314.81, 3470.3, 4273.97]
#for i in range(len(thrust_left)):
# thrust_total.append(thrust_left[i]+thrust_right[i])
#print (thrust_total)
C_D = []
for i in range(len(thrust_total)):
C_D_formula = thrust_total[i]/(0.5*rho[i]*V_tas[i]**2*S) #C_D formula
C_D.append(C_D_formula) #C_D values for stationary flight data
#corrected coefficients
corrected_C_D = []
C_D_0 = 0.022
e = 1/(pi*A*0.043)
for i in range(len(C_Lsquared)):
corrected_C_D_formula = C_D_0 + C_Lsquared[i]/(pi*e*A) #C_D formula
corrected_C_D.append(corrected_C_D_formula) #C_D values for stationary flight data
#Reynolds number
Re = []
mu = 0.000017217
bar_c = 2.0569
for i in range(len(rho)):
Re.append(rho[i]*V_tas[i]*bar_c/mu)
### Alpha values
alpha_rad = array([0.02792526803, 0.04188790205, 0.06108652382, 0.09424777961, 0.1291543646, 0.193731547])
plt.figure(1)
plt.subplot(511)
plt.title('C_L vs C_D ')
plt.plot(corrected_C_D, C_L, 'r')
plt.xlabel('C_D')
plt.ylabel('C_L')
plt.subplot(512)
plt.title('C_L vs alpha')
plt.plot(alpha_rad, C_L, 'b')
plt.xlabel('alpha')
plt.ylabel('C_L')
plt.subplot(513)
plt.title('C_D vs alpha')
plt.plot(alpha_rad, corrected_C_D, 'g')
plt.xlabel('alpha')
plt.ylabel('C_D')
plt.subplot(514)
plt.title('C_L^2 vs C_D')
plt.plot(C_Lsquared,corrected_C_D, 'y')
plt.xlabel('C_L^2')
plt.ylabel('C_D')
#<<<<<<< HEAD
plt.show()
'''
=======
plt.subplot(515)
plt.title('C_D vs alpha')
plt.plot(alpha_rad, corrected_C_D, 'g')
plt.xlabel('alpha')
plt.ylabel('C_D')
plt.show()
>>>>>>> 3402d9fb1c7a939ddfd89a411fc55cc2616abfd5
'''