summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--__init__.py4
-rw-r--r--creator.py32
-rw-r--r--main.py16
3 files changed, 29 insertions, 23 deletions
diff --git a/__init__.py b/__init__.py
index 5e916af..dc031d0 100644
--- a/__init__.py
+++ b/__init__.py
@@ -13,5 +13,5 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
__author__ = "Marius Peter"
-__version__ = "2.3"
-__revision__ = "2.3.1"
+# __version__ = "2.3"
+# __revision__ = "2.3.1"
diff --git a/creator.py b/creator.py
index 8b6b8ae..3cc10d1 100644
--- a/creator.py
+++ b/creator.py
@@ -70,10 +70,7 @@ class Coordinates:
def __str__(self):
return type(self).__name__
- def add_mass(self, mass):
- self.mass = len(self.x_u) * mass
-
- def print_coord(self, round):
+ def print_info(self, round):
"""
Print all the component's coordinates to the terminal.
@@ -83,15 +80,15 @@ class Coordinates:
print('Component:', str(self))
print('Chord length:', self.chord)
print('Semi-span:', self.semi_span)
+ print('Mass:', self.mass)
print('============================')
print('x_u the upper x-coordinates:\n', np.around(self.x_u, round))
print('y_u the upper y-coordinates:\n', np.around(self.y_u, round))
print('x_l the lower x-coordinates:\n', np.around(self.x_l, round))
print('y_l the lower y-coordinates:\n', np.around(self.y_l, round))
- # print('\n')
return None
- def save_coord(self, save_dir_path, number):
+ def save_info(self, save_dir_path, number):
"""
Save all the object's coordinates (must be full path).
"""
@@ -100,7 +97,7 @@ class Coordinates:
full_path = os.path.join(save_dir_path, file_name)
try:
with open(full_path, 'w') as sys.stdout:
- self.print_coord(2)
+ self.print_info(2)
# This line required to reset behavior of sys.stdout
sys.stdout = sys.__stdout__
print('Successfully wrote to file {}'.format(full_path))
@@ -112,7 +109,7 @@ class Coordinates:
return None
- def pack_coord(self):
+ def pack_info(self):
self.coord.append(self.x_u)
self.coord.append(self.y_u)
self.coord.append(self.x_l)
@@ -244,9 +241,12 @@ class Airfoil(Coordinates):
self.x_l.append(get_lower_coordinates(x)[0])
self.y_l.append(get_lower_coordinates(x)[1])
- super().pack_coord()
+ super().pack_info()
return None
+ def add_mass(self, mass):
+ self.mass = mass
+
class Spar(Coordinates):
"""Contains a single spar's location."""
@@ -285,9 +285,12 @@ class Spar(Coordinates):
self.x_l.append(x_l[spar_x_l])
self.y_l.append(y_l[spar_x_l])
- super().pack_coord()
+ super().pack_info()
return None
+ def add_mass(self, mass):
+ self.mass = len(self.x_u) * mass
+
class Stringer(Coordinates):
"""Contains the coordinates of all stringers."""
@@ -296,8 +299,8 @@ class Stringer(Coordinates):
def __init__(self):
super().__init__(parent.chord, parent.semi_span)
- def add_coord(self, airfoil_coord, spar_coord, stringer_u_1, stringer_u_2,
- stringer_l_1, stringer_l_2):
+ def add_coord(self, airfoil_coord, spar_coord,
+ stringer_u_1, stringer_u_2, stringer_l_1, stringer_l_2):
"""
Add equally distributed stringers to four airfoil locations
(upper nose, lower nose, upper surface, lower surface).
@@ -365,9 +368,12 @@ class Stringer(Coordinates):
self.y_l.append(airfoil_y_l[index])
x += interval
- super().pack_coord()
+ super().pack_info()
return None
+ def add_mass(self, mass):
+ self.mass = len(self.x_u) * mass + len(self.x_l) * mass
+
def plot(airfoil, spar, stringer):
"""This function plots the elements passed as arguments."""
diff --git a/main.py b/main.py
index 06dd233..a530730 100644
--- a/main.py
+++ b/main.py
@@ -21,7 +21,7 @@ import random
import time
start_time = time.time()
-CHORD_LENGTH = 10
+CHORD_LENGTH = 100
SEMI_SPAN = 200
# masss
@@ -45,7 +45,7 @@ def main():
# Define NACA airfoil coordinates and mass
af.add_naca(2412)
af.add_mass(AIRFOIL_MASS)
- af.print_coord(2)
+ af.print_info(2)
# Create spar instance
af.spar = creator.Spar()
@@ -53,22 +53,22 @@ def main():
af.spar.add_coord(af.coord, 0.15)
af.spar.add_coord(af.coord, 0.55)
af.spar.add_mass(SPAR_MASS)
- af.spar.print_coord(2)
+ af.spar.print_info(2)
# Create stringer instance
af.stringer = creator.Stringer()
# Compute the stringer coordinates from their quantity in each zone
af.stringer.add_coord(af.coord, af.spar.coord, 4, 7, 5, 6)
af.stringer.add_mass(STRINGER_MASS)
- af.stringer.print_coord(2)
+ af.stringer.print_info(2)
# Plot components with matplotlib
# creator.plot(af, af.spar, af.stringer)
- # Save component coordinates
- af.save_coord(SAVE_PATH, _)
- af.spar.save_coord(SAVE_PATH, _)
- af.stringer.save_coord(SAVE_PATH, _)
+ # Save component info
+ af.save_info(SAVE_PATH, _)
+ af.spar.save_info(SAVE_PATH, _)
+ af.stringer.save_info(SAVE_PATH, _)
# Print final execution time
print("--- %s seconds ---" % (time.time() - start_time))
Copyright 2019--2024 Marius PETER