airfoil coordinates

Commit
2c8e6e632eb03cd6545de51d72aaebe0df9bf7ee
Author
Marius Peter <blendoit@gmail.com>
Author date
Committer
Marius Peter <blendoit@gmail.com>
Committer date
Changed files
creator.py
index d75661f9..601e8497 100644..100644
@@ -186,18 +186,24 @@
186 186
187 187 # Densify x-coordinates 10 times for first 1/4 chord length
188 188 x_chord_25_percent = round(self.chord / 4)
189 Removed: x_chord = [x / 10 for x in range(x_chord_25_percent * 10)]
190 Removed: x_chord.extend([x for x in range(x_chord_25_percent, self.chord + 1)])
191 189
190 Added: x_chord = [i / 10 for i in range(x_chord_25_percent * 10)]
191 Added: x_chord.extend(i for i in range(x_chord_25_percent, self.chord + 1))
192 Added: # Reversed list for our lower airfoil coordinate densification
193 Added: x_chord_rev = [i for i in range(
194 Added: self.chord, x_chord_25_percent, -1)]
195 Added: ext = [i / 10 for i in range(x_chord_25_percent * 10, -1, -1)]
196 Added: x_chord_rev.extend(ext)
197 Added: print(len(x_chord))
198 Added: print(len(x_chord_rev))
199 Added:
192 200 # Generate our airfoil geometry from previous sub-functions.
193 201 for x in x_chord:
194 202 self.x_c.append(x)
195 203 self.y_c.append(get_camber(x))
196 204 self.x.append(get_upper_coord(x)[0])
197 205 self.z.append(get_upper_coord(x)[1])
198 Removed: # Behold the true power of Python list slicing!
199 Removed: # (This special list index reverses the list.)
200 Removed: for x in x_chord[::-1]:
206 Added: for x in x_chord_rev:
201 207 self.x.append(get_lower_coord(x)[0])
202 208 self.z.append(get_lower_coord(x)[1])
203 209 return None
@@ -232,7 +238,6 @@
232 238 None
233 239 '''
234 240 # Airfoil surface coordinates
235 Removed: # unpacked from 'coordinates' (list of lists in 'Coordinates').
236 241 x = airfoil.x
237 242 z = airfoil.z
238 243 # Scaled spar location with regards to chord
@@ -242,13 +247,21 @@
242 247 # bisect_right: returns index of first value in x > loc
243 248 # starting from [-1] (last list element).
244 249 # This ensures that the spar geom intersects with airfoil geom.
245 Removed: spar_x = bi.bisect_left(x, loc) # index of spar's x
246 Removed: spar_x = bi.bisect_left(x, loc) # index of spar's x
250 Added: spar_x_u = bi.bisect_left(x, loc) # index of spar's x_u
251 Added: spar_z_u = bi.bisect_left(z, loc)
252 Added: spar_x_l = bi.bisect_left(x[::-1], loc) # index of spar's x_l
253 Added: spar_z_l = bi.bisect_left(z[::-1], loc)
254 Added: print(len(x))
255 Added: print(len(z))
247 256 # These x and y coordinates are assigned to the spar, NOT airfoil.
248 Removed: self.x.append(x[spar_x])
249 Removed: self.z.append(z[spar_x])
250 Removed: self.x.append(x[spar_x])
251 Removed: self.z.append(z[spar_x])
257 Added: # print(spar_x_u)
258 Added: # print(spar_z_u)
259 Added: # print(spar_x_l)
260 Added: # print(spar_z_l)
261 Added: # self.x.append(x[spar_x_u])
262 Added: # self.z.append(z[spar_z_u])
263 Added: # self.x.append(x[spar_x_l])
264 Added: # self.z.append(z[spar_z_l])
252 265 return None
253 266
254 267 def add_spar_caps(self, spar_cap_area):
@@ -354,40 +367,38 @@
354 367 plt.plot(airfoil.chord / 4, 0, '.', color='g',
355 368 markersize=24, label='Quarter-chord')
356 369 # Plot mean camber line
357 Removed: plt.plot(airfoil.x_c, airfoil.y_c,
358 Removed: '-.', color='r', linewidth='2',
370 Added: plt.plot(airfoil.x_c, airfoil.y_c, '-.', color='r', linewidth='2',
359 371 label='Mean camber line')
360 Removed: # Plot upper surface
361 Removed: plt.plot(airfoil.x, airfoil.z,
362 Removed: '', color='b', linewidth='1')
363 Removed: # Plot lower surface
364 Removed: plt.plot(airfoil.x, airfoil.z,
365 Removed: '', color='b', linewidth='1')
372 Added: # Plot airfoil surfaces
373 Added: plt.fill(airfoil.x, airfoil.z, '', color='b', linewidth='1', fill=False)
366 374
367 375 # Plot spars
368 Removed: for _ in range(0, len(airfoil.spar.x)):
369 Removed: x = (airfoil.spar.x[_], airfoil.spar.x[_])
370 Removed: y = (airfoil.spar.z[_], airfoil.spar.z[_])
371 Removed: plt.plot(x, y, '.-', color='b')
372 Removed:
376 Added: try:
377 Added: for _ in range(0, len(airfoil.spar.x)):
378 Added: x = (airfoil.spar.x[_], airfoil.spar.x[_])
379 Added: y = (airfoil.spar.z[_], airfoil.spar.z[_])
380 Added: plt.plot(x, y, '.-', color='b')
381 Added: except AttributeError:
382 Added: print('No spars to plot.')
373 383 # Plot upper stringers
374 Removed: for _ in range(0, len(airfoil.stringer.x)):
375 Removed: x = airfoil.stringer.x[_]
376 Removed: y = airfoil.stringer.z[_]
377 Removed: plt.plot(x, y, '.', color='y', markersize=12)
378 Removed: # Plot lower stringers
379 Removed: for _ in range(0, len(airfoil.stringer.x)):
380 Removed: x = airfoil.stringer.x[_]
381 Removed: y = airfoil.stringer.z[_]
382 Removed: plt.plot(x, y, '.', color='y', markersize=12)
384 Added: try:
385 Added: for _ in range(0, len(airfoil.stringer.x)):
386 Added: x = airfoil.stringer.x[_]
387 Added: y = airfoil.stringer.z[_]
388 Added: plt.plot(x, y, '.', color='y', markersize=12)
389 Added: except AttributeError:
390 Added: print('No stringers to plot.')
391 Added: # # Plot lower stringers
392 Added: # for _ in range(0, len(airfoil.stringer.x)):
393 Added: # x = airfoil.stringer.x[_]
394 Added: # y = airfoil.stringer.z[_]
395 Added: # plt.plot(x, y, '.', color='y', markersize=12)
383 396
384 397 # Graph formatting
385 398 plt.xlabel('X axis')
386 399 plt.ylabel('Z axis')
387 400
388 Removed: plot_bound = airfoil.x[-1]
389 Removed: plt.xlim(- 0.10 * plot_bound, 1.10 * plot_bound)
390 Removed: plt.ylim(- (1.10 * plot_bound / 2), (1.10 * plot_bound / 2))
401 Added: # plot_bound = airfoil.x[-1]
391 402 plt.gca().set_aspect('equal', adjustable='box')
392 403 plt.gca().legend()
393 404 plt.grid(axis='both', linestyle=':', linewidth=1)
main.py
index fd8855f3..09d33e61 100644..100644
@@ -24,8 +24,8 @@
24 24
25 25 # Airfoil dimensions
26 26 NACA_NUM = 2412
27 Removed: CHORD_LENGTH = 40
28 Removed: SEMI_SPAN = 50
27 Added: CHORD_LENGTH = 12
28 Added: SEMI_SPAN = 20
29 29
30 30 # Airfoil thickness
31 31 T_UPPER = 0.1
@@ -41,9 +41,9 @@
41 41 STRINGER_AREA = 0.1 # sqin
42 42
43 43 # Amount of stringers
44 Removed: TOP_STRINGERS = 0
44 Added: TOP_STRINGERS = 2
45 45 BOTTOM_STRINGERS = 18
46 Removed: NOSE_TOP_STRINGERS = 0
46 Added: NOSE_TOP_STRINGERS = 5
47 47 NOSE_BOTTOM_STRINGERS = 5
48 48
49 49 # population information & save path
@@ -71,42 +71,42 @@
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 Removed: # Create spar instance
77 Removed: af.spar = creator.Spar()
78 Removed: # Define the spar coordinates and mass, stored in single spar object
79 Removed: af.spar.add_coord(af, 0.15)
80 Removed: af.spar.add_coord(af, 0.55)
81 Removed: # Automatically adds spar caps for all spars previously defined
82 Removed: af.spar.add_spar_caps(SPAR_CAP_AREA)
83 Removed: af.spar.add_mass(SPAR_MASS)
84 Removed: # af.spar.info_print(2)
85 Removed: # af.spar.info_save(SAVE_PATH, _)
76 Added: # # Create spar instance
77 Added: # af.spar = creator.Spar()
78 Added: # # Define the spar coordinates and mass, stored in single spar object
79 Added: # af.spar.add_coord(af, 0.15)
80 Added: # af.spar.add_coord(af, 0.55)
81 Added: # # Automatically adds spar caps for all spars previously defined
82 Added: # af.spar.add_spar_caps(SPAR_CAP_AREA)
83 Added: # af.spar.add_mass(SPAR_MASS)
84 Added: # # af.spar.info_print(2)
85 Added: # # af.spar.info_save(SAVE_PATH, _)
86 Added: #
87 Added: # # Create stringer instance
88 Added: # af.stringer = creator.Stringer()
89 Added: # # Compute the stringer coordinates from their quantity in each zone
90 Added: # af.stringer.add_coord(af,
91 Added: # NOSE_TOP_STRINGERS,
92 Added: # TOP_STRINGERS,
93 Added: # NOSE_BOTTOM_STRINGERS,
94 Added: # BOTTOM_STRINGERS)
95 Added: # af.stringer.add_area(STRINGER_AREA)
96 Added: # af.stringer.add_mass(STRINGER_MASS)
97 Added: # # af.stringer.info_print(2)
98 Added: # # af.stringer.info_save(SAVE_PATH, _)
86 99
87 Removed: # Create stringer instance
88 Removed: af.stringer = creator.Stringer()
89 Removed: # Compute the stringer coordinates from their quantity in each zone
90 Removed: af.stringer.add_coord(af,
91 Removed: NOSE_TOP_STRINGERS,
92 Removed: TOP_STRINGERS,
93 Removed: NOSE_BOTTOM_STRINGERS,
94 Removed: BOTTOM_STRINGERS)
95 Removed: af.stringer.add_area(STRINGER_AREA)
96 Removed: af.stringer.add_mass(STRINGER_MASS)
97 Removed: # af.stringer.info_print(2)
98 Removed: # af.stringer.info_save(SAVE_PATH, _)
99 Removed:
100 100 # Plot components with matplotlib
101 Removed: # creator.plot_geom(af)
101 Added: creator.plot_geom(af)
102 102
103 103 # Evaluator object contains airfoil analysis results.
104 Removed: eval = evaluator.Evaluator(af)
104 Added: # eval = evaluator.Evaluator(af)
105 105 # The analysis is performed in the evaluator.py module.
106 Removed: eval.analysis()
106 Added: # eval.analysis()
107 107 # eval.info_print(2)
108 Removed: eval.info_save(SAVE_PATH, _)
109 Removed: evaluator.plot_geom(eval)
108 Added: # eval.info_save(SAVE_PATH, _)
109 Added: # evaluator.plot_geom(eval)
110 110 # evaluator.plot_lift(eval)
111 111
112 112 # Print final execution time