spar caps added!

Commit
618b61d6e8781a03ce60725783815b37214024c2
Author
Marius Peter <blendoit@gmail.com>
Author date
Committer
Marius Peter <blendoit@gmail.com>
Committer date
Changed files
creator.py
index 97d28f56..e8bba684 100644..100644
@@ -254,6 +254,10 @@
254 254 self.z_l.append(z_l[spar_x_l])
255 255 return None
256 256
257 Added: def add_spar_caps(self, spar_cap_area):
258 Added: self.cap_area = spar_cap_area
259 Added: return None
260 Added:
257 261 def add_mass(self, mass):
258 262 self.mass = len(self.x_u) * mass
259 263 return None
evaluator.py
index 4ab94778..5710522c 100644..100644
@@ -27,9 +27,12 @@
27 27 def __init__(self, airfoil):
28 28 # Evaluator knows all geometrical info from evaluated airfoil
29 29 self.airfoil = airfoil
30 Added: self.spar = airfoil.spar
31 Added: self.stringer = airfoil.stringer
30 32 # Global dimensions
31 33 self.chord = airfoil.chord
32 34 self.semi_span = airfoil.semi_span
35 Added:
33 36 # mass and area
34 37 self.mass_total = float(airfoil.mass
35 38 + airfoil.spar.mass
@@ -41,11 +44,6 @@
41 44 # Lower coordinates
42 45 self.x_l = airfoil.x_l
43 46 self.z_l = airfoil.z_l
44 Removed: # Spars
45 Removed: self.spar = airfoil.spar
46 Removed: # Stringers
47 Removed: self.stringer = airfoil.stringer
48 Removed: # Lifts
49 47 self.lift_rectangular = []
50 48 self.lift_elliptical = []
51 49 self.lift_total = []
@@ -139,36 +137,52 @@
139 137
140 138 def get_centroid(self):
141 139 '''Return the coordinates of the centroid.'''
142 Removed: area = self.airfoil.stringer.area
140 Added: stringer_area = self.stringer.area
141 Added: caps_area = self.spar.cap_area
143 142
144 Removed: x_stringers = self.airfoil.stringer.x_u + self.airfoil.stringer.x_l
145 Removed: x_centroid = sum([x * area for x in x_stringers]) / \
146 Removed: (len(x_stringers) * area)
143 Added: x_spars = self.spar.x_u + self.spar.x_l
144 Added: x_stringers = self.stringer.x_u + self.stringer.x_l
145 Added: z_stringers = self.stringer.z_u + self.stringer.z_l
146 Added: denom = float(len(x_spars) * caps_area
147 Added: + len(x_stringers) * stringer_area)
147 148
148 Removed: z_stringers = self.airfoil.stringer.z_u + self.airfoil.stringer.z_l
149 Removed: z_centroid = sum([x * area for x in z_stringers]) / \
150 Removed: (len(x_stringers) * area)
151 Removed: return(x_centroid, z_centroid)
149 Added: x_ctr = (sum([i * caps_area for i in self.spar.x_u])
150 Added: + sum([i * stringer_area for i in x_stringers])) / denom
151 Added: z_ctr = (sum([i * caps_area for i in self.spar.z_u])
152 Added: + sum([i * stringer_area for i in z_stringers])) / denom
153 Added: return(x_ctr, z_ctr)
152 154
153 155 def get_inertia_terms(self):
154 156 '''Obtain all inertia terms.'''
155 157
156 Removed: area = self.stringer.area
158 Added: stringer_area = self.stringer.area
159 Added: caps_area = self.spar.cap_area
160 Added:
161 Added: # Adds upper and lower components' coordinates to list
157 162 x_stringers = self.stringer.x_u + self.stringer.x_l
158 163 z_stringers = self.stringer.z_u + self.stringer.z_l
164 Added: x_spars = self.spar.x_u + self.spar.x_l
165 Added: z_spars = self.spar.z_u + self.spar.z_l
159 166 stringer_count = range(len(x_stringers))
167 Added: spar_count = range(len(self.spar.x_u))
160 168
161 Removed: # I_x is the sum of (stringer area * z-distance to the centroid) ** 2,
162 Removed: # for all stringers.
163 Removed: I_x = sum([area * (z_stringers[_] - self.centroid[1]) ** 2
164 Removed: for _ in stringer_count])
169 Added: # I_x is the sum of the contributions of the spar caps and stringers
170 Added: I_x = (sum([caps_area * (z_spars[i] - self.centroid[1]) ** 2
171 Added: for i in spar_count])
172 Added: + sum([stringer_area * (z_stringers[i] - self.centroid[1]) ** 2
173 Added: for i in stringer_count]))
165 174
166 Removed: I_z = sum([area * (x_stringers[_] - self.centroid[0]) ** 2
167 Removed: for _ in stringer_count])
175 Added: I_z = (sum([caps_area * (x_spars[i] - self.centroid[0]) ** 2
176 Added: for i in spar_count])
177 Added: + sum([stringer_area * (x_stringers[i] - self.centroid[0]) ** 2
178 Added: for i in stringer_count]))
168 179
169 Removed: I_xz = sum([area * (z_stringers[_] - self.centroid[1])
170 Removed: * (x_stringers[_] - self.centroid[0])
171 Removed: for _ in stringer_count])
180 Added: I_xz = (sum([caps_area * (x_spars[i] - self.centroid[0])
181 Added: * (z_spars[i] - self.centroid[1])
182 Added: for i in spar_count])
183 Added: + sum([stringer_area * (x_stringers[i] - self.centroid[0])
184 Added: * (z_stringers[i] - self.centroid[1])
185 Added: for i in stringer_count]))
172 186
173 187 return(I_x, I_z, I_xz)
174 188
@@ -245,8 +259,10 @@
245 259 y_1 = evaluator.lift_rectangular
246 260 y_2 = evaluator.lift_elliptical
247 261 y_3 = evaluator.lift_total
248 Removed: plt.plot(x, y_1, '.', color='b', markersize=4, label='Rectangular lift')
249 Removed: plt.plot(x, y_2, '.', color='g', markersize=4, label='Elliptical lift')
262 Added: plt.plot(x, y_1, '.', color='b', markersize=4,
263 Added: label='Rectangular lift')
264 Added: plt.plot(x, y_2, '.', color='g', markersize=4,
265 Added: label='Elliptical lift')
250 266 plt.plot(x, y_3, '.', color='r', markersize=4, label='Total lift')
251 267
252 268 # Graph formatting
main.py
index 734b88ae..acaf7747 100644..100644
@@ -27,18 +27,24 @@
27 27 CHORD_LENGTH = 40
28 28 SEMI_SPAN = 50
29 29
30 Added: # Airfoil thickness
31 Added: T_UPPER = 0.1
32 Added: T_LOWER = 0.1
33 Added:
30 34 # Component masses
31 35 AIRFOIL_MASS = 10 # lbs
32 36 SPAR_MASS = 10 # lbs
33 37 STRINGER_MASS = 5 # lbs
34 38
35 39 # Area
40 Added: SPAR_CAP_AREA = 0.3 # sqin
36 41 STRINGER_AREA = 0.1 # sqin
42 Added:
37 43 # Amount of stringers
38 Removed: TOP_STRINGERS = 8
44 Added: TOP_STRINGERS = 7
39 45 BOTTOM_STRINGERS = 6
40 46 NOSE_TOP_STRINGERS = 4
41 Removed: NOSE_BOTTOM_STRINGERS = 7
47 Added: NOSE_BOTTOM_STRINGERS = 5
42 48
43 49 # population information & save path
44 50 POP_SIZE = 1
@@ -65,16 +71,18 @@
65 71 af.add_naca(NACA_NUM)
66 72 af.add_mass(AIRFOIL_MASS)
67 73 # af.info_print(2)
68 Removed: af.info_save(SAVE_PATH, _)
74 Added: # af.info_save(SAVE_PATH, _)
69 75
70 76 # Create spar instance
71 77 af.spar = creator.Spar()
72 78 # Define the spar coordinates and mass, stored in single spar object
73 79 af.spar.add_coord(af, 0.15)
74 80 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)
75 83 af.spar.add_mass(SPAR_MASS)
76 84 # af.spar.info_print(2)
77 Removed: af.spar.info_save(SAVE_PATH, _)
85 Added: # af.spar.info_save(SAVE_PATH, _)
78 86
79 87 # Create stringer instance
80 88 af.stringer = creator.Stringer()
@@ -87,7 +95,7 @@
87 95 af.stringer.add_area(STRINGER_AREA)
88 96 af.stringer.add_mass(STRINGER_MASS)
89 97 # af.stringer.info_print(2)
90 Removed: af.stringer.info_save(SAVE_PATH, _)
98 Added: # af.stringer.info_save(SAVE_PATH, _)
91 99
92 100 # Plot components with matplotlib
93 101 # creator.plot_geom(af)
@@ -98,7 +106,7 @@
98 106 eval.analysis()
99 107 # eval.info_print(2)
100 108 eval.info_save(SAVE_PATH, _)
101 Removed: # evaluator.plot_geom(eval)
109 Added: evaluator.plot_geom(eval)
102 110 # evaluator.plot_lift(eval)
103 111
104 112 # Print final execution time