stringer areas

Commit
18fd5385ec0ff1f303b38802d22cfec357f58b62
Author
Marius Peter <blendoit@gmail.com>
Author date
Committer
Marius Peter <blendoit@gmail.com>
Committer date
Changed files
creator.py
index 138fffbd..c7bbf033 100644..100644
@@ -69,10 +69,6 @@
69 69 def __str__(self):
70 70 return type(self).__name__
71 71
72 Removed: def add_area(self, area):
73 Removed: self.area = area
74 Removed: return None
75 Removed:
76 72 def print_info(self, round):
77 73 """
78 74 Print all the component's coordinates to the terminal.
@@ -301,6 +297,7 @@
301 297
302 298 def __init__(self):
303 299 super().__init__(parent.chord, parent.semi_span)
300 Added: self.area = float()
304 301
305 302 def add_coord(self, airfoil_coord, spar_coord,
306 303 stringer_u_1, stringer_u_2, stringer_l_1, stringer_l_2):
@@ -333,6 +330,7 @@
333 330 spar_z_l = spar_coord[3]
334 331 except:
335 332 print('Unable to initialize stringers. Were spars created?')
333 Added:
336 334 # Find distance between leading edge and first upper stringer
337 335 interval = spar_x_u[0] / (stringer_u_1 + 1)
338 336 # initialise first self.stringer_x_u at first interval
@@ -370,12 +368,21 @@
370 368 self.x_l.append(airfoil_x_l[index])
371 369 self.z_l.append(airfoil_z_l[index])
372 370 x += interval
373 Removed:
374 371 super().pack_info()
375 372 return None
376 373
374 Added: def add_area(self, area):
375 Added: self.area = area
376 Added: return None
377 Added:
377 378 def add_mass(self, mass):
378 379 self.mass = len(self.x_u) * mass + len(self.x_l) * mass
380 Added: return None
381 Added:
382 Added: def print_info(self, round):
383 Added: super().print_info(round)
384 Added: print('Stringer Area:\n', np.around(self.area, round))
385 Added: return None
379 386
380 387
381 388 def plot(airfoil, spar, stringer):
evaluator.py
index f3a05f46..4a65a4e8 100644..100644
@@ -20,6 +20,8 @@
20 20 pass
21 21
22 22
23 Removed: def get_mass(*component):
24 Removed: for _ in len(component):
25 Removed: mass += component.mass
23 Added: def get_total_mass(self, *component):
24 Added: total_mass = float()
25 Added: for _ in component:
26 Added: total_mass += _.mass
27 Added: return total_mass
main.py
index 1e591fde..be49d2fe 100644..100644
@@ -24,18 +24,25 @@
24 24 CHORD_LENGTH = 100
25 25 SEMI_SPAN = 200
26 26
27 Removed: # mass
27 Added: # m=Mass
28 28 AIRFOIL_MASS = 100 # lbs
29 29 SPAR_MASS = 10 # lbs
30 30 STRINGER_MASS = 5 # lbs
31 31
32 Added: # Area
33 Added: STRINGER_AREA = 0.1 # sqin
34 Added:
32 35 # population information
33 36 POP_SIZE = 1
34 37 SAVE_PATH = 'C:/Users/blend/github/UCLA_MAE_154B/save'
35 38
36 39
37 Removed: def create():
38 Removed: '''Create an airfoil.'''
40 Added: def main():
41 Added: '''
42 Added: Create an airfoil;
43 Added: Evaluate an airfoil;
44 Added: Generate a population of airfoils & optimize.
45 Added: '''
39 46
40 47 # Create coordinate system specific to our airfoil dimensions.
41 48 # TODO: imperial + metric unit setting
@@ -49,7 +56,7 @@
49 56 # Define NACA airfoil coordinates and mass
50 57 af.add_naca(2412)
51 58 af.add_mass(AIRFOIL_MASS)
52 Removed: af.print_info(2)
59 Added: # af.print_info(2)
53 60
54 61 # Create spar instance
55 62 af.spar = creator.Spar()
@@ -57,41 +64,32 @@
57 64 af.spar.add_coord(af.coord, 0.15)
58 65 af.spar.add_coord(af.coord, 0.55)
59 66 af.spar.add_mass(SPAR_MASS)
60 Removed: af.spar.print_info(2)
67 Added: # af.spar.print_info(2)
61 68
62 69 # Create stringer instance
63 70 af.stringer = creator.Stringer()
64 71 # Compute the stringer coordinates from their quantity in each zone
65 72 af.stringer.add_coord(af.coord, af.spar.coord, 4, 7, 5, 6)
73 Added: af.stringer.add_area(STRINGER_AREA)
66 74 af.stringer.add_mass(STRINGER_MASS)
67 75 af.stringer.print_info(2)
68 76
69 77 # Plot components with matplotlib
70 Removed: creator.plot(af, af.spar, af.stringer)
78 Added: # creator.plot(af, af.spar, af.stringer)
71 79
72 80 # Save component info
73 Removed: af.save_info(SAVE_PATH, _)
74 Removed: af.spar.save_info(SAVE_PATH, _)
75 Removed: af.stringer.save_info(SAVE_PATH, _)
81 Added: # af.save_info(SAVE_PATH, _)
82 Added: # af.spar.save_info(SAVE_PATH, _)
83 Added: # af.stringer.save_info(SAVE_PATH, _)
76 84
77 Removed: # Print final execution time
78 Removed: print("--- %s seconds ---" % (time.time() - start_time))
85 Added: # Evaluate previously created airfoil(s).
86 Added: total_mass = evaluator.get_total_mass(af, af.spar, af.stringer)
79 87
88 Added: # Iteratively evaluate airfoils by defining genetic generations.
89 Added: # pass
80 90
81 Removed: def evaluate():
82 Removed: '''Evaluate previously created airfoil(s).'''
83 Removed: pass
84 Removed:
85 Removed:
86 Removed: def generate():
87 Removed: '''Iteratively evaluate airfoils by defining genetic generations.'''
88 Removed: pass
89 Removed:
90 Removed:
91 Removed: def main():
92 Removed: create()
93 Removed: evaluate()
94 Removed: generate()
91 Added: # Print final execution time
92 Added: print("--- %s seconds ---" % (time.time() - start_time))
95 93
96 94
97 95 if __name__ == '__main__':