diff options
author | Marius Peter <blendoit@gmail.com> | 2019-06-23 02:09:34 -0700 |
---|---|---|
committer | Marius Peter <blendoit@gmail.com> | 2019-06-23 02:09:34 -0700 |
commit | 3074c4c8cbeac6a6e5a4d7fa4a8afe34ec39911d (patch) | |
tree | aa4d2400edc78298ae067a63eb93e3aeb0c41c7f | |
parent | 5de63cf149ba044444531e7a5eb5a40ec67dcaed (diff) |
finalised branch :)
-rw-r--r-- | creator.py | 6 | ||||
-rw-r--r-- | evaluator.py | 76 | ||||
-rw-r--r-- | main.py | 20 |
3 files changed, 54 insertions, 48 deletions
@@ -358,7 +358,7 @@ def plot_geom(airfoil): y_chord = [0, 0] plt.plot(x_chord, y_chord, linewidth='1') # Plot quarter chord - plt.plot(airfoil.chord / 4, 0, '', color='g', + 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', @@ -392,7 +392,9 @@ def plot_geom(airfoil): plt.xlabel('X axis') plt.ylabel('Z axis') - # plot_bound = airfoil.x[-1] + plot_bound = max(airfoil.x) + plt.xlim(- 0.10 * plot_bound, 1.10 * plot_bound) + plt.ylim(- (1.10 * plot_bound / 2), (1.10 * plot_bound / 2)) plt.gca().set_aspect('equal', adjustable='box') plt.gca().legend() plt.grid(axis='both', linestyle=':', linewidth=1) diff --git a/evaluator.py b/evaluator.py index 801c5ae..867ede9 100644 --- a/evaluator.py +++ b/evaluator.py @@ -137,19 +137,21 @@ class Evaluator: def get_centroid(self): '''Return the coordinates of the centroid.''' + stringer_area = self.stringer.area caps_area = self.spar.cap_area - x_spars = self.spar.x + self.spar.x - x_stringers = self.stringer.x + self.stringer.x - z_stringers = self.stringer.z + self.stringer.z - denom = float(len(x_spars) * caps_area - + len(x_stringers) * stringer_area) + spar_x = self.spar.x + self.spar.x + stringers_x = self.stringer.x + stringers_z = self.stringer.z + + denom = float(len(spar_x) * caps_area + + len(stringers_x) * stringer_area) - x_ctr = (sum([i * caps_area for i in self.spar.x]) - + sum([i * stringer_area for i in x_stringers])) / denom - z_ctr = (sum([i * caps_area for i in self.spar.z]) - + sum([i * stringer_area for i in z_stringers])) / denom + 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) def get_inertia_terms(self): @@ -159,10 +161,11 @@ class Evaluator: caps_area = self.spar.cap_area # Adds upper and lower components' coordinates to list - x_stringers = self.stringer.x + self.stringer.x - z_stringers = self.stringer.z + self.stringer.z - x_spars = self.spar.x + self.spar.x - z_spars = self.spar.z + self.spar.z + x_stringers = self.stringer.x + 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)) @@ -209,31 +212,32 @@ def plot_geom(evaluator): y_chord = [0, 0] plt.plot(x_chord, y_chord, linewidth='1') # Plot quarter chord - q = evaluator.chord / 4 - plt.plot(q, 0, '.', color='g', markersize=24, label='Quarter-chord') - # Plot upper surface - plt.plot(evaluator.x, evaluator.z, - '', color='b', linewidth='1') - # Plot lower surface - plt.plot(evaluator.x, evaluator.z, - '', color='b', linewidth='1') + plt.plot(evaluator.chord / 4, 0, '.', color='g', + markersize=24, label='Quarter-chord') + # Plot airfoil surfaces + plt.fill(evaluator.x, evaluator.z, color='b', linewidth='1', fill=False) # Plot spars - for _ in range(0, len(evaluator.spar.x)): - x = (evaluator.spar.x[_], evaluator.spar.x[_]) - y = (evaluator.spar.z[_], evaluator.spar.z[_]) - plt.plot(x, y, '.-', color='b') - + try: + for _ in range(len(evaluator.spar.x)): + x = (evaluator.spar.x[_]) + y = (evaluator.spar.z[_]) + plt.plot(x, y, '-', color='b') + except AttributeError: + print('No spars to plot.') # Plot upper stringers - for _ in range(0, len(evaluator.stringer.x)): - x = evaluator.stringer.x[_] - y = evaluator.stringer.z[_] - plt.plot(x, y, '.', color='y', markersize=12) - # Plot lower stringers - for _ in range(0, len(evaluator.stringer.x)): - x = evaluator.stringer.x[_] - y = evaluator.stringer.z[_] - plt.plot(x, y, '.', color='y', markersize=12) + try: + for _ in range(0, len(evaluator.stringer.x)): + x = evaluator.stringer.x[_] + y = evaluator.stringer.z[_] + plt.plot(x, y, '.', color='y', markersize=12) + except AttributeError: + print('No stringers to plot.') + # # Plot lower stringers + # for _ in range(0, len(evaluator.stringer.x)): + # x = evaluator.stringer.x[_] + # y = evaluator.stringer.z[_] + # plt.plot(x, y, '.', color='y', markersize=12) # Plot centroid x = evaluator.centroid[0] @@ -244,7 +248,7 @@ def plot_geom(evaluator): plt.xlabel('X axis') plt.ylabel('Z axis') - plot_bound = evaluator.x[-1] + plot_bound = max(evaluator.x) plt.xlim(- 0.10 * plot_bound, 1.10 * plot_bound) plt.ylim(- (1.10 * plot_bound / 2), (1.10 * plot_bound / 2)) plt.gca().set_aspect('equal', adjustable='box') @@ -25,7 +25,7 @@ start_time = time.time() # Airfoil dimensions NACA_NUM = 2412 CHORD_LENGTH = 100 -SEMI_SPAN = 20 +SEMI_SPAN = 140 # Airfoil thickness T_UPPER = 0.1 @@ -41,8 +41,8 @@ SPAR_CAP_AREA = 0.3 # sqin STRINGER_AREA = 0.1 # sqin # Amount of stringers -TOP_STRINGERS = 4 -BOTTOM_STRINGERS = 7 +TOP_STRINGERS = 5 +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,17 +95,17 @@ 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) + # creator.plot_geom(af) # Evaluator object contains airfoil analysis results. - # eval = evaluator.Evaluator(af) + eval = evaluator.Evaluator(af) # The analysis is performed in the evaluator.py module. - # eval.analysis() + eval.analysis() # eval.info_print(2) - # eval.info_save(SAVE_PATH, _) + eval.info_save(SAVE_PATH, _) # evaluator.plot_geom(eval) # evaluator.plot_lift(eval) |