summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Peter <blendoit@gmail.com>2019-06-23 12:17:37 -0700
committerMarius Peter <blendoit@gmail.com>2019-06-23 12:17:37 -0700
commit3ce3509ea818c289d45de8264068791de91a1b99 (patch)
tree66f7aca46919788c3c5639c5f68514805156f089
parent7a7c4840386adc45ed84985784d57fe3fc345c07 (diff)
bugfix: negative x-coord error for high-camber cases
-rw-r--r--creator.py37
-rw-r--r--evaluator.py23
-rw-r--r--main.py18
3 files changed, 39 insertions, 39 deletions
diff --git a/creator.py b/creator.py
index 0bfe529..3749bf7 100644
--- a/creator.py
+++ b/creator.py
@@ -122,7 +122,7 @@ class Airfoil(Coordinates):
self.naca_num = int()
# Mean camber line
self.x_c = []
- self.y_c = []
+ self.z_c = []
def add_naca(self, naca_num):
'''
@@ -148,22 +148,22 @@ class Airfoil(Coordinates):
def get_camber(x):
'''
- Returns camber y-coordinate from 1 'x' along the airfoil chord.
+ Returns camber z-coordinate from 1 'x' along the airfoil chord.
'''
- y_c = float()
+ z_c = float()
if 0 <= x < p_c:
- y_c = (m / (p ** 2)) * (2 * p * (x / self.chord)
+ z_c = (m / (p ** 2)) * (2 * p * (x / self.chord)
- (x / self.chord) ** 2)
elif p_c <= x <= self.chord:
- y_c = (m / ((1 - p) ** 2)) * ((1 - 2 * p)
+ z_c = (m / ((1 - p) ** 2)) * ((1 - 2 * p)
+ 2 * p * (x / self.chord)
- (x / self.chord) ** 2)
- return (y_c * self.chord)
+ return (z_c * self.chord)
def get_thickness(x):
- '''
- Returns thickness from 1 'x' along the airfoil chord.
- '''
+ '''Returns thickness from 1 'x' along the airfoil chord.'''
+
+ x = 0 if x < 0 else x
y_t = 5 * t * self.chord * (
+ 0.2969 * sqrt(x / self.chord)
- 0.1260 * (x / self.chord)
@@ -173,12 +173,12 @@ class Airfoil(Coordinates):
return y_t
def get_theta(x):
- dy_c = float()
+ dz_c = float()
if 0 <= x < p_c:
- dy_c = ((2 * m) / p ** 2) * (p - x / self.chord)
+ dz_c = ((2 * m) / p ** 2) * (p - x / self.chord)
elif p_c <= x <= self.chord:
- dy_c = (2 * m) / ((1 - p) ** 2) * (p - x / self.chord)
- theta = atan(dy_c)
+ dz_c = (2 * m) / ((1 - p) ** 2) * (p - x / self.chord)
+ theta = atan(dz_c)
return theta
def get_upper_coord(x):
@@ -204,7 +204,7 @@ class Airfoil(Coordinates):
# Generate our airfoil geometry from previous sub-functions.
for x in x_chord:
self.x_c.append(x)
- self.y_c.append(get_camber(x))
+ self.z_c.append(get_camber(x))
self.x.append(get_upper_coord(x)[0])
self.z.append(get_upper_coord(x)[1])
for x in x_chord_rev:
@@ -361,7 +361,7 @@ def plot_geom(airfoil):
plt.plot(airfoil.chord / 4, 0, '.', color='g',
markersize=24, label='Quarter-chord')
# Plot mean camber line
- plt.plot(airfoil.x_c, airfoil.y_c, '-.', color='r', linewidth='2',
+ plt.plot(airfoil.x_c, airfoil.z_c, '-.', color='r', linewidth='2',
label='Mean camber line')
# Plot airfoil surfaces
plt.fill(airfoil.x, airfoil.z, color='b', linewidth='1', fill=False)
@@ -374,7 +374,7 @@ def plot_geom(airfoil):
plt.plot(x, y, '-', color='b')
except AttributeError:
print('No spars to plot.')
- # Plot upper stringers
+ # Plot stringers
try:
for _ in range(0, len(airfoil.stringer.x)):
x = airfoil.stringer.x[_]
@@ -382,11 +382,6 @@ def plot_geom(airfoil):
plt.plot(x, y, '.', color='y', markersize=12)
except AttributeError:
print('No stringers to plot.')
- # # Plot lower stringers
- # for _ in range(0, len(airfoil.stringer.x)):
- # x = airfoil.stringer.x[_]
- # y = airfoil.stringer.z[_]
- # plt.plot(x, y, '.', color='y', markersize=12)
# Graph formatting
plt.xlabel('X axis')
diff --git a/evaluator.py b/evaluator.py
index 867ede9..9512a4b 100644
--- a/evaluator.py
+++ b/evaluator.py
@@ -49,6 +49,8 @@ class Evaluator:
self.lift_total = []
# Drag
self.drag = []
+ # centroid
+ self.centroid = []
# Inertia terms:
# I_x = self.I_[0]
# I_z = self.I_[1]
@@ -141,18 +143,22 @@ class Evaluator:
stringer_area = self.stringer.area
caps_area = self.spar.cap_area
- spar_x = self.spar.x + self.spar.x
+ caps_x = [value for spar in self.spar.x for value in spar]
+ caps_z = [value for spar in self.spar.z for value in spar]
stringers_x = self.stringer.x
stringers_z = self.stringer.z
- denom = float(len(spar_x) * caps_area
- + len(stringers_x) * stringer_area)
+ denominator = float(len(caps_x) * caps_area
+ + len(stringers_x) * stringer_area)
- x_ctr = (sum([i * caps_area for i in spar_x[:][0]])
- + sum([i * stringer_area for i in stringers_x])) / denom
- z_ctr = (sum([i * caps_area for i in spar_x[:][0]])
- + sum([i * stringer_area for i in stringers_z])) / denom
- return(x_ctr, z_ctr)
+ centroid_x = float(sum([x * caps_area for x in caps_x])
+ + sum([x * stringer_area for x in stringers_x]))
+ centroid_x = centroid_x / denominator
+
+ centroid_z = float(sum([z * caps_area for z in caps_z])
+ + sum([z * stringer_area for z in stringers_z]))
+ centroid_z = centroid_z / denominator
+ return(centroid_x, centroid_z)
def get_inertia_terms(self):
'''Obtain all inertia terms.'''
@@ -165,7 +171,6 @@ class Evaluator:
z_stringers = self.stringer.z
x_spars = self.spar.x[:][0] + self.spar.x[:][1]
z_spars = self.spar.z[:][0] + self.spar.z[:][1]
- print(x_spars)
stringer_count = range(len(x_stringers))
spar_count = range(len(self.spar.x))
diff --git a/main.py b/main.py
index 97cd492..f82ca89 100644
--- a/main.py
+++ b/main.py
@@ -23,9 +23,9 @@ import time
start_time = time.time()
# Airfoil dimensions
-NACA_NUM = 4412
-CHORD_LENGTH = 133
-SEMI_SPAN = 140
+NACA_NUM = 2412
+CHORD_LENGTH = 101
+SEMI_SPAN = 40
# Airfoil thickness
T_UPPER = 0.1
@@ -37,11 +37,11 @@ SPAR_MASS = 10 # lbs
STRINGER_MASS = 5 # lbs
# Area
-SPAR_CAP_AREA = 0.3 # sqin
+SPAR_CAP_AREA = 0.0 # sqin
STRINGER_AREA = 0.1 # sqin
# Amount of stringers
-TOP_STRINGERS = 5
+TOP_STRINGERS = 3
BOTTOM_STRINGERS = 4
NOSE_TOP_STRINGERS = 3
NOSE_BOTTOM_STRINGERS = 6
@@ -71,7 +71,7 @@ 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()
@@ -82,7 +82,7 @@ def main():
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()
@@ -95,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)
@@ -106,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