*ARCHIVED* development moved to aircraft-studio.
add_mass for each component class
Changed files
__init__.py
@@ -13,5 +13,5 @@
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program. If not, see <https://www.gnu.org/licenses/>.
15
15
__author__ = "Marius Peter"
16
Removed:
__version__ = "2.3"
17
Removed:
__revision__ = "2.3.1"
16
Added:
# __version__ = "2.3"
17
Added:
# __revision__ = "2.3.1"
creator.py
@@ -70,10 +70,7 @@
70
70
def __str__(self):
71
71
return type(self).__name__
72
72
73
Removed:
def add_mass(self, mass):
74
Removed:
self.mass = len(self.x_u) * mass
75
Removed:
76
Removed:
def print_coord(self, round):
73
Added:
def print_info(self, round):
77
74
"""
78
75
Print all the component's coordinates to the terminal.
79
76
@@ -83,15 +80,15 @@
83
80
print('Component:', str(self))
84
81
print('Chord length:', self.chord)
85
82
print('Semi-span:', self.semi_span)
83
Added:
print('Mass:', self.mass)
86
84
print('============================')
87
85
print('x_u the upper x-coordinates:\n', np.around(self.x_u, round))
88
86
print('y_u the upper y-coordinates:\n', np.around(self.y_u, round))
89
87
print('x_l the lower x-coordinates:\n', np.around(self.x_l, round))
90
88
print('y_l the lower y-coordinates:\n', np.around(self.y_l, round))
91
Removed:
# print('\n')
92
89
return None
93
90
94
Removed:
def save_coord(self, save_dir_path, number):
91
Added:
def save_info(self, save_dir_path, number):
95
92
"""
96
93
Save all the object's coordinates (must be full path).
97
94
"""
@@ -100,7 +97,7 @@
100
97
full_path = os.path.join(save_dir_path, file_name)
101
98
try:
102
99
with open(full_path, 'w') as sys.stdout:
103
Removed:
self.print_coord(2)
100
Added:
self.print_info(2)
104
101
# This line required to reset behavior of sys.stdout
105
102
sys.stdout = sys.__stdout__
106
103
print('Successfully wrote to file {}'.format(full_path))
@@ -112,7 +109,7 @@
112
109
113
110
return None
114
111
115
Removed:
def pack_coord(self):
112
Added:
def pack_info(self):
116
113
self.coord.append(self.x_u)
117
114
self.coord.append(self.y_u)
118
115
self.coord.append(self.x_l)
@@ -244,10 +241,13 @@
244
241
self.x_l.append(get_lower_coordinates(x)[0])
245
242
self.y_l.append(get_lower_coordinates(x)[1])
246
243
247
Removed:
super().pack_coord()
244
Added:
super().pack_info()
248
245
return None
249
246
247
Added:
def add_mass(self, mass):
248
Added:
self.mass = mass
250
249
250
Added:
251
251
class Spar(Coordinates):
252
252
"""Contains a single spar's location."""
253
253
global parent
@@ -285,10 +285,13 @@
285
285
self.x_l.append(x_l[spar_x_l])
286
286
self.y_l.append(y_l[spar_x_l])
287
287
288
Removed:
super().pack_coord()
288
Added:
super().pack_info()
289
289
return None
290
290
291
Added:
def add_mass(self, mass):
292
Added:
self.mass = len(self.x_u) * mass
291
293
294
Added:
292
295
class Stringer(Coordinates):
293
296
"""Contains the coordinates of all stringers."""
294
297
global parent
@@ -296,8 +299,8 @@
296
299
def __init__(self):
297
300
super().__init__(parent.chord, parent.semi_span)
298
301
299
Removed:
def add_coord(self, airfoil_coord, spar_coord, stringer_u_1, stringer_u_2,
300
Removed:
stringer_l_1, stringer_l_2):
302
Added:
def add_coord(self, airfoil_coord, spar_coord,
303
Added:
stringer_u_1, stringer_u_2, stringer_l_1, stringer_l_2):
301
304
"""
302
305
Add equally distributed stringers to four airfoil locations
303
306
(upper nose, lower nose, upper surface, lower surface).
@@ -365,8 +368,11 @@
365
368
self.y_l.append(airfoil_y_l[index])
366
369
x += interval
367
370
368
Removed:
super().pack_coord()
371
Added:
super().pack_info()
369
372
return None
373
Added:
374
Added:
def add_mass(self, mass):
375
Added:
self.mass = len(self.x_u) * mass + len(self.x_l) * mass
370
376
371
377
372
378
def plot(airfoil, spar, stringer):
main.py
@@ -21,7 +21,7 @@
21
21
import time
22
22
start_time = time.time()
23
23
24
Removed:
CHORD_LENGTH = 10
24
Added:
CHORD_LENGTH = 100
25
25
SEMI_SPAN = 200
26
26
27
27
# masss
@@ -45,7 +45,7 @@
45
45
# Define NACA airfoil coordinates and mass
46
46
af.add_naca(2412)
47
47
af.add_mass(AIRFOIL_MASS)
48
Removed:
af.print_coord(2)
48
Added:
af.print_info(2)
49
49
50
50
# Create spar instance
51
51
af.spar = creator.Spar()
@@ -53,22 +53,22 @@
53
53
af.spar.add_coord(af.coord, 0.15)
54
54
af.spar.add_coord(af.coord, 0.55)
55
55
af.spar.add_mass(SPAR_MASS)
56
Removed:
af.spar.print_coord(2)
56
Added:
af.spar.print_info(2)
57
57
58
58
# Create stringer instance
59
59
af.stringer = creator.Stringer()
60
60
# Compute the stringer coordinates from their quantity in each zone
61
61
af.stringer.add_coord(af.coord, af.spar.coord, 4, 7, 5, 6)
62
62
af.stringer.add_mass(STRINGER_MASS)
63
Removed:
af.stringer.print_coord(2)
63
Added:
af.stringer.print_info(2)
64
64
65
65
# Plot components with matplotlib
66
66
# creator.plot(af, af.spar, af.stringer)
67
67
68
Removed:
# Save component coordinates
69
Removed:
af.save_coord(SAVE_PATH, _)
70
Removed:
af.spar.save_coord(SAVE_PATH, _)
71
Removed:
af.stringer.save_coord(SAVE_PATH, _)
68
Added:
# Save component info
69
Added:
af.save_info(SAVE_PATH, _)
70
Added:
af.spar.save_info(SAVE_PATH, _)
71
Added:
af.stringer.save_info(SAVE_PATH, _)
72
72
73
73
# Print final execution time
74
74
print("--- %s seconds ---" % (time.time() - start_time))