summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Peter <blendoit@gmail.com>2019-06-09 12:15:41 -0700
committerMarius Peter <blendoit@gmail.com>2019-06-09 12:15:41 -0700
commite5610a86d65615a91a89205b3ae4ee559a37d751 (patch)
tree7735e990bc1f850246fea3a4c4aa529ad21a7312
parent4baa99bcf568f91ffe9ce961e86185cf42a75a4b (diff)
pack_coord method in Coordinates
-rw-r--r--creator.py39
-rw-r--r--main.py33
2 files changed, 42 insertions, 30 deletions
diff --git a/creator.py b/creator.py
index 953f088..673cfe9 100644
--- a/creator.py
+++ b/creator.py
@@ -59,11 +59,12 @@ class Coordinates:
self.x_l = []
self.y_l = []
# Coordinates x_u, y_u, x_l, y_l packed in single list
- self.coordinates = []
+ self.coord = []
+ # The airfoil components know the Coordinates instance's coords
global parent
parent = self
- def print_coord(self, round):
+ def print_component(self, round):
"""
Print all the component's coordinates to the terminal.
@@ -100,6 +101,12 @@ class Coordinates:
self.print_coord(4)
return None
+ def pack_coord(self):
+ self.coord.append(self.x_u)
+ self.coord.append(self.y_u)
+ self.coord.append(self.x_l)
+ self.coord.append(self.y_l)
+
class Airfoil(Coordinates):
"""This class enables the creation of a single NACA airfoil."""
@@ -227,11 +234,7 @@ class Airfoil(Coordinates):
self.x_l.append(get_lower_coordinates(x)[0])
self.y_l.append(get_lower_coordinates(x)[1])
- self.coordinates.append(self.x_u)
- self.coordinates.append(self.y_u)
- self.coordinates.append(self.x_l)
- self.coordinates.append(self.y_l)
-
+ super().pack_coord()
return None
@@ -271,6 +274,8 @@ class Spar(Coordinates):
self.y_u.append(y_u[spar_x_u])
self.x_l.append(x_l[spar_x_l])
self.y_l.append(y_l[spar_x_l])
+
+ super().pack_coord()
return None
@@ -281,17 +286,25 @@ class Stringer():
def __init__(self):
super().__init__(parent.chord, parent.semi_span)
- def add_stringer(self, *density):
+ def add_stringer(self, coordinates, den_u_1, den_u_2, den_l_1, den_l_2):
"""
- Add stringers to the wing from their distribution density between spars.
- First half of density[] concerns stringer distribution on
+ Add stringers to the wing from their density distribution.
Parameters:
- material: stringer material
- *density:
+ den_u_1: upper nose stringer density (until first spar)
+ den_u_2: upper surface stringer density
+ den_l_1: lower nose stringer density (until first spar)
+ den_l_2: lower surface stringer density
+ Returns:
+ None
"""
-
+ # Airfoil surface coordinates
+ # unpacked from 'coordinates' (list of lists in 'Airfoil').
+ x_u = coordinates[0]
+ y_u = coordinates[1]
+ x_l = coordinates[2]
+ y_l = coordinates[3]
# Find interval between leading edge and first upper stringer,
# from density parameter den_u_1.
interval = self.spar_x_u[0] / (den_u_1 * self.spar_x_u[0])
diff --git a/main.py b/main.py
index 4bbd7a9..bba67ce 100644
--- a/main.py
+++ b/main.py
@@ -19,7 +19,7 @@ import random
import time
start_time = time.time()
-CHORD_LENGTH = 100
+CHORD_LENGTH = 10
SEMI_SPAN = 200
POP_SIZE = 1
@@ -36,31 +36,30 @@ def main():
af = creator.Airfoil()
# Define NACA airfoil coordinates
af.naca(2412)
- # Print coordinates of af to terminal
- af.print_coord(4)
+
+ print(af.coord)
# Create spar instance
af.spar = creator.Spar()
# Define the spar coordinates
- af.spar.add_spar(af.coordinates, 0.15)
- af.spar.add_spar(af.coordinates, 0.55)
+ af.spar.add_spar(af.coord, 0.15)
+ af.spar.add_spar(af.coord, 0.55)
# Print coordinates of af.spar to terminal
- af.spar.print_coord(4)
- # Create stringer instance
- af.stringer = creator.Stringer()
- # Define the stringer coordinates
- af.stringer.add_stringer(af.coordinates, 0.15)
- af.stringer.add_stringer(af.coordinates, 0.55)
- # Print coordinates of af.stringer to terminal
- af.stringer.print_coord(4)
+ # # Create stringer instance
+ # af.stringer = creator.Stringer()
+ # # Define the stringer coordinates
+ # af.stringer.add_stringer(af.coordinates, 0.15)
+ # af.stringer.add_stringer(af.coordinates, 0.55)
+ # # Print coordinates of af.stringer to terminal
+ # af.stringer.print_coord(4)
# Plot components with matplotlib
- creator.plot(af, af.spar, af.stringer)
+ creator.plot(af, af.spar)
- # Save component coordinates
- af.save_coord(SAVE_PATH)
- af.spar.save_coord(SAVE_PATH)
+ # # Save component coordinates
+ # af.save_coord(SAVE_PATH)
+ # af.spar.save_coord(SAVE_PATH)
# Print final execution time
print("--- %s seconds ---" % (time.time() - start_time))
Copyright 2019--2024 Marius PETER