*ARCHIVED* development moved to aircraft-studio.
deleted get_dy_c to reduce cyclomatic complexity
creator.py
@@ -45,9 +45,7 @@
45
45
46
46
def __init__(self, chord, semi_span):
47
47
# Global dimensions
48
Removed:
self.chord = chord
49
Removed:
if chord < 10:
50
Removed:
self.chord = 10
48
Added:
self.chord = chord if chord > 10 else 10
51
49
self.semi_span = semi_span
52
50
# mass and area
53
51
self.mass = float()
@@ -164,12 +162,12 @@
164
162
x_c = x
165
163
y_c = float()
166
164
if 0 <= x < p_c:
167
Removed:
y_c = (m / (p**2)) * (2 * p * (x / self.chord) -
168
Removed:
(x / self.chord)**2)
165
Added:
y_c = (m / (p**2)) * (2 * p * (x / self.chord)
166
Added:
- (x / self.chord)**2)
169
167
elif p_c <= x <= self.chord:
170
Removed:
y_c = (m /
171
Removed:
((1 - p)**2)) * ((1 - 2 * p) + 2 * p *
172
Removed:
(x / self.chord) - (x / self.chord)**2)
168
Added:
y_c = (m / ((1 - p)**2)) * ((1 - 2 * p)
169
Added:
+ 2 * p * (x / self.chord)
170
Added:
- (x / self.chord)**2)
173
171
else:
174
172
print('x-coordinate for camber is out of bounds. '
175
173
'Check that 0 < x <= chord.')
@@ -181,29 +179,23 @@
181
179
"""
182
180
y_t = float()
183
181
if 0 <= x <= self.chord:
184
Removed:
y_t = 5 * t * self.chord * (0.2969 * sqrt(x / self.chord) -
185
Removed:
0.1260 *
186
Removed:
(x / self.chord) - 0.3516 *
187
Removed:
(x / self.chord)**2 + 0.2843 *
188
Removed:
(x / self.chord)**3 - 0.1015 *
189
Removed:
(x / self.chord)**4)
182
Added:
y_t = 5 * t * self.chord * (
183
Added:
+0.2969 * sqrt(x / self.chord)
184
Added:
- 0.1260 * (x / self.chord)
185
Added:
- 0.3516 * (x / self.chord)**2
186
Added:
+ 0.2843 * (x / self.chord)**3
187
Added:
- 0.1015 * (x / self.chord)**4)
190
188
else:
191
189
print('x-coordinate for thickness is out of bounds. '
192
190
'Check that 0 < x <= chord.')
193
191
return y_t
194
192
195
Removed:
def get_dy_c(x):
196
Removed:
"""
197
Removed:
Returns dy_c/dx from 1 'x' along the airfoil chord.
198
Removed:
"""
193
Added:
def get_theta(x):
199
194
dy_c = float()
200
195
if 0 <= x < p_c:
201
196
dy_c = ((2 * m) / p**2) * (p - x / self.chord)
202
197
elif p_c <= x <= self.chord:
203
198
dy_c = (2 * m) / ((1 - p)**2) * (p - x / self.chord)
204
Removed:
return dy_c
205
Removed:
206
Removed:
def get_theta(dy_c):
207
199
theta = atan(dy_c)
208
200
return theta
209
201
@@ -211,10 +203,11 @@
211
203
x_u = float()
212
204
z_u = float()
213
205
if 0 <= x < self.chord:
214
Removed:
x_u = x - self.y_t[x] * sin(self.theta[x])
215
Removed:
z_u = self.y_c[x] + self.y_t[x] * cos(self.theta[x])
206
Added:
x_u = x - get_thickness(x) * sin(get_theta(x))
207
Added:
z_u = get_camber(x)[1] + get_thickness(x) * \
208
Added:
cos(get_theta(x))
216
209
elif x == self.chord:
217
Removed:
x_u = x - self.y_t[x] * sin(self.theta[x])
210
Added:
x_u = x - get_thickness(x) * sin(get_theta(x))
218
211
z_u = 0 # Make upper curve finish at y = 0
219
212
return (x_u, z_u)
220
213
@@ -222,20 +215,28 @@
222
215
x_l = float()
223
216
z_l = float()
224
217
if 0 <= x < self.chord:
225
Removed:
x_l = (x + self.y_t[x] * sin(self.theta[x]))
226
Removed:
z_l = (self.y_c[x] - self.y_t[x] * cos(self.theta[x]))
218
Added:
x_l = (x + get_thickness(x) * sin(get_theta(x)))
219
Added:
z_l = (get_camber(x)[1] - get_thickness(x)
220
Added:
* cos(get_theta(x)))
227
221
elif x == self.chord:
228
Removed:
x_l = (x + self.y_t[x] * sin(self.theta[x]))
222
Added:
x_l = (x + get_thickness(x) * sin(get_theta(x)))
229
223
z_l = 0 # Make lower curve finish at y = 0
230
224
return (x_l, z_l)
231
225
232
Removed:
# Generate all our wing geometries from previous sub-functions
233
Removed:
for x in range(0, self.chord + 1):
226
Added:
# Generate our airfoil geometry from previous sub-functions.
227
Added:
# Geometry is densest at leading edge: airfoil slope is highest here.
228
Added:
x_chord_10_percent = round(self.chord / 10)
229
Added:
# Densify x-coordinates 10 times for first 10% of the chord length
230
Added:
x_chord = [x / 10 for x in range(x_chord_10_percent * 10)]
231
Added:
x_chord.extend([x for x in range(x_chord_10_percent, self.chord + 1)])
232
Added:
print(x_chord)
233
Added:
234
Added:
for x in x_chord:
234
235
self.x_c.append(get_camber(x)[0])
235
236
self.y_c.append(get_camber(x)[1])
236
237
self.y_t.append(get_thickness(x))
237
Removed:
self.dy_c.append(get_dy_c(x))
238
Removed:
self.theta.append(get_theta(self.dy_c[x]))
238
Added:
self.dy_c.append(x)
239
Added:
self.theta.append(get_theta(x))
239
240
self.x_u.append(get_upper_coordinates(x)[0])
240
241
self.z_u.append(get_upper_coordinates(x)[1])
241
242
self.x_l.append(get_lower_coordinates(x)[0])