*ARCHIVED* development moved to aircraft-studio.
get all inertia terms
Changed files
creator.py
@@ -362,7 +362,7 @@
362
362
return None
363
363
364
364
365
Removed:
def plot(airfoil):
365
Added:
def plot_geom(airfoil):
366
366
'''This function plots the airfoil's + sub-components' geometry.'''
367
367
368
368
# Plot chord
@@ -370,11 +370,12 @@
370
370
y_chord = [0, 0]
371
371
plt.plot(x_chord, y_chord, linewidth='1')
372
372
# Plot quarter chord
373
Removed:
plt.plot(airfoil.chord / 4, 0, '.', color='g', markersize=24)
373
Added:
plt.plot(airfoil.chord / 4, 0, '.', color='g',
374
Added:
markersize=24, label='Quarter-chord')
374
375
# Plot mean camber line
375
376
plt.plot(airfoil.x_c, airfoil.y_c,
376
377
'-.', color='r', linewidth='2',
377
Removed:
label='mean camber line')
378
Added:
label='Mean camber line')
378
379
# Plot upper surface
379
380
plt.plot(airfoil.x_u, airfoil.z_u,
380
381
'', color='b', linewidth='1')
@@ -407,6 +408,7 @@
407
408
plt.xlim(- 0.10 * plot_bound, 1.10 * plot_bound)
408
409
plt.ylim(- (1.10 * plot_bound / 2), (1.10 * plot_bound / 2))
409
410
plt.gca().set_aspect('equal', adjustable='box')
411
Added:
plt.gca().legend()
410
412
plt.grid(axis='both', linestyle=':', linewidth=1)
411
413
plt.show()
412
414
return None
evaluator.py
@@ -25,8 +25,8 @@
25
25
'''Performs structural evaluations for the airfoil passed as argument.'''
26
26
27
27
def __init__(self, airfoil):
28
Added:
# Evaluator knows all geometrical info from evaluated airfoil
28
29
self.airfoil = airfoil
29
Removed:
print(self.airfoil)
30
30
# Global dimensions
31
31
self.chord = airfoil.chord
32
32
self.semi_span = airfoil.semi_span
@@ -48,10 +48,14 @@
48
48
# Lifts
49
49
self.lift_rectangular = []
50
50
self.lift_elliptical = []
51
Removed:
self.lift = []
52
Removed:
51
Added:
self.lift_total = []
53
52
# Drag
54
53
self.drag = []
54
Added:
# Inertia terms:
55
Added:
# I_x = self.I_[0]
56
Added:
# I_z = self.I_[1]
57
Added:
# I_xz = self.I_[2]
58
Added:
self.I_ = []
55
59
56
60
def info_print(self, round):
57
61
'''
@@ -69,20 +73,24 @@
69
73
print('Chord length:', self.chord)
70
74
print('Semi-span:', self.semi_span)
71
75
print('Total airfoil mass:', self.mass_total)
72
Removed:
print('Centroid location:', np.around(self.centroid, round + 1))
76
Added:
print('Centroid location:\n', np.around(self.centroid, 3))
77
Added:
print('Inertia terms:')
78
Added:
print('I_x:\n', np.around(self.I_[0], 3))
79
Added:
print('I_z:\n', np.around(self.I_[1], 3))
80
Added:
print('I_xz:\n', np.around(self.I_[2], 3))
73
81
print(num_of_dashes * '-')
74
82
print('Rectangular lift:\n', np.around(self.lift_rectangular, round))
75
83
print('Elliptical lift:\n', np.around(self.lift_elliptical, round))
76
Removed:
print('Combined lift:\n', np.around(self.lift, round))
84
Added:
print('Combined lift:\n', np.around(self.lift_total, round))
77
85
print('Distribution of mass:\n', np.around(self.mass_dist, round))
78
86
print('Drag:\n', np.around(self.drag, round))
79
87
return None
80
88
81
Removed:
def info_save(self, save_dir_path, number):
89
Added:
def info_save(self, save_path, number):
82
90
'''Save all the object's coordinates (must be full path).'''
83
91
84
92
file_name = 'airfoil_{}_eval.txt'.format(number)
85
Removed:
full_path = os.path.join(save_dir_path, file_name)
93
Added:
full_path = os.path.join(save_path, file_name)
86
94
try:
87
95
with open(full_path, 'w') as sys.stdout:
88
96
self.info_print(6)
@@ -142,35 +150,44 @@
142
150
(len(x_stringers) * area)
143
151
return(x_centroid, z_centroid)
144
152
145
Removed:
def get_I_x(self):
146
Removed:
I_x = float()
147
Removed:
i_x = int()
148
Removed:
print(I_x)
153
Added:
def get_inertia_terms(self):
154
Added:
'''Obtain all inertia terms.'''
149
155
150
Removed:
def get_I_z(self):
151
Removed:
pass
156
Added:
area = self.stringer.area
157
Added:
x_stringers = self.stringer.x_u + self.stringer.x_l
158
Added:
z_stringers = self.stringer.z_u + self.stringer.z_l
159
Added:
stringer_count = range(len(x_stringers))
152
160
153
Removed:
def get_I_xz(self):
154
Removed:
pass
161
Added:
# I_x is the sum of (stringer area * z-distance to the centroid) ** 2,
162
Added:
# for all stringers.
163
Added:
I_x = sum([area * (z_stringers[_] - self.centroid[1]) ** 2
164
Added:
for _ in stringer_count])
155
165
166
Added:
I_z = sum([area * (x_stringers[_] - self.centroid[0]) ** 2
167
Added:
for _ in stringer_count])
168
Added:
169
Added:
I_xz = sum([area * (z_stringers[_] - self.centroid[1])
170
Added:
* (x_stringers[_] - self.centroid[0])
171
Added:
for _ in stringer_count])
172
Added:
173
Added:
return(I_x, I_z, I_xz)
174
Added:
156
175
def analysis(self):
157
176
'''Perform all analysis calculations and store in class instance.'''
158
177
159
178
self.drag = self.get_drag(10)
160
179
161
Removed:
self.lift_rectangular = self.get_lift_rectangular(10)
180
Added:
self.lift_rectangular = self.get_lift_rectangular(1000)
162
181
self.lift_elliptical = self.get_lift_elliptical(15)
163
Removed:
self.lift = self.get_lift_total()
182
Added:
self.lift_total = self.get_lift_total()
164
183
165
184
self.mass_dist = self.get_mass_distribution(self.mass_total)
166
185
self.centroid = self.get_centroid()
167
Removed:
self.I_x = self.get_I_x()
168
Removed:
self.I_z = self.get_I_z()
169
Removed:
self.I_xz = self.get_I_xz()
186
Added:
self.I_ = self.get_inertia_terms()
170
187
return None
171
188
172
189
173
Removed:
def plot(evaluator):
190
Added:
def plot_geom(evaluator):
174
191
'''This function plots analysis results over the airfoil's geometry.'''
175
192
176
193
# Plot chord
@@ -179,7 +196,7 @@
179
196
plt.plot(x_chord, y_chord, linewidth='1')
180
197
# Plot quarter chord
181
198
q = evaluator.chord / 4
182
Removed:
plt.plot(q, 0, '.', color='g', markersize=24, label='quarter-chord')
199
Added:
plt.plot(q, 0, '.', color='g', markersize=24, label='Quarter-chord')
183
200
# Plot upper surface
184
201
plt.plot(evaluator.x_u, evaluator.z_u,
185
202
'', color='b', linewidth='1')
@@ -217,6 +234,26 @@
217
234
plt.xlim(- 0.10 * plot_bound, 1.10 * plot_bound)
218
235
plt.ylim(- (1.10 * plot_bound / 2), (1.10 * plot_bound / 2))
219
236
plt.gca().set_aspect('equal', adjustable='box')
237
Added:
plt.gca().legend()
238
Added:
plt.grid(axis='both', linestyle=':', linewidth=1)
239
Added:
plt.show()
240
Added:
return None
241
Added:
242
Added:
243
Added:
def plot_lift(evaluator):
244
Added:
x = range(evaluator.semi_span)
245
Added:
y_1 = evaluator.lift_rectangular
246
Added:
y_2 = evaluator.lift_elliptical
247
Added:
y_3 = evaluator.lift_total
248
Added:
plt.plot(x, y_1, '.', color='b', markersize=4, label='Rectangular lift')
249
Added:
plt.plot(x, y_2, '.', color='g', markersize=4, label='Elliptical lift')
250
Added:
plt.plot(x, y_3, '.', color='r', markersize=4, label='Total lift')
251
Added:
252
Added:
# Graph formatting
253
Added:
plt.xlabel('Semi-span location')
254
Added:
plt.ylabel('Lift')
255
Added:
256
Added:
plt.gca().legend()
220
257
plt.grid(axis='both', linestyle=':', linewidth=1)
221
258
plt.show()
222
259
return None
main.py
@@ -63,7 +63,7 @@
63
63
# Define NACA airfoil coordinates and mass
64
64
af.add_naca(NACA_NUM)
65
65
af.add_mass(AIRFOIL_MASS)
66
Removed:
af.info_print(2)
66
Added:
# af.info_print(2)
67
67
af.info_save(SAVE_PATH, _)
68
68
69
69
# Create spar instance
@@ -72,7 +72,7 @@
72
72
af.spar.add_coord(af.coord, 0.15)
73
73
af.spar.add_coord(af.coord, 0.55)
74
74
af.spar.add_mass(SPAR_MASS)
75
Removed:
af.spar.info_print(2)
75
Added:
# af.spar.info_print(2)
76
76
af.spar.info_save(SAVE_PATH, _)
77
77
78
78
# Create stringer instance
@@ -85,19 +85,20 @@
85
85
BOTTOM_STRINGERS)
86
86
af.stringer.add_area(STRINGER_AREA)
87
87
af.stringer.add_mass(STRINGER_MASS)
88
Removed:
af.stringer.info_print(2)
88
Added:
# af.stringer.info_print(2)
89
89
af.stringer.info_save(SAVE_PATH, _)
90
90
91
91
# Plot components with matplotlib
92
Removed:
creator.plot(af)
92
Added:
# creator.plot_geom(af)
93
93
94
Removed:
# evaluator.Evaluator instance contains airfoil analysis results.
94
Added:
# Evaluator object contains airfoil analysis results.
95
95
eval = evaluator.Evaluator(af)
96
96
# The analysis is performed in the evaluator.py module.
97
97
eval.analysis()
98
Removed:
eval.info_print(2)
98
Added:
# eval.info_print(2)
99
99
eval.info_save(SAVE_PATH, _)
100
Removed:
evaluator.plot(eval)
100
Added:
# evaluator.plot_geom(eval)
101
Added:
# evaluator.plot_lift(eval)
101
102
102
103
# Print final execution time
103
104
print("--- %s seconds ---" % (time.time() - start_time))