Linux

Commit
6684ea0a2e6e7a8e992c18420c20d54d6c5b1aa2
Author
blendoit <blendoit@gmail.com>
Author date
Committer
blendoit <blendoit@gmail.com>
Committer date
Changed files
example_airfoil.py
index e0eb532c..56b2ffaa 100644..100644
@@ -10,7 +10,6 @@
10 10
11 11 from tools import creator, evaluator, generator
12 12
13 Removed:
14 13 import time
15 14 start_time = time.time()
16 15
@@ -40,7 +39,6 @@
40 39
41 40 SAVE_PATH = '/home/blendux/github/UCLA_MAE_154B/save/'
42 41
43 Removed:
44 42 # Create airfoil instance
45 43 af = creator.Airfoil.from_dimensions(CHORD_LENGTH, SEMI_SPAN)
46 44 af.add_naca(NACA_NUM)
@@ -63,11 +61,8 @@
63 61 # Create stringer instance
64 62 af.stringer = creator.Stringer()
65 63 # Compute the stringer coordinates from their quantity in each zone
66 Removed: af.stringer.add_coord(af,
67 Removed: NOSE_TOP_STRINGERS,
68 Removed: TOP_STRINGERS,
69 Removed: NOSE_BOTTOM_STRINGERS,
70 Removed: BOTTOM_STRINGERS)
64 Added: af.stringer.add_coord(af, NOSE_TOP_STRINGERS, TOP_STRINGERS,
65 Added: NOSE_BOTTOM_STRINGERS, BOTTOM_STRINGERS)
71 66 af.stringer.add_area(STRINGER_AREA)
72 67 af.stringer.add_mass(STRINGER_MASS)
73 68 af.stringer.add_webs(SKIN_THICKNESS)
tools/creator.py
index 6d074f81..d345a00a 100644..100644
@@ -12,7 +12,6 @@
12 12 #
13 13 # You should have received a copy of the GNU General Public License
14 14 # along with this program. If not, see <https://www.gnu.org/licenses/>.
15 Removed:
16 15 """
17 16 The creator.py module contains class definitions for coordinates
18 17 and various components we add to an airfoil (spars, stringers, and ribs).
@@ -57,7 +56,7 @@
57 56 self.area = float()
58 57 # Component material
59 58 self.material = str()
60 Removed: # Coordinates
59 Added: # Coordinate
61 60 self.x = []
62 61 self.z = []
63 62
@@ -102,31 +101,32 @@
102 101 """
103 102 z_c = float()
104 103 if 0 <= x < p_c:
105 Removed: z_c = (m / (p ** 2)) * (2 * p * (x / self.chord)
106 Removed: - (x / self.chord) ** 2)
104 Added: z_c = (m / (p**2)) * (2 * p * (x / self.chord) -
105 Added: (x / self.chord)**2)
107 106 elif p_c <= x <= self.chord:
108 Removed: z_c = (m / ((1 - p) ** 2)) * ((1 - 2 * p)
109 Removed: + 2 * p * (x / self.chord)
110 Removed: - (x / self.chord) ** 2)
107 Added: z_c = (m /
108 Added: ((1 - p)**2)) * ((1 - 2 * p) + 2 * p *
109 Added: (x / self.chord) - (x / self.chord)**2)
111 110 return (z_c * self.chord)
112 111
113 112 def get_thickness(x):
114 113 """Return thickness from 1 'x' along the airfoil chord."""
115 114 x = 0 if x < 0 else x
116 Removed: z_t = 5 * t * self.chord * (
117 Removed: + 0.2969 * (x / self.chord) ** 0.5
118 Removed: - 0.1260 * (x / self.chord) ** 1
119 Removed: - 0.3516 * (x / self.chord) ** 2
120 Removed: + 0.2843 * (x / self.chord) ** 3
121 Removed: - 0.1015 * (x / self.chord) ** 4)
115 Added: z_t = 5 * t * self.chord * (+0.2969 *
116 Added: (x / self.chord)**0.5 - 0.1260 *
117 Added: (x / self.chord)**1 - 0.3516 *
118 Added: (x / self.chord)**2 + 0.2843 *
119 Added: (x / self.chord)**3 - 0.1015 *
120 Added: (x / self.chord)**4)
122 121 return z_t
123 122
124 123 def get_theta(x):
125 124 dz_c = float()
126 125 if 0 <= x < p_c:
127 Removed: dz_c = ((2 * m) / p ** 2) * (p - x / self.chord)
126 Added: dz_c = ((2 * m) / p**2) * (p - x / self.chord)
128 127 elif p_c <= x <= self.chord:
129 Removed: dz_c = (2 * m) / ((1 - p) ** 2) * (p - x / self.chord)
128 Added: dz_c = (2 * m) / ((1 - p)**2) * (p - x / self.chord)
129 Added:
130 130 theta = atan(dz_c)
131 131 return theta
132 132
@@ -192,15 +192,14 @@
192 192 sys.stdout = sys.__stdout__
193 193 print('Successfully wrote to file {}'.format(full_path))
194 194 except IOError:
195 Removed: print('Unable to write {} to specified directory.\n'
196 Removed: .format(file_name),
197 Removed: 'Was the full path passed to the function?')
195 Added: print(
196 Added: 'Unable to write {} to specified directory.\n'.format(
197 Added: file_name), 'Was the full path passed to the function?')
198 198 return None
199 199
200 200
201 201 class Spar(Airfoil):
202 202 """Contains a single spar's location."""
203 Removed:
204 203 def __init__(self):
205 204 super().__init__()
206 205 self.x_start = []
@@ -257,7 +256,6 @@
257 256
258 257 class Stringer(Airfoil):
259 258 """Contains the coordinates of all stringers."""
260 Removed:
261 259 def __init__(self):
262 260 super().__init__()
263 261 self.x_start = []
@@ -267,9 +265,8 @@
267 265 self.z_end = []
268 266 self.area = float()
269 267
270 Removed: def add_coord(self, airfoil,
271 Removed: stringer_u_1, stringer_u_2,
272 Removed: stringer_l_1, stringer_l_2):
268 Added: def add_coord(self, airfoil, stringer_u_1, stringer_u_2, stringer_l_1,
269 Added: stringer_l_2):
273 270 """Add equally distributed stringers to four airfoil locations
274 271 (upper nose, lower nose, upper surface, lower surface).
275 272
@@ -298,8 +295,8 @@
298 295 x += interval
299 296 # Add upper stringers from first spar until last spar
300 297 # TODO: stringer placement if only one spar is created
301 Removed: interval = (airfoil.spar.x[-1][0]
302 Removed: - airfoil.spar.x[0][0]) / (stringer_u_2 + 1)
298 Added: interval = (airfoil.spar.x[-1][0] -
299 Added: airfoil.spar.x[0][0]) / (stringer_u_2 + 1)
303 300 x = interval + airfoil.spar.x[0][0]
304 301 for _ in range(0, stringer_u_2):
305 302 i = bi.bisect_left(airfoil.x, x)
@@ -317,8 +314,8 @@
317 314 self.z.append(airfoil.z[-i])
318 315 x += interval
319 316 # Add lower stringers from first spar until last spar
320 Removed: interval = (airfoil.spar.x[-1][1]
321 Removed: - airfoil.spar.x[0][1]) / (stringer_l_2 + 1)
317 Added: interval = (airfoil.spar.x[-1][1] -
318 Added: airfoil.spar.x[0][1]) / (stringer_l_2 + 1)
322 319 x = interval + airfoil.spar.x[0][1]
323 320 for _ in range(0, stringer_l_2):
324 321 i = bi.bisect_left(airfoil.x[::-1], x)
@@ -360,16 +357,21 @@
360 357 y = [0, 0]
361 358 ax.plot(x, y, linewidth='1')
362 359 # Plot quarter chord
363 Removed: ax.plot(airfoil.chord / 4, 0,
364 Removed: '.', color='g', markersize=24,
360 Added: ax.plot(airfoil.chord / 4,
361 Added: 0,
362 Added: '.',
363 Added: color='g',
364 Added: markersize=24,
365 365 label='Quarter-chord')
366 366 # Plot mean camber line
367 Removed: ax.plot(airfoil.x_c, airfoil.z_c,
368 Removed: '-.', color='r', linewidth='2',
367 Added: ax.plot(airfoil.x_c,
368 Added: airfoil.z_c,
369 Added: '-.',
370 Added: color='r',
371 Added: linewidth='2',
369 372 label='Mean camber line')
370 373 # Plot airfoil surfaces
371 Removed: ax.plot(airfoil.x, airfoil.z,
372 Removed: color='b', linewidth='1')
374 Added: ax.plot(airfoil.x, airfoil.z, color='b', linewidth='1')
373 375
374 376 # Plot spars
375 377 try:
@@ -392,9 +394,9 @@
392 394 plot_bound = max(airfoil.x)
393 395 ax.set(title='NACA ' + str(airfoil.naca_num) + ' airfoil',
394 396 xlabel='X axis',
395 Removed: xlim=[- 0.10 * plot_bound, 1.10 * plot_bound],
397 Added: xlim=[-0.10 * plot_bound, 1.10 * plot_bound],
396 398 ylabel='Z axis',
397 Removed: ylim=[- (1.10 * plot_bound / 2), (1.10 * plot_bound / 2)])
399 Added: ylim=[-(1.10 * plot_bound / 2), (1.10 * plot_bound / 2)])
398 400
399 401 plt.grid(axis='both', linestyle=':', linewidth=1)
400 402 plt.gca().set_aspect('equal', adjustable='box')