summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--creator.py4
-rw-r--r--evaluator.py72
-rw-r--r--main.py20
3 files changed, 62 insertions, 34 deletions
diff --git a/creator.py b/creator.py
index 97d28f5..e8bba68 100644
--- a/creator.py
+++ b/creator.py
@@ -254,6 +254,10 @@ class Spar(Coordinates):
self.z_l.append(z_l[spar_x_l])
return None
+ def add_spar_caps(self, spar_cap_area):
+ self.cap_area = spar_cap_area
+ return None
+
def add_mass(self, mass):
self.mass = len(self.x_u) * mass
return None
diff --git a/evaluator.py b/evaluator.py
index 4ab9477..5710522 100644
--- a/evaluator.py
+++ b/evaluator.py
@@ -27,9 +27,12 @@ class Evaluator:
def __init__(self, airfoil):
# Evaluator knows all geometrical info from evaluated airfoil
self.airfoil = airfoil
+ self.spar = airfoil.spar
+ self.stringer = airfoil.stringer
# Global dimensions
self.chord = airfoil.chord
self.semi_span = airfoil.semi_span
+
# mass and area
self.mass_total = float(airfoil.mass
+ airfoil.spar.mass
@@ -41,11 +44,6 @@ class Evaluator:
# Lower coordinates
self.x_l = airfoil.x_l
self.z_l = airfoil.z_l
- # Spars
- self.spar = airfoil.spar
- # Stringers
- self.stringer = airfoil.stringer
- # Lifts
self.lift_rectangular = []
self.lift_elliptical = []
self.lift_total = []
@@ -139,36 +137,52 @@ class Evaluator:
def get_centroid(self):
'''Return the coordinates of the centroid.'''
- area = self.airfoil.stringer.area
+ stringer_area = self.stringer.area
+ caps_area = self.spar.cap_area
- x_stringers = self.airfoil.stringer.x_u + self.airfoil.stringer.x_l
- x_centroid = sum([x * area for x in x_stringers]) / \
- (len(x_stringers) * area)
+ x_spars = self.spar.x_u + self.spar.x_l
+ x_stringers = self.stringer.x_u + self.stringer.x_l
+ z_stringers = self.stringer.z_u + self.stringer.z_l
+ denom = float(len(x_spars) * caps_area
+ + len(x_stringers) * stringer_area)
- z_stringers = self.airfoil.stringer.z_u + self.airfoil.stringer.z_l
- z_centroid = sum([x * area for x in z_stringers]) / \
- (len(x_stringers) * area)
- return(x_centroid, z_centroid)
+ x_ctr = (sum([i * caps_area for i in self.spar.x_u])
+ + sum([i * stringer_area for i in x_stringers])) / denom
+ z_ctr = (sum([i * caps_area for i in self.spar.z_u])
+ + sum([i * stringer_area for i in z_stringers])) / denom
+ return(x_ctr, z_ctr)
def get_inertia_terms(self):
'''Obtain all inertia terms.'''
- area = self.stringer.area
+ stringer_area = self.stringer.area
+ caps_area = self.spar.cap_area
+
+ # Adds upper and lower components' coordinates to list
x_stringers = self.stringer.x_u + self.stringer.x_l
z_stringers = self.stringer.z_u + self.stringer.z_l
+ x_spars = self.spar.x_u + self.spar.x_l
+ z_spars = self.spar.z_u + self.spar.z_l
stringer_count = range(len(x_stringers))
-
- # I_x is the sum of (stringer area * z-distance to the centroid) ** 2,
- # for all stringers.
- I_x = sum([area * (z_stringers[_] - self.centroid[1]) ** 2
- for _ in stringer_count])
-
- I_z = sum([area * (x_stringers[_] - self.centroid[0]) ** 2
- for _ in stringer_count])
-
- I_xz = sum([area * (z_stringers[_] - self.centroid[1])
- * (x_stringers[_] - self.centroid[0])
- for _ in stringer_count])
+ spar_count = range(len(self.spar.x_u))
+
+ # I_x is the sum of the contributions of the spar caps and stringers
+ I_x = (sum([caps_area * (z_spars[i] - self.centroid[1]) ** 2
+ for i in spar_count])
+ + sum([stringer_area * (z_stringers[i] - self.centroid[1]) ** 2
+ for i in stringer_count]))
+
+ I_z = (sum([caps_area * (x_spars[i] - self.centroid[0]) ** 2
+ for i in spar_count])
+ + sum([stringer_area * (x_stringers[i] - self.centroid[0]) ** 2
+ for i in stringer_count]))
+
+ I_xz = (sum([caps_area * (x_spars[i] - self.centroid[0])
+ * (z_spars[i] - self.centroid[1])
+ for i in spar_count])
+ + sum([stringer_area * (x_stringers[i] - self.centroid[0])
+ * (z_stringers[i] - self.centroid[1])
+ for i in stringer_count]))
return(I_x, I_z, I_xz)
@@ -245,8 +259,10 @@ def plot_lift(evaluator):
y_1 = evaluator.lift_rectangular
y_2 = evaluator.lift_elliptical
y_3 = evaluator.lift_total
- plt.plot(x, y_1, '.', color='b', markersize=4, label='Rectangular lift')
- plt.plot(x, y_2, '.', color='g', markersize=4, label='Elliptical lift')
+ plt.plot(x, y_1, '.', color='b', markersize=4,
+ label='Rectangular lift')
+ plt.plot(x, y_2, '.', color='g', markersize=4,
+ label='Elliptical lift')
plt.plot(x, y_3, '.', color='r', markersize=4, label='Total lift')
# Graph formatting
diff --git a/main.py b/main.py
index 734b88a..acaf774 100644
--- a/main.py
+++ b/main.py
@@ -27,18 +27,24 @@ NACA_NUM = 2412
CHORD_LENGTH = 40
SEMI_SPAN = 50
+# Airfoil thickness
+T_UPPER = 0.1
+T_LOWER = 0.1
+
# Component masses
AIRFOIL_MASS = 10 # lbs
SPAR_MASS = 10 # lbs
STRINGER_MASS = 5 # lbs
# Area
+SPAR_CAP_AREA = 0.3 # sqin
STRINGER_AREA = 0.1 # sqin
+
# Amount of stringers
-TOP_STRINGERS = 8
+TOP_STRINGERS = 7
BOTTOM_STRINGERS = 6
NOSE_TOP_STRINGERS = 4
-NOSE_BOTTOM_STRINGERS = 7
+NOSE_BOTTOM_STRINGERS = 5
# population information & save path
POP_SIZE = 1
@@ -65,16 +71,18 @@ def main():
af.add_naca(NACA_NUM)
af.add_mass(AIRFOIL_MASS)
# af.info_print(2)
- af.info_save(SAVE_PATH, _)
+ # af.info_save(SAVE_PATH, _)
# Create spar instance
af.spar = creator.Spar()
# Define the spar coordinates and mass, stored in single spar object
af.spar.add_coord(af, 0.15)
af.spar.add_coord(af, 0.55)
+ # Automatically adds spar caps for all spars previously defined
+ af.spar.add_spar_caps(SPAR_CAP_AREA)
af.spar.add_mass(SPAR_MASS)
# af.spar.info_print(2)
- af.spar.info_save(SAVE_PATH, _)
+ # af.spar.info_save(SAVE_PATH, _)
# Create stringer instance
af.stringer = creator.Stringer()
@@ -87,7 +95,7 @@ def main():
af.stringer.add_area(STRINGER_AREA)
af.stringer.add_mass(STRINGER_MASS)
# af.stringer.info_print(2)
- af.stringer.info_save(SAVE_PATH, _)
+ # af.stringer.info_save(SAVE_PATH, _)
# Plot components with matplotlib
# creator.plot_geom(af)
@@ -98,7 +106,7 @@ def main():
eval.analysis()
# eval.info_print(2)
eval.info_save(SAVE_PATH, _)
- # evaluator.plot_geom(eval)
+ evaluator.plot_geom(eval)
# evaluator.plot_lift(eval)
# Print final execution time
Copyright 2019--2024 Marius PETER