*ARCHIVED* development moved to aircraft-studio.
redefine plot() from class method to module method
Changed files
creator.py
@@ -224,56 +224,7 @@
224
224
print('z_c the camber z-coordinates:\n', np.around(self.x_u, round))
225
225
return None
226
226
227
Removed:
def plot(self):
228
Removed:
'''This function plots the entire airfoil's geometry.'''
229
227
230
Removed:
# Plot chord
231
Removed:
x_chord = [0, self.chord]
232
Removed:
y_chord = [0, 0]
233
Removed:
plt.plot(x_chord, y_chord, linewidth='1')
234
Removed:
# Plot quarter chord
235
Removed:
plt.plot(self.chord / 4, 0, '.', color='g', markersize=24)
236
Removed:
# Plot mean camber line
237
Removed:
plt.plot(self.x_c, self.y_c,
238
Removed:
'-.', color='r', linewidth='2',
239
Removed:
label='mean camber line')
240
Removed:
# Plot upper surface
241
Removed:
plt.plot(self.x_u, self.z_u,
242
Removed:
'', color='b', linewidth='1')
243
Removed:
# Plot lower surface
244
Removed:
plt.plot(self.x_l, self.z_l,
245
Removed:
'', color='b', linewidth='1')
246
Removed:
247
Removed:
# Plot spars
248
Removed:
for _ in range(0, len(self.spar.x_u)):
249
Removed:
x = (self.spar.x_u[_], self.spar.x_l[_])
250
Removed:
y = (self.spar.z_u[_], self.spar.z_l[_])
251
Removed:
plt.plot(x, y, '.-', color='b')
252
Removed:
253
Removed:
# Plot upper stringers
254
Removed:
for _ in range(0, len(self.stringer.x_u)):
255
Removed:
x = self.stringer.x_u[_]
256
Removed:
y = self.stringer.z_u[_]
257
Removed:
plt.plot(x, y, '.', color='y', markersize=12)
258
Removed:
# Plot lower stringers
259
Removed:
for _ in range(0, len(self.stringer.x_l)):
260
Removed:
x = self.stringer.x_l[_]
261
Removed:
y = self.stringer.z_l[_]
262
Removed:
plt.plot(x, y, '.', color='y', markersize=12)
263
Removed:
264
Removed:
# Graph formatting
265
Removed:
plt.xlabel('X axis')
266
Removed:
plt.ylabel('Z axis')
267
Removed:
268
Removed:
plot_bound = self.x_u[-1]
269
Removed:
plt.xlim(- 0.10 * plot_bound, 1.10 * plot_bound)
270
Removed:
plt.ylim(- (1.10 * plot_bound / 2), (1.10 * plot_bound / 2))
271
Removed:
plt.gca().set_aspect('equal', adjustable='box')
272
Removed:
plt.grid(axis='both', linestyle=':', linewidth=1)
273
Removed:
plt.show()
274
Removed:
return None
275
Removed:
276
Removed:
277
228
class Spar(Coordinates):
278
229
'''Contains a single spar's location.'''
279
230
global parent
@@ -409,6 +360,56 @@
409
360
super().info_print(round)
410
361
print('Stringer Area:\n', np.around(self.area, round))
411
362
return None
363
Added:
364
Added:
365
Added:
def plot(airfoil):
366
Added:
'''This function plots the airfoil's + sub-components' geometry.'''
367
Added:
368
Added:
# Plot chord
369
Added:
x_chord = [0, airfoil.chord]
370
Added:
y_chord = [0, 0]
371
Added:
plt.plot(x_chord, y_chord, linewidth='1')
372
Added:
# Plot quarter chord
373
Added:
plt.plot(airfoil.chord / 4, 0, '.', color='g', markersize=24)
374
Added:
# Plot mean camber line
375
Added:
plt.plot(airfoil.x_c, airfoil.y_c,
376
Added:
'-.', color='r', linewidth='2',
377
Added:
label='mean camber line')
378
Added:
# Plot upper surface
379
Added:
plt.plot(airfoil.x_u, airfoil.z_u,
380
Added:
'', color='b', linewidth='1')
381
Added:
# Plot lower surface
382
Added:
plt.plot(airfoil.x_l, airfoil.z_l,
383
Added:
'', color='b', linewidth='1')
384
Added:
385
Added:
# Plot spars
386
Added:
for _ in range(0, len(airfoil.spar.x_u)):
387
Added:
x = (airfoil.spar.x_u[_], airfoil.spar.x_l[_])
388
Added:
y = (airfoil.spar.z_u[_], airfoil.spar.z_l[_])
389
Added:
plt.plot(x, y, '.-', color='b')
390
Added:
391
Added:
# Plot upper stringers
392
Added:
for _ in range(0, len(airfoil.stringer.x_u)):
393
Added:
x = airfoil.stringer.x_u[_]
394
Added:
y = airfoil.stringer.z_u[_]
395
Added:
plt.plot(x, y, '.', color='y', markersize=12)
396
Added:
# Plot lower stringers
397
Added:
for _ in range(0, len(airfoil.stringer.x_l)):
398
Added:
x = airfoil.stringer.x_l[_]
399
Added:
y = airfoil.stringer.z_l[_]
400
Added:
plt.plot(x, y, '.', color='y', markersize=12)
401
Added:
402
Added:
# Graph formatting
403
Added:
plt.xlabel('X axis')
404
Added:
plt.ylabel('Z axis')
405
Added:
406
Added:
plot_bound = airfoil.x_u[-1]
407
Added:
plt.xlim(- 0.10 * plot_bound, 1.10 * plot_bound)
408
Added:
plt.ylim(- (1.10 * plot_bound / 2), (1.10 * plot_bound / 2))
409
Added:
plt.gca().set_aspect('equal', adjustable='box')
410
Added:
plt.grid(axis='both', linestyle=':', linewidth=1)
411
Added:
plt.show()
412
Added:
return None
412
413
413
414
414
415
def main():
evaluator.py
@@ -21,7 +21,7 @@
21
21
import matplotlib.pyplot as plt
22
22
23
23
24
Removed:
class Airfoil:
24
Added:
class Evaluator:
25
25
'''Performs structural evaluations for the airfoil passed as argument.'''
26
26
27
27
def __init__(self, airfoil):
@@ -143,7 +143,9 @@
143
143
return(x_centroid, z_centroid)
144
144
145
145
def get_I_x(self):
146
Removed:
pass
146
Added:
I_x = float()
147
Added:
i_x = int()
148
Added:
print(I_x)
147
149
148
150
def get_I_z(self):
149
151
pass
@@ -167,53 +169,54 @@
167
169
self.I_xz = self.get_I_xz()
168
170
return None
169
171
170
Removed:
def plot(self):
171
Removed:
'''This function plots analysis results over the airfoil's geometry.'''
172
172
173
Removed:
# Plot chord
174
Removed:
x_chord = [0, self.chord]
175
Removed:
y_chord = [0, 0]
176
Removed:
plt.plot(x_chord, y_chord, linewidth='1')
177
Removed:
# Plot quarter chord
178
Removed:
q = self.chord / 4
179
Removed:
plt.plot(q, 0, '.', color='g', markersize=24, label='quarter-chord')
180
Removed:
# Plot upper surface
181
Removed:
plt.plot(self.x_u, self.z_u,
182
Removed:
'', color='b', linewidth='1')
183
Removed:
# Plot lower surface
184
Removed:
plt.plot(self.x_l, self.z_l,
185
Removed:
'', color='b', linewidth='1')
173
Added:
def plot(evaluator):
174
Added:
'''This function plots analysis results over the airfoil's geometry.'''
186
175
187
Removed:
# Plot spars
188
Removed:
for _ in range(0, len(self.spar.x_u)):
189
Removed:
x = (self.spar.x_u[_], self.spar.x_l[_])
190
Removed:
y = (self.spar.z_u[_], self.spar.z_l[_])
191
Removed:
plt.plot(x, y, '.-', color='b')
176
Added:
# Plot chord
177
Added:
x_chord = [0, evaluator.chord]
178
Added:
y_chord = [0, 0]
179
Added:
plt.plot(x_chord, y_chord, linewidth='1')
180
Added:
# Plot quarter chord
181
Added:
q = evaluator.chord / 4
182
Added:
plt.plot(q, 0, '.', color='g', markersize=24, label='quarter-chord')
183
Added:
# Plot upper surface
184
Added:
plt.plot(evaluator.x_u, evaluator.z_u,
185
Added:
'', color='b', linewidth='1')
186
Added:
# Plot lower surface
187
Added:
plt.plot(evaluator.x_l, evaluator.z_l,
188
Added:
'', color='b', linewidth='1')
192
189
193
Removed:
# Plot upper stringers
194
Removed:
for _ in range(0, len(self.stringer.x_u)):
195
Removed:
x = self.stringer.x_u[_]
196
Removed:
y = self.stringer.z_u[_]
197
Removed:
plt.plot(x, y, '.', color='y', markersize=12)
198
Removed:
# Plot lower stringers
199
Removed:
for _ in range(0, len(self.stringer.x_l)):
200
Removed:
x = self.stringer.x_l[_]
201
Removed:
y = self.stringer.z_l[_]
202
Removed:
plt.plot(x, y, '.', color='y', markersize=12)
190
Added:
# Plot spars
191
Added:
for _ in range(0, len(evaluator.spar.x_u)):
192
Added:
x = (evaluator.spar.x_u[_], evaluator.spar.x_l[_])
193
Added:
y = (evaluator.spar.z_u[_], evaluator.spar.z_l[_])
194
Added:
plt.plot(x, y, '.-', color='b')
203
195
204
Removed:
# Plot centroid
205
Removed:
x = self.centroid[0]
206
Removed:
y = self.centroid[1]
207
Removed:
plt.plot(x, y, '.', color='r', markersize=24, label='centroid')
196
Added:
# Plot upper stringers
197
Added:
for _ in range(0, len(evaluator.stringer.x_u)):
198
Added:
x = evaluator.stringer.x_u[_]
199
Added:
y = evaluator.stringer.z_u[_]
200
Added:
plt.plot(x, y, '.', color='y', markersize=12)
201
Added:
# Plot lower stringers
202
Added:
for _ in range(0, len(evaluator.stringer.x_l)):
203
Added:
x = evaluator.stringer.x_l[_]
204
Added:
y = evaluator.stringer.z_l[_]
205
Added:
plt.plot(x, y, '.', color='y', markersize=12)
208
206
209
Removed:
# Graph formatting
210
Removed:
plt.xlabel('X axis')
211
Removed:
plt.ylabel('Z axis')
207
Added:
# Plot centroid
208
Added:
x = evaluator.centroid[0]
209
Added:
y = evaluator.centroid[1]
210
Added:
plt.plot(x, y, '.', color='r', markersize=24, label='centroid')
212
211
213
Removed:
plot_bound = self.x_u[-1]
214
Removed:
plt.xlim(- 0.10 * plot_bound, 1.10 * plot_bound)
215
Removed:
plt.ylim(- (1.10 * plot_bound / 2), (1.10 * plot_bound / 2))
216
Removed:
plt.gca().set_aspect('equal', adjustable='box')
217
Removed:
plt.grid(axis='both', linestyle=':', linewidth=1)
218
Removed:
plt.show()
219
Removed:
return None
212
Added:
# Graph formatting
213
Added:
plt.xlabel('X axis')
214
Added:
plt.ylabel('Z axis')
215
Added:
216
Added:
plot_bound = evaluator.x_u[-1]
217
Added:
plt.xlim(- 0.10 * plot_bound, 1.10 * plot_bound)
218
Added:
plt.ylim(- (1.10 * plot_bound / 2), (1.10 * plot_bound / 2))
219
Added:
plt.gca().set_aspect('equal', adjustable='box')
220
Added:
plt.grid(axis='both', linestyle=':', linewidth=1)
221
Added:
plt.show()
222
Added:
return None
main.py
@@ -13,6 +13,7 @@
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
15
16
Added:
16
17
import creator # Create geometry
17
18
import evaluator # Evaluate geometry
18
19
import generator # Iteratevely evaluate instances of geometry and optimize
@@ -88,15 +89,15 @@
88
89
af.stringer.info_save(SAVE_PATH, _)
89
90
90
91
# Plot components with matplotlib
91
Removed:
af.plot()
92
Added:
creator.plot(af)
92
93
93
94
# evaluator.Evaluator instance contains airfoil analysis results.
94
Removed:
eval = evaluator.Airfoil(af)
95
Added:
eval = evaluator.Evaluator(af)
95
96
# The analysis is performed in the evaluator.py module.
96
97
eval.analysis()
97
98
eval.info_print(2)
98
99
eval.info_save(SAVE_PATH, _)
99
Removed:
eval.plot()
100
Added:
evaluator.plot(eval)
100
101
101
102
# Print final execution time
102
103
print("--- %s seconds ---" % (time.time() - start_time))