*ARCHIVED* development moved to aircraft-studio.
add example
Changed files
example.py
@@ -0,0 +1,118 @@
1
Added:
# This file is part of Marius Peter's airfoil analysis package (this program).
2
Added:
#
3
Added:
# This program is free software: you can redistribute it and/or modify
4
Added:
# it under the terms of the GNU General Public License as published by
5
Added:
# the Free Software Foundation, either version 3 of the License, or
6
Added:
# (at your option) any later version.
7
Added:
#
8
Added:
# This program is distributed in the hope that it will be useful,
9
Added:
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
Added:
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
Added:
# GNU General Public License for more details.
12
Added:
#
13
Added:
# You should have received a copy of the GNU General Public License
14
Added:
# along with this program. If not, see <https://www.gnu.org/licenses/>.
15
Added:
16
Added:
17
Added:
import creator # Create geometry
18
Added:
import evaluator # Evaluate geometry
19
Added:
import generator # Iteratevely evaluate instances of geometry and optimize
20
Added:
import numpy as np
21
Added:
22
Added:
import time
23
Added:
start_time = time.time()
24
Added:
25
Added:
# Airfoil dimensions
26
Added:
NACA_NUM = 2412
27
Added:
CHORD_LENGTH = 68 # inches
28
Added:
SEMI_SPAN = 150 # inches
29
Added:
30
Added:
# Thicknesses
31
Added:
SPAR_THICKNESS = 0.4
32
Added:
SKIN_THICKNESS = 0.1
33
Added:
34
Added:
# Component masses
35
Added:
AIRFOIL_MASS = 10 # lbs
36
Added:
SPAR_MASS = 10 # lbs
37
Added:
STRINGER_MASS = 5 # lbs
38
Added:
39
Added:
# Area
40
Added:
SPAR_CAP_AREA = 0.3 # sqin
41
Added:
STRINGER_AREA = 0.1 # sqin
42
Added:
43
Added:
# Amount of stringers
44
Added:
TOP_STRINGERS = 6
45
Added:
BOTTOM_STRINGERS = 4
46
Added:
NOSE_TOP_STRINGERS = 3
47
Added:
NOSE_BOTTOM_STRINGERS = 5
48
Added:
49
Added:
# population information & save path
50
Added:
POP_SIZE = 1
51
Added:
SAVE_PATH = 'C:/Users/blend/github/UCLA_MAE_154B/save'
52
Added:
53
Added:
54
Added:
def main():
55
Added:
"""
56
Added:
Create an airfoil;
57
Added:
Evaluate an airfoil;
58
Added:
Generate a population of airfoils & optimize.
59
Added:
"""
60
Added:
61
Added:
# Create airfoil instance
62
Added:
af = creator.Airfoil.from_dimensions(CHORD_LENGTH, SEMI_SPAN)
63
Added:
# Define NACA airfoil coordinates and mass
64
Added:
af.add_naca(NACA_NUM)
65
Added:
af.add_mass(AIRFOIL_MASS)
66
Added:
# af.info_print(2)
67
Added:
af.info_save(SAVE_PATH, 'foo_name')
68
Added:
69
Added:
# Create spar instance
70
Added:
af.spar = creator.Spar()
71
Added:
# Define the spar coordinates and mass, stored in single spar object
72
Added:
af.spar.add_coord(af, 0.23)
73
Added:
af.spar.add_coord(af, 0.57)
74
Added:
# Automatically adds spar caps for each spar defined previously
75
Added:
af.spar.add_spar_caps(SPAR_CAP_AREA)
76
Added:
af.spar.add_mass(SPAR_MASS)
77
Added:
af.spar.add_webs(SPAR_THICKNESS)
78
Added:
# af.spar.info_print(2)
79
Added:
af.spar.info_save(SAVE_PATH, 'foo_name')
80
Added:
81
Added:
# Create stringer instance
82
Added:
af.stringer = creator.Stringer()
83
Added:
# Compute the stringer coordinates from their quantity in each zone
84
Added:
af.stringer.add_coord(af,
85
Added:
NOSE_TOP_STRINGERS,
86
Added:
TOP_STRINGERS,
87
Added:
NOSE_BOTTOM_STRINGERS,
88
Added:
BOTTOM_STRINGERS)
89
Added:
af.stringer.add_area(STRINGER_AREA)
90
Added:
af.stringer.add_mass(STRINGER_MASS)
91
Added:
af.stringer.add_webs(SKIN_THICKNESS)
92
Added:
# af.stringer.info_print(2)
93
Added:
af.stringer.info_save(SAVE_PATH, 'foo_name')
94
Added:
95
Added:
# Plot components with matplotlib
96
Added:
creator.plot_geom(af, True)
97
Added:
98
Added:
# Evaluator object contains airfoil analysis results.
99
Added:
eval = evaluator.Evaluator(af)
100
Added:
# The analysis is performed in the evaluator.py module.
101
Added:
eval.analysis(1, 1)
102
Added:
# eval.info_print(2)
103
Added:
eval.info_save(SAVE_PATH, 'foo_name')
104
Added:
# evaluator.plot_geom(eval)
105
Added:
# evaluator.plot_lift(eval)
106
Added:
107
Added:
pop = generator.Population(10)
108
Added:
109
Added:
# print(help(creator))
110
Added:
# print(help(evaluator))
111
Added:
# print(help(generator))
112
Added:
113
Added:
# Print final execution time
114
Added:
print("--- %s seconds ---" % (time.time() - start_time))
115
Added:
116
Added:
117
Added:
if __name__ == '__main__':
118
Added:
main()
main.py
@@ -1,121 +0,0 @@
1
Removed:
# This file is part of Marius Peter's airfoil analysis package (this program).
2
Removed:
#
3
Removed:
# This program is free software: you can redistribute it and/or modify
4
Removed:
# it under the terms of the GNU General Public License as published by
5
Removed:
# the Free Software Foundation, either version 3 of the License, or
6
Removed:
# (at your option) any later version.
7
Removed:
#
8
Removed:
# This program is distributed in the hope that it will be useful,
9
Removed:
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
Removed:
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
Removed:
# GNU General Public License for more details.
12
Removed:
#
13
Removed:
# You should have received a copy of the GNU General Public License
14
Removed:
# along with this program. If not, see <https://www.gnu.org/licenses/>.
15
Removed:
16
Removed:
17
Removed:
import creator # Create geometry
18
Removed:
import evaluator # Evaluate geometry
19
Removed:
import generator # Iteratevely evaluate instances of geometry and optimize
20
Removed:
import numpy as np
21
Removed:
22
Removed:
import time
23
Removed:
start_time = time.time()
24
Removed:
25
Removed:
# Airfoil dimensions
26
Removed:
NACA_NUM = 2412
27
Removed:
CHORD_LENGTH = 2 # inches
28
Removed:
SEMI_SPAN = 150 # inches
29
Removed:
30
Removed:
# Thicknesses
31
Removed:
SPAR_THICKNESS = 0.4
32
Removed:
SKIN_THICKNESS = 0.1
33
Removed:
34
Removed:
# Component masses
35
Removed:
AIRFOIL_MASS = 10 # lbs
36
Removed:
SPAR_MASS = 10 # lbs
37
Removed:
STRINGER_MASS = 5 # lbs
38
Removed:
39
Removed:
# Area
40
Removed:
SPAR_CAP_AREA = 0.3 # sqin
41
Removed:
STRINGER_AREA = 0.1 # sqin
42
Removed:
43
Removed:
# Amount of stringers
44
Removed:
TOP_STRINGERS = 6
45
Removed:
BOTTOM_STRINGERS = 4
46
Removed:
NOSE_TOP_STRINGERS = 3
47
Removed:
NOSE_BOTTOM_STRINGERS = 5
48
Removed:
49
Removed:
# population information & save path
50
Removed:
POP_SIZE = 1
51
Removed:
SAVE_PATH = 'C:/Users/blend/github/UCLA_MAE_154B/save'
52
Removed:
53
Removed:
54
Removed:
def main():
55
Removed:
"""
56
Removed:
Create an airfoil;
57
Removed:
Evaluate an airfoil;
58
Removed:
Generate a population of airfoils & optimize.
59
Removed:
"""
60
Removed:
61
Removed:
# Interate through all wings in population, creating and evaluating them.
62
Removed:
for _ in range(1, POP_SIZE + 1):
63
Removed:
64
Removed:
# Create airfoil instance
65
Removed:
af = creator.Airfoil.from_dimensions(CHORD_LENGTH, SEMI_SPAN)
66
Removed:
# Define NACA airfoil coordinates and mass
67
Removed:
af.add_naca(NACA_NUM)
68
Removed:
af.add_mass(AIRFOIL_MASS)
69
Removed:
# af.info_print(2)
70
Removed:
af.info_save(SAVE_PATH, _)
71
Removed:
72
Removed:
# Create spar instance
73
Removed:
af.spar = creator.Spar()
74
Removed:
# Define the spar coordinates and mass, stored in single spar object
75
Removed:
af.spar.add_coord(af, 0.23)
76
Removed:
af.spar.add_coord(af, 0.57)
77
Removed:
# Automatically adds spar caps for each spar defined previously
78
Removed:
af.spar.add_spar_caps(SPAR_CAP_AREA)
79
Removed:
af.spar.add_mass(SPAR_MASS)
80
Removed:
af.spar.add_webs(SPAR_THICKNESS)
81
Removed:
# af.spar.info_print(2)
82
Removed:
af.spar.info_save(SAVE_PATH, _)
83
Removed:
84
Removed:
# Create stringer instance
85
Removed:
af.stringer = creator.Stringer()
86
Removed:
# Compute the stringer coordinates from their quantity in each zone
87
Removed:
af.stringer.add_coord(af,
88
Removed:
NOSE_TOP_STRINGERS,
89
Removed:
TOP_STRINGERS,
90
Removed:
NOSE_BOTTOM_STRINGERS,
91
Removed:
BOTTOM_STRINGERS)
92
Removed:
af.stringer.add_area(STRINGER_AREA)
93
Removed:
af.stringer.add_mass(STRINGER_MASS)
94
Removed:
af.stringer.add_webs(SKIN_THICKNESS)
95
Removed:
# af.stringer.info_print(2)
96
Removed:
af.stringer.info_save(SAVE_PATH, _)
97
Removed:
98
Removed:
# Plot components with matplotlib
99
Removed:
# creator.plot_geom(af, True)
100
Removed:
101
Removed:
# Evaluator object contains airfoil analysis results.
102
Removed:
eval = evaluator.Evaluator(af)
103
Removed:
# The analysis is performed in the evaluator.py module.
104
Removed:
eval.analysis(1, 1)
105
Removed:
# eval.info_print(2)
106
Removed:
eval.info_save(SAVE_PATH, _)
107
Removed:
# evaluator.plot_geom(eval)
108
Removed:
# evaluator.plot_lift(eval)
109
Removed:
110
Removed:
pop = generator.Population(10)
111
Removed:
112
Removed:
# print(help(creator))
113
Removed:
# print(help(evaluator))
114
Removed:
# print(help(generator))
115
Removed:
116
Removed:
# Print final execution time
117
Removed:
print("--- %s seconds ---" % (time.time() - start_time))
118
Removed:
119
Removed:
120
Removed:
if __name__ == '__main__':
121
Removed:
main()