summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--creator.py31
-rw-r--r--evaluator.py31
-rw-r--r--generator.py20
-rw-r--r--main.py14
4 files changed, 81 insertions, 15 deletions
diff --git a/creator.py b/creator.py
index df714a8..3a36bd8 100644
--- a/creator.py
+++ b/creator.py
@@ -221,8 +221,8 @@ class Airfoil(Coordinates):
def info_print(self, round):
super().info_print(round)
- print('x_c the camber x-coordinates:\n', np.around(self.x, round))
- print('z_c the camber z-coordinates:\n', np.around(self.x, round))
+ print('x_c the camber x-coordinates:\n', np.around(self.x_c, round))
+ print('z_c the camber z-coordinates:\n', np.around(self.z_c, round))
return None
@@ -237,6 +237,10 @@ class Spar(Coordinates):
self.thickness = float()
self.z_start = []
self.z_end = []
+ self.dx = float()
+ self.dz = float()
+ self.dP_x = float()
+ self.dP_z = float()
def add_coord(self, airfoil, x_loc_percent):
'''
@@ -274,15 +278,15 @@ class Spar(Coordinates):
self.mass = len(self.x) * mass
return None
- def add_webs(self, skin_thickness):
+ def add_webs(self, thickness):
'''Add webs to spars.'''
for _ in range(len(self.x)):
self.x_start.append(self.x[_][0])
self.x_end.append(self.x[_][1])
- self.thickness = skin_thickness
self.z_start.append(self.z[_][0])
self.z_end.append(self.z[_][1])
+ self.thickness = thickness
return None
@@ -292,7 +296,16 @@ class Stringer(Coordinates):
def __init__(self):
super().__init__(parent.chord, parent.semi_span)
+ self.x_start = []
+ self.x_end = []
+ self.thickness = float()
+ self.z_start = []
+ self.z_end = []
self.area = float()
+ # self.dx = float()
+ # self.dz = float()
+ # self.dP_x = float()
+ # self.dP_z = float()
def add_coord(self, airfoil,
stringer_u_1, stringer_u_2,
@@ -364,7 +377,15 @@ class Stringer(Coordinates):
return None
def add_webs(self, thickness):
- pass
+ '''Add webs to stringers.'''
+
+ for _ in range(len(self.x) // 2):
+ self.x_start.append(self.x[_])
+ self.x_end.append(self.x[_ + 1])
+ self.z_start.append(self.z[_])
+ self.z_end.append(self.z[_ + 1])
+ self.thickness = thickness
+ return None
def info_print(self, round):
super().info_print(round)
diff --git a/evaluator.py b/evaluator.py
index c2429d1..05900e9 100644
--- a/evaluator.py
+++ b/evaluator.py
@@ -76,6 +76,8 @@ class Evaluator:
print('I_x:\n', np.around(self.I_[0], 3))
print('I_z:\n', np.around(self.I_[1], 3))
print('I_xz:\n', np.around(self.I_[2], 3))
+ print('Spar dP_x:\n', self.spar.dP_x)
+ print('Spar dP_z:\n', self.spar.dP_z)
print(num_of_dashes * '-')
print('Rectangular lift along semi-span:\n',
np.around(self.lift_rectangular, round))
@@ -113,7 +115,8 @@ class Evaluator:
return L_prime
def get_lift_elliptical(self, L_0):
- L_prime = [L_0 * sqrt(1 - (y / self.semi_span) ** 2)
+ L_prime = [L_0 / (self.semi_span * 2)
+ * sqrt(1 - (y / self.semi_span) ** 2)
for y in range(self.semi_span)]
return L_prime
@@ -196,18 +199,40 @@ class Evaluator:
return(I_x, I_z, I_xz)
- def analysis(self):
+ def analysis(self, V_x, V_z):
'''Perform all analysis calculations and store in class instance.'''
+ def get_dp(xDist, zDist, V_x, V_z, I_x, I_z, I_xz, area):
+ denom = float(I_x * I_z - I_xz ** 2)
+ z = float()
+ for _ in range(len(xDist)):
+ z += float(- area * xDist[_] * (I_x * V_x - I_xz * V_z)
+ / denom
+ - area * zDist[_] * (I_z * V_z - I_xz * V_x)
+ / denom)
+ return z
+
+ def get_dx(component):
+ return [x - self.centroid[0] for x in component.x_start]
+
+ def get_dz(component):
+ return [x - self.centroid[1] for x in component.x_start]
+
self.drag = self.get_drag(10)
- self.lift_rectangular = self.get_lift_rectangular(1000)
+ self.lift_rectangular = self.get_lift_rectangular(13.7)
self.lift_elliptical = self.get_lift_elliptical(15)
self.lift_total = self.get_lift_total()
self.mass_dist = self.get_mass_distribution(self.mass_total)
self.centroid = self.get_centroid()
self.I_ = self.get_inertia_terms()
+ self.spar.dP_x = get_dp(get_dx(self.spar), get_dz(self.spar), V_x, 0,
+ self.I_[0], self.I_[1], self.I_[2],
+ self.spar.cap_area)
+ self.spar.dP_z = get_dp(get_dx(self.spar), get_dz(self.spar), 0, V_z,
+ self.I_[0], self.I_[1], self.I_[2],
+ self.spar.cap_area)
return None
diff --git a/generator.py b/generator.py
index 6a87b7e..7ad2cf3 100644
--- a/generator.py
+++ b/generator.py
@@ -14,3 +14,23 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import creator
+
+
+class Population:
+ '''Collection of random airfoils.'''
+
+ def __init__(self, size):
+ self.size = size
+ self.gen_number = 0 # incremented for every generation
+
+ def mutate(self, prob_mt):
+ '''Randomly mutate the genes of prob_mt % of the population.'''
+
+ def crossover(self, prob_cx):
+ '''Combine the genes of prob_cx % of the population.'''
+
+ def reproduce(self, prob_rp):
+ '''Pass on the genes of the fittest prob_rp % of the population.'''
+
+ def fitness():
+ '''Rate the fitness of an individual on a relative scale (0-100)'''
diff --git a/main.py b/main.py
index b015f6f..abbd339 100644
--- a/main.py
+++ b/main.py
@@ -70,7 +70,7 @@ def main():
# Define NACA airfoil coordinates and mass
af.add_naca(NACA_NUM)
af.add_mass(AIRFOIL_MASS)
- # af.info_print(2)
+ af.info_print(2)
af.info_save(SAVE_PATH, _)
# Create spar instance
@@ -82,7 +82,7 @@ def main():
af.spar.add_spar_caps(SPAR_CAP_AREA)
af.spar.add_mass(SPAR_MASS)
af.spar.add_webs(SPAR_THICKNESS)
- # af.spar.info_print(2)
+ af.spar.info_print(2)
af.spar.info_save(SAVE_PATH, _)
# Create stringer instance
@@ -96,20 +96,20 @@ def main():
af.stringer.add_area(STRINGER_AREA)
af.stringer.add_mass(STRINGER_MASS)
af.stringer.add_webs(SKIN_THICKNESS)
- # af.stringer.info_print(2)
+ af.stringer.info_print(2)
af.stringer.info_save(SAVE_PATH, _)
# Plot components with matplotlib
- # creator.plot_geom(af)
+ creator.plot_geom(af)
# Evaluator object contains airfoil analysis results.
eval = evaluator.Evaluator(af)
# The analysis is performed in the evaluator.py module.
- eval.analysis()
- # eval.info_print(2)
+ eval.analysis(1, 1)
+ eval.info_print(2)
eval.info_save(SAVE_PATH, _)
evaluator.plot_geom(eval)
- # evaluator.plot_lift(eval)
+ evaluator.plot_lift(eval)
# Print final execution time
print("--- %s seconds ---" % (time.time() - start_time))
Copyright 2019--2024 Marius PETER