summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Peter <blendoit@gmail.com>2019-06-13 13:14:04 -0700
committerMarius Peter <blendoit@gmail.com>2019-06-13 13:14:04 -0700
commitb7a4c9728438b075e741f856fe3285bada26bb44 (patch)
tree6b90dfbafc0d085408134d47332fb11470b03b0b
parent09fd81eac3f5861b043e00d4865fa205deba5319 (diff)
add_mass method in class Coordinates
-rw-r--r--creator.py12
-rw-r--r--main.py29
2 files changed, 27 insertions, 14 deletions
diff --git a/creator.py b/creator.py
index a2626d0..8b6b8ae 100644
--- a/creator.py
+++ b/creator.py
@@ -50,6 +50,8 @@ class Coordinates:
if chord < 10:
self.chord = 10
self.semi_span = semi_span
+ # mass
+ self.mass = float()
# Component material
self.material = str()
# Upper coordinates
@@ -60,6 +62,7 @@ class Coordinates:
self.y_l = []
# Coordinates x_u, y_u, x_l, y_l packed in single list
self.coord = []
+
# The airfoil components know the Coordinates instance's coords
global parent
parent = self
@@ -67,6 +70,9 @@ 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):
"""
Print all the component's coordinates to the terminal.
@@ -249,7 +255,7 @@ class Spar(Coordinates):
def __init__(self):
super().__init__(parent.chord, parent.semi_span)
- def add(self, airfoil_coord, spar_x):
+ def add_coord(self, airfoil_coord, spar_x):
"""
Add a single spar at the % chord location given to function.
@@ -290,8 +296,8 @@ class Stringer(Coordinates):
def __init__(self):
super().__init__(parent.chord, parent.semi_span)
- def add(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).
diff --git a/main.py b/main.py
index b842e9e..06dd233 100644
--- a/main.py
+++ b/main.py
@@ -21,9 +21,14 @@ import random
import time
start_time = time.time()
-CHORD_LENGTH = 1000
+CHORD_LENGTH = 10
SEMI_SPAN = 200
+# masss
+AIRFOIL_MASS = 100 # lbs
+SPAR_MASS = 10 # lbs
+STRINGER_MASS = 5 # lbs
+
POP_SIZE = 1
SAVE_PATH = 'C:/Users/blend/github/UCLA_MAE_154B/save'
@@ -37,23 +42,25 @@ def main():
# Create airfoil instance
af = creator.Airfoil()
- # Define NACA airfoil coordinates
+ # Define NACA airfoil coordinates and mass
af.add_naca(2412)
- # af.print_coord(2)
+ af.add_mass(AIRFOIL_MASS)
+ af.print_coord(2)
# Create spar instance
af.spar = creator.Spar()
- # Define the spar coordinates, stored in single spar object
- af.spar.add(af.coord, 0.15)
- af.spar.add(af.coord, 0.55)
- # af.spar.print_coord(2)
+ # Define the spar coordinates and mass, stored in single spar object
+ 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)
# Create stringer instance
af.stringer = creator.Stringer()
- # Define the stringer coordinates from their amount
- af.stringer.add(af.coord, af.spar.coord, 4, 7, 5, 6)
- # Print coordinates of af.stringer to terminal
- # af.stringer.print_coord(2)
+ # 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)
# Plot components with matplotlib
# creator.plot(af, af.spar, af.stringer)
Copyright 2019--2024 Marius PETER