*ARCHIVED* development moved to aircraft-studio.
spar dP_x
Changed files
creator.py
@@ -221,8 +221,8 @@
221
221
222
222
def info_print(self, round):
223
223
super().info_print(round)
224
Removed:
print('x_c the camber x-coordinates:\n', np.around(self.x, round))
225
Removed:
print('z_c the camber z-coordinates:\n', np.around(self.x, round))
224
Added:
print('x_c the camber x-coordinates:\n', np.around(self.x_c, round))
225
Added:
print('z_c the camber z-coordinates:\n', np.around(self.z_c, round))
226
226
return None
227
227
228
228
@@ -237,6 +237,10 @@
237
237
self.thickness = float()
238
238
self.z_start = []
239
239
self.z_end = []
240
Added:
self.dx = float()
241
Added:
self.dz = float()
242
Added:
self.dP_x = float()
243
Added:
self.dP_z = float()
240
244
241
245
def add_coord(self, airfoil, x_loc_percent):
242
246
'''
@@ -274,15 +278,15 @@
274
278
self.mass = len(self.x) * mass
275
279
return None
276
280
277
Removed:
def add_webs(self, skin_thickness):
281
Added:
def add_webs(self, thickness):
278
282
'''Add webs to spars.'''
279
283
280
284
for _ in range(len(self.x)):
281
285
self.x_start.append(self.x[_][0])
282
286
self.x_end.append(self.x[_][1])
283
Removed:
self.thickness = skin_thickness
284
287
self.z_start.append(self.z[_][0])
285
288
self.z_end.append(self.z[_][1])
289
Added:
self.thickness = thickness
286
290
return None
287
291
288
292
@@ -292,7 +296,16 @@
292
296
293
297
def __init__(self):
294
298
super().__init__(parent.chord, parent.semi_span)
299
Added:
self.x_start = []
300
Added:
self.x_end = []
301
Added:
self.thickness = float()
302
Added:
self.z_start = []
303
Added:
self.z_end = []
295
304
self.area = float()
305
Added:
# self.dx = float()
306
Added:
# self.dz = float()
307
Added:
# self.dP_x = float()
308
Added:
# self.dP_z = float()
296
309
297
310
def add_coord(self, airfoil,
298
311
stringer_u_1, stringer_u_2,
@@ -364,7 +377,15 @@
364
377
return None
365
378
366
379
def add_webs(self, thickness):
367
Removed:
pass
380
Added:
'''Add webs to stringers.'''
381
Added:
382
Added:
for _ in range(len(self.x) // 2):
383
Added:
self.x_start.append(self.x[_])
384
Added:
self.x_end.append(self.x[_ + 1])
385
Added:
self.z_start.append(self.z[_])
386
Added:
self.z_end.append(self.z[_ + 1])
387
Added:
self.thickness = thickness
388
Added:
return None
368
389
369
390
def info_print(self, round):
370
391
super().info_print(round)
evaluator.py
@@ -76,6 +76,8 @@
76
76
print('I_x:\n', np.around(self.I_[0], 3))
77
77
print('I_z:\n', np.around(self.I_[1], 3))
78
78
print('I_xz:\n', np.around(self.I_[2], 3))
79
Added:
print('Spar dP_x:\n', self.spar.dP_x)
80
Added:
print('Spar dP_z:\n', self.spar.dP_z)
79
81
print(num_of_dashes * '-')
80
82
print('Rectangular lift along semi-span:\n',
81
83
np.around(self.lift_rectangular, round))
@@ -113,7 +115,8 @@
113
115
return L_prime
114
116
115
117
def get_lift_elliptical(self, L_0):
116
Removed:
L_prime = [L_0 * sqrt(1 - (y / self.semi_span) ** 2)
118
Added:
L_prime = [L_0 / (self.semi_span * 2)
119
Added:
* sqrt(1 - (y / self.semi_span) ** 2)
117
120
for y in range(self.semi_span)]
118
121
return L_prime
119
122
@@ -196,18 +199,40 @@
196
199
197
200
return(I_x, I_z, I_xz)
198
201
199
Removed:
def analysis(self):
202
Added:
def analysis(self, V_x, V_z):
200
203
'''Perform all analysis calculations and store in class instance.'''
201
204
205
Added:
def get_dp(xDist, zDist, V_x, V_z, I_x, I_z, I_xz, area):
206
Added:
denom = float(I_x * I_z - I_xz ** 2)
207
Added:
z = float()
208
Added:
for _ in range(len(xDist)):
209
Added:
z += float(- area * xDist[_] * (I_x * V_x - I_xz * V_z)
210
Added:
/ denom
211
Added:
- area * zDist[_] * (I_z * V_z - I_xz * V_x)
212
Added:
/ denom)
213
Added:
return z
214
Added:
215
Added:
def get_dx(component):
216
Added:
return [x - self.centroid[0] for x in component.x_start]
217
Added:
218
Added:
def get_dz(component):
219
Added:
return [x - self.centroid[1] for x in component.x_start]
220
Added:
202
221
self.drag = self.get_drag(10)
203
222
204
Removed:
self.lift_rectangular = self.get_lift_rectangular(1000)
223
Added:
self.lift_rectangular = self.get_lift_rectangular(13.7)
205
224
self.lift_elliptical = self.get_lift_elliptical(15)
206
225
self.lift_total = self.get_lift_total()
207
226
208
227
self.mass_dist = self.get_mass_distribution(self.mass_total)
209
228
self.centroid = self.get_centroid()
210
229
self.I_ = self.get_inertia_terms()
230
Added:
self.spar.dP_x = get_dp(get_dx(self.spar), get_dz(self.spar), V_x, 0,
231
Added:
self.I_[0], self.I_[1], self.I_[2],
232
Added:
self.spar.cap_area)
233
Added:
self.spar.dP_z = get_dp(get_dx(self.spar), get_dz(self.spar), 0, V_z,
234
Added:
self.I_[0], self.I_[1], self.I_[2],
235
Added:
self.spar.cap_area)
211
236
return None
212
237
213
238
generator.py
@@ -14,3 +14,23 @@
14
14
# along with this program. If not, see <https://www.gnu.org/licenses/>.
15
15
16
16
import creator
17
Added:
18
Added:
19
Added:
class Population:
20
Added:
'''Collection of random airfoils.'''
21
Added:
22
Added:
def __init__(self, size):
23
Added:
self.size = size
24
Added:
self.gen_number = 0 # incremented for every generation
25
Added:
26
Added:
def mutate(self, prob_mt):
27
Added:
'''Randomly mutate the genes of prob_mt % of the population.'''
28
Added:
29
Added:
def crossover(self, prob_cx):
30
Added:
'''Combine the genes of prob_cx % of the population.'''
31
Added:
32
Added:
def reproduce(self, prob_rp):
33
Added:
'''Pass on the genes of the fittest prob_rp % of the population.'''
34
Added:
35
Added:
def fitness():
36
Added:
'''Rate the fitness of an individual on a relative scale (0-100)'''
main.py
@@ -70,7 +70,7 @@
70
70
# Define NACA airfoil coordinates and mass
71
71
af.add_naca(NACA_NUM)
72
72
af.add_mass(AIRFOIL_MASS)
73
Removed:
# af.info_print(2)
73
Added:
af.info_print(2)
74
74
af.info_save(SAVE_PATH, _)
75
75
76
76
# Create spar instance
@@ -82,7 +82,7 @@
82
82
af.spar.add_spar_caps(SPAR_CAP_AREA)
83
83
af.spar.add_mass(SPAR_MASS)
84
84
af.spar.add_webs(SPAR_THICKNESS)
85
Removed:
# af.spar.info_print(2)
85
Added:
af.spar.info_print(2)
86
86
af.spar.info_save(SAVE_PATH, _)
87
87
88
88
# Create stringer instance
@@ -96,20 +96,20 @@
96
96
af.stringer.add_area(STRINGER_AREA)
97
97
af.stringer.add_mass(STRINGER_MASS)
98
98
af.stringer.add_webs(SKIN_THICKNESS)
99
Removed:
# af.stringer.info_print(2)
99
Added:
af.stringer.info_print(2)
100
100
af.stringer.info_save(SAVE_PATH, _)
101
101
102
102
# Plot components with matplotlib
103
Removed:
# creator.plot_geom(af)
103
Added:
creator.plot_geom(af)
104
104
105
105
# Evaluator object contains airfoil analysis results.
106
106
eval = evaluator.Evaluator(af)
107
107
# The analysis is performed in the evaluator.py module.
108
Removed:
eval.analysis()
109
Removed:
# eval.info_print(2)
108
Added:
eval.analysis(1, 1)
109
Added:
eval.info_print(2)
110
110
eval.info_save(SAVE_PATH, _)
111
111
evaluator.plot_geom(eval)
112
Removed:
# evaluator.plot_lift(eval)
112
Added:
evaluator.plot_lift(eval)
113
113
114
114
# Print final execution time
115
115
print("--- %s seconds ---" % (time.time() - start_time))