summaryrefslogtreecommitdiff
path: root/example_airfoil.py
blob: 3dc319cf961b58b6094507be540770f578b2f3b3 (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
"""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 resources.materials as mt
import creator
import evaluator.evaluator as evaluator
import generator
import matplotlib.pyplot as plt

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

# Amount of stringers
TOP_STRINGERS = 6
BOTTOM_STRINGERS = 4
NOSE_TOP_STRINGERS = 3
NOSE_BOTTOM_STRINGERS = 5

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)
# stringer = creator.wing.Stringer(af, 'stringer')
# af.stringer.add_coord(af, [af.spar1, af.spar2], NOSE_TOP_STRINGERS,
#                       TOP_STRINGERS, NOSE_BOTTOM_STRINGERS, BOTTOM_STRINGERS)
# af.stringer.info_print(2)
# af.stringer.info_save(SAVE_PATH, 'foo_name')

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)
spar3.info_save()
spar4.info_save()


eval.tree_print()
eval.tree_save()

print(eval.analysis())

# for aircraft in eval.aircrafts:
#     print(aircraft)
#     print(aircraft.wing.material)
#     for spar in aircraft.wing.spars:
#         print(spar, f"is made out of: {spar.material['name']}")

# Plot components with matplotlib
# creator.wing.plot_geom(af, [af.spar1, af.spar2], None)

# Evaluator object contains airfoil analysis results.
# The analysis is performed in the evaluator.py module.
# eval.analysis(1, 1)
# eval.info_print(2)
# eval.info_save(SAVE_PATH, 'foo_name')
# evaluator.plot_geom(eval)
# evaluator.plot_lift(eval)

# import resources.NACA_2412
# cl = resources.NACA_2412.cl
# alpha = resources.NACA_2412.alpha
# plt.plot(alpha, cl)
# plt.show()


# Final execution time
final_time = time.time() - start_time
print(f"--- {round(final_time, 4)}s seconds ---")
Copyright 2019--2024 Marius PETER