1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
"""
This example illustrates the usage of creator, evaluator and generator.
All the steps of airfoil creation & evaluation are detailed here;
furthermore, the generator.py module contains certain presets
(default airfoils).
Create an airfoil;
Evaluate an airfoil;
Generate a population of airfoils & optimize.
"""
import aircraftstudio as acs
import resources.materials as mt
import time
start_time = time.time()
# Thicknesses
SPAR_THICKNESS = 0.4
SKIN_THICKNESS = 0.1
# Component masses (lbs)
AIRFOIL_MASS = 10
SPAR_MASS = 10
STRINGER_MASS = 5
# Area (sqin)
SPAR_CAP_AREA = 0.3
STRINGER_AREA = 0.1
SAVE_PATH = '/home/blendux/Projects/Aircraft_Studio/save'
# eval = evaluator.Evaluator("eval")
# ac = creator.base.Aircraft(eval, "ac")
# af = creator.wing.Airfoil(ac, 'af')
# af.add_naca(2412)
# spar1 = creator.wing.Spar(af, 'spar1')
# spar2 = creator.wing.Spar(af, 'spar2', 0.57)
# # spar2 = creator.wing.Spar(af, 'spar2', 0.7)
# stringer = creator.wing.Stringer(af, 'stringer', 5, 6, 5, 4)
# stringer.info_save(SAVE_PATH)
# ac2 = creator.base.Aircraft(eval, "ac2")
# af2 = creator.wing.Airfoil(ac2, 'af2')
# af2.add_naca(3412)
# af2.info_save()
# spar3 = creator.wing.Spar(af2, 'spar3', 0.23)
# spar4 = creator.wing.Spar(af2, 'spar4', 0.67)
# stringer2 = creator.wing.Stringer(af2, 'stringer2')
# stringer2.info_save(SAVE_PATH)
population = acs.generator.Population(10000)
acs.evaluator.analyze_all(population) # 123s with multiprocessing :-(
def foo(size):
for _ in range(size):
print(acs.evaluator.analyze(acs.creator.base.Aircraft.from_random()))
return None
foo(10000) # 106s
# Final execution time
final_time = time.time() - start_time
print(f"--- {round(final_time, 4)}s seconds ---")
|