*ARCHIVED* development moved to aircraft-studio.
start
Changed files
creator.py
@@ -12,8 +12,9 @@
12
12
#
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
Added:
15
16
"""
16
Removed:
The 'creator' module contains class definitions for coordinates
17
Added:
The creator.py module contains class definitions for coordinates
17
18
and various components we add to an airfoil (spars, stringers, and ribs.)
18
19
19
20
Classes:
@@ -25,6 +26,7 @@
25
26
Functions:
26
27
plot_geom(airfoil): generates a 2D plot of the airfoil & any components.
27
28
"""
29
Added:
28
30
import sys
29
31
import os.path
30
32
import numpy as np
@@ -33,13 +35,6 @@
33
35
import matplotlib.pyplot as plt
34
36
35
37
36
Removed:
# This variable is required for main.py constant wing dimensions
37
Removed:
# to be passed to inheriting classes (Airfoil, Spar, Stringer, Rib).
38
Removed:
# This way, we don't have to redeclare our coordinates as parameters for
39
Removed:
# our spars, stringers and ribs. This makes for more elegant code.
40
Removed:
global parent
41
Removed:
42
Removed:
43
38
class Coordinates:
44
39
"""
45
40
All airfoil components need the following:
@@ -55,10 +50,10 @@
55
50
So, all component classes inherit from class Coordinates.
56
51
"""
57
52
58
Removed:
def __init__(self, chord, semi_span):
59
Removed:
# Global dimensions
60
Removed:
self.chord = chord if chord > 40 else 40
61
Removed:
self.semi_span = semi_span
53
Added:
chord = 100
54
Added:
semi_span = 200
55
Added:
56
Added:
def __init__(self):
62
57
# mass and area
63
58
self.mass = float()
64
59
self.area = float()
@@ -68,9 +63,11 @@
68
63
self.x = []
69
64
self.z = []
70
65
71
Removed:
# The airfoil components know the Coordinates instance's coords
72
Removed:
global parent
73
Removed:
parent = self
66
Added:
@classmethod
67
Added:
def from_chord(cls, chord, semi_span):
68
Added:
cls.chord = chord
69
Added:
cls.semi_span = semi_span
70
Added:
return None
74
71
75
72
def __str__(self):
76
73
return type(self).__name__
@@ -131,7 +128,9 @@
131
128
def __init__(self):
132
129
global parent
133
130
# Run 'Coordinates' super class init method with same chord & 1/2 span.
134
Removed:
super().__init__(parent.chord, parent.semi_span)
131
Added:
super().__init__()
132
Added:
self.chord = Coordinates.chord
133
Added:
self.semi_span = Coordinates.semi_span
135
134
# NACA number
136
135
self.naca_num = int()
137
136
# Mean camber line
@@ -236,10 +235,9 @@
236
235
237
236
class Spar(Coordinates):
238
237
"""Contains a single spar's location."""
239
Removed:
global parent
240
238
241
239
def __init__(self):
242
Removed:
super().__init__(parent.chord, parent.semi_span)
240
Added:
super().__init__()
243
241
self.x_start = []
244
242
self.x_end = []
245
243
self.thickness = float()
@@ -298,10 +296,9 @@
298
296
299
297
class Stringer(Coordinates):
300
298
"""Contains the coordinates of all stringers."""
301
Removed:
global parent
302
299
303
300
def __init__(self):
304
Removed:
super().__init__(parent.chord, parent.semi_span)
301
Added:
super().__init__()
305
302
self.x_start = []
306
303
self.x_end = []
307
304
self.thickness = float()
@@ -432,7 +429,6 @@
432
429
# Graph formatting
433
430
plt.xlabel('X axis')
434
431
plt.ylabel('Z axis')
435
Removed:
436
432
plot_bound = max(airfoil.x)
437
433
plt.xlim(- 0.10 * plot_bound, 1.10 * plot_bound)
438
434
plt.ylim(- (1.10 * plot_bound / 2), (1.10 * plot_bound / 2))
main.py
@@ -59,7 +59,7 @@
59
59
"""
60
60
# Create coordinate system specific to our airfoil dimensions.
61
61
# TODO: imperial + metric unit setting
62
Removed:
creator.Coordinates(CHORD_LENGTH, SEMI_SPAN)
62
Added:
creator.Coordinates.from_chord(CHORD_LENGTH, SEMI_SPAN)
63
63
64
64
# Interate through all wings in population, creating and evaluating them.
65
65
for _ in range(1, POP_SIZE + 1):