*ARCHIVED* development moved to aircraft-studio.
bugfix: negative x-coord error for high-camber cases
Changed files
creator.py
@@ -122,7 +122,7 @@
122
122
self.naca_num = int()
123
123
# Mean camber line
124
124
self.x_c = []
125
Removed:
self.y_c = []
125
Added:
self.z_c = []
126
126
127
127
def add_naca(self, naca_num):
128
128
'''
@@ -148,22 +148,22 @@
148
148
149
149
def get_camber(x):
150
150
'''
151
Removed:
Returns camber y-coordinate from 1 'x' along the airfoil chord.
151
Added:
Returns camber z-coordinate from 1 'x' along the airfoil chord.
152
152
'''
153
Removed:
y_c = float()
153
Added:
z_c = float()
154
154
if 0 <= x < p_c:
155
Removed:
y_c = (m / (p ** 2)) * (2 * p * (x / self.chord)
155
Added:
z_c = (m / (p ** 2)) * (2 * p * (x / self.chord)
156
156
- (x / self.chord) ** 2)
157
157
elif p_c <= x <= self.chord:
158
Removed:
y_c = (m / ((1 - p) ** 2)) * ((1 - 2 * p)
158
Added:
z_c = (m / ((1 - p) ** 2)) * ((1 - 2 * p)
159
159
+ 2 * p * (x / self.chord)
160
160
- (x / self.chord) ** 2)
161
Removed:
return (y_c * self.chord)
161
Added:
return (z_c * self.chord)
162
162
163
163
def get_thickness(x):
164
Removed:
'''
165
Removed:
Returns thickness from 1 'x' along the airfoil chord.
166
Removed:
'''
164
Added:
'''Returns thickness from 1 'x' along the airfoil chord.'''
165
Added:
166
Added:
x = 0 if x < 0 else x
167
167
y_t = 5 * t * self.chord * (
168
168
+ 0.2969 * sqrt(x / self.chord)
169
169
- 0.1260 * (x / self.chord)
@@ -173,12 +173,12 @@
173
173
return y_t
174
174
175
175
def get_theta(x):
176
Removed:
dy_c = float()
176
Added:
dz_c = float()
177
177
if 0 <= x < p_c:
178
Removed:
dy_c = ((2 * m) / p ** 2) * (p - x / self.chord)
178
Added:
dz_c = ((2 * m) / p ** 2) * (p - x / self.chord)
179
179
elif p_c <= x <= self.chord:
180
Removed:
dy_c = (2 * m) / ((1 - p) ** 2) * (p - x / self.chord)
181
Removed:
theta = atan(dy_c)
180
Added:
dz_c = (2 * m) / ((1 - p) ** 2) * (p - x / self.chord)
181
Added:
theta = atan(dz_c)
182
182
return theta
183
183
184
184
def get_upper_coord(x):
@@ -204,7 +204,7 @@
204
204
# Generate our airfoil geometry from previous sub-functions.
205
205
for x in x_chord:
206
206
self.x_c.append(x)
207
Removed:
self.y_c.append(get_camber(x))
207
Added:
self.z_c.append(get_camber(x))
208
208
self.x.append(get_upper_coord(x)[0])
209
209
self.z.append(get_upper_coord(x)[1])
210
210
for x in x_chord_rev:
@@ -361,7 +361,7 @@
361
361
plt.plot(airfoil.chord / 4, 0, '.', color='g',
362
362
markersize=24, label='Quarter-chord')
363
363
# Plot mean camber line
364
Removed:
plt.plot(airfoil.x_c, airfoil.y_c, '-.', color='r', linewidth='2',
364
Added:
plt.plot(airfoil.x_c, airfoil.z_c, '-.', color='r', linewidth='2',
365
365
label='Mean camber line')
366
366
# Plot airfoil surfaces
367
367
plt.fill(airfoil.x, airfoil.z, color='b', linewidth='1', fill=False)
@@ -374,7 +374,7 @@
374
374
plt.plot(x, y, '-', color='b')
375
375
except AttributeError:
376
376
print('No spars to plot.')
377
Removed:
# Plot upper stringers
377
Added:
# Plot stringers
378
378
try:
379
379
for _ in range(0, len(airfoil.stringer.x)):
380
380
x = airfoil.stringer.x[_]
@@ -382,11 +382,6 @@
382
382
plt.plot(x, y, '.', color='y', markersize=12)
383
383
except AttributeError:
384
384
print('No stringers to plot.')
385
Removed:
# # Plot lower stringers
386
Removed:
# for _ in range(0, len(airfoil.stringer.x)):
387
Removed:
# x = airfoil.stringer.x[_]
388
Removed:
# y = airfoil.stringer.z[_]
389
Removed:
# plt.plot(x, y, '.', color='y', markersize=12)
390
385
391
386
# Graph formatting
392
387
plt.xlabel('X axis')
evaluator.py
@@ -49,6 +49,8 @@
49
49
self.lift_total = []
50
50
# Drag
51
51
self.drag = []
52
Added:
# centroid
53
Added:
self.centroid = []
52
54
# Inertia terms:
53
55
# I_x = self.I_[0]
54
56
# I_z = self.I_[1]
@@ -141,19 +143,23 @@
141
143
stringer_area = self.stringer.area
142
144
caps_area = self.spar.cap_area
143
145
144
Removed:
spar_x = self.spar.x + self.spar.x
146
Added:
caps_x = [value for spar in self.spar.x for value in spar]
147
Added:
caps_z = [value for spar in self.spar.z for value in spar]
145
148
stringers_x = self.stringer.x
146
149
stringers_z = self.stringer.z
147
150
148
Removed:
denom = float(len(spar_x) * caps_area
149
Removed:
+ len(stringers_x) * stringer_area)
151
Added:
denominator = float(len(caps_x) * caps_area
152
Added:
+ len(stringers_x) * stringer_area)
150
153
151
Removed:
x_ctr = (sum([i * caps_area for i in spar_x[:][0]])
152
Removed:
+ sum([i * stringer_area for i in stringers_x])) / denom
153
Removed:
z_ctr = (sum([i * caps_area for i in spar_x[:][0]])
154
Removed:
+ sum([i * stringer_area for i in stringers_z])) / denom
155
Removed:
return(x_ctr, z_ctr)
154
Added:
centroid_x = float(sum([x * caps_area for x in caps_x])
155
Added:
+ sum([x * stringer_area for x in stringers_x]))
156
Added:
centroid_x = centroid_x / denominator
156
157
158
Added:
centroid_z = float(sum([z * caps_area for z in caps_z])
159
Added:
+ sum([z * stringer_area for z in stringers_z]))
160
Added:
centroid_z = centroid_z / denominator
161
Added:
return(centroid_x, centroid_z)
162
Added:
157
163
def get_inertia_terms(self):
158
164
'''Obtain all inertia terms.'''
159
165
@@ -165,7 +171,6 @@
165
171
z_stringers = self.stringer.z
166
172
x_spars = self.spar.x[:][0] + self.spar.x[:][1]
167
173
z_spars = self.spar.z[:][0] + self.spar.z[:][1]
168
Removed:
print(x_spars)
169
174
stringer_count = range(len(x_stringers))
170
175
spar_count = range(len(self.spar.x))
171
176
main.py
@@ -23,9 +23,9 @@
23
23
start_time = time.time()
24
24
25
25
# Airfoil dimensions
26
Removed:
NACA_NUM = 4412
27
Removed:
CHORD_LENGTH = 133
28
Removed:
SEMI_SPAN = 140
26
Added:
NACA_NUM = 2412
27
Added:
CHORD_LENGTH = 101
28
Added:
SEMI_SPAN = 40
29
29
30
30
# Airfoil thickness
31
31
T_UPPER = 0.1
@@ -37,11 +37,11 @@
37
37
STRINGER_MASS = 5 # lbs
38
38
39
39
# Area
40
Removed:
SPAR_CAP_AREA = 0.3 # sqin
40
Added:
SPAR_CAP_AREA = 0.0 # sqin
41
41
STRINGER_AREA = 0.1 # sqin
42
42
43
43
# Amount of stringers
44
Removed:
TOP_STRINGERS = 5
44
Added:
TOP_STRINGERS = 3
45
45
BOTTOM_STRINGERS = 4
46
46
NOSE_TOP_STRINGERS = 3
47
47
NOSE_BOTTOM_STRINGERS = 6
@@ -71,7 +71,7 @@
71
71
af.add_naca(NACA_NUM)
72
72
af.add_mass(AIRFOIL_MASS)
73
73
# af.info_print(2)
74
Removed:
# af.info_save(SAVE_PATH, _)
74
Added:
af.info_save(SAVE_PATH, _)
75
75
76
76
# Create spar instance
77
77
af.spar = creator.Spar()
@@ -82,7 +82,7 @@
82
82
af.spar.add_spar_caps(SPAR_CAP_AREA)
83
83
af.spar.add_mass(SPAR_MASS)
84
84
# af.spar.info_print(2)
85
Removed:
# af.spar.info_save(SAVE_PATH, _)
85
Added:
af.spar.info_save(SAVE_PATH, _)
86
86
87
87
# Create stringer instance
88
88
af.stringer = creator.Stringer()
@@ -95,7 +95,7 @@
95
95
af.stringer.add_area(STRINGER_AREA)
96
96
af.stringer.add_mass(STRINGER_MASS)
97
97
# af.stringer.info_print(2)
98
Removed:
# af.stringer.info_save(SAVE_PATH, _)
98
Added:
af.stringer.info_save(SAVE_PATH, _)
99
99
100
100
# Plot components with matplotlib
101
101
# creator.plot_geom(af)
@@ -106,7 +106,7 @@
106
106
eval.analysis()
107
107
# eval.info_print(2)
108
108
eval.info_save(SAVE_PATH, _)
109
Removed:
evaluator.plot_geom(eval)
109
Added:
# evaluator.plot_geom(eval)
110
110
# evaluator.plot_lift(eval)
111
111
112
112
# Print final execution time