From 0452be24400a6960b5471c4d552f881859e7986f Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Thu, 20 Jun 2019 16:23:30 -0700 Subject: remove unused exception catching --- creator.py | 37 +++++++++++++++---------------------- main.py | 16 +++++++++------- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/creator.py b/creator.py index 3f6cbd8..6cc2268 100644 --- a/creator.py +++ b/creator.py @@ -243,7 +243,7 @@ class Spar(Coordinates): # Scaled spar location with regards to chord loc = spar_x * self.chord # bisect_left: returns index of first value in x_u > loc. - # This ensures that the spar coordinates intersect with airfoil surface. + # Ensures that the spar coordinates intersect with airfoil surface. spar_x_u = bi.bisect_left(x_u, loc) # index of spar's x_u spar_x_l = bi.bisect_left(x_l, loc) # index of spar's x_l # These x and y coordinates are assigned to the spar, NOT airfoil. @@ -374,29 +374,22 @@ def plot(airfoil, spar, stringer): plt.plot(airfoil.x_l, airfoil.z_l, '', color='b', linewidth='1') # Plot spars - try: - for _ in range(0, len(spar.x_u)): - x = (spar.x_u[_], spar.x_l[_]) - y = (spar.z_u[_], spar.z_l[_]) - plt.plot(x, y, '.-', color='b') - # plt.legend() - except: - print('Did not plot spars. Were they added?') + for _ in range(0, len(spar.x_u)): + x = (spar.x_u[_], spar.x_l[_]) + y = (spar.z_u[_], spar.z_l[_]) + plt.plot(x, y, '.-', color='b') # Plot stringers - try: - # Upper stringers - for _ in range(0, len(stringer.x_u)): - x = stringer.x_u[_] - y = stringer.z_u[_] - plt.plot(x, y, '.', color='y') - # Lower stringers - for _ in range(0, len(stringer.x_l)): - x = stringer.x_l[_] - y = stringer.z_l[_] - plt.plot(x, y, '.', color='y') - except: - print('Unable to plot stringers. Were they created?') + # Upper stringers + for _ in range(0, len(stringer.x_u)): + x = stringer.x_u[_] + y = stringer.z_u[_] + plt.plot(x, y, '.', color='y') + # Lower stringers + for _ in range(0, len(stringer.x_l)): + x = stringer.x_l[_] + y = stringer.z_l[_] + plt.plot(x, y, '.', color='y') # Graph formatting plt.gca().set_aspect('equal', adjustable='box') diff --git a/main.py b/main.py index 9d9db82..fe5bb10 100644 --- a/main.py +++ b/main.py @@ -21,10 +21,12 @@ import random import time start_time = time.time() -CHORD_LENGTH = 10 +# Airfoil dimensions +NACA_NUM = 4412 +CHORD_LENGTH = 100 SEMI_SPAN = 200 -# m=Mass +# Component masses AIRFOIL_MASS = 100 # lbs SPAR_MASS = 10 # lbs STRINGER_MASS = 5 # lbs @@ -54,9 +56,9 @@ def main(): # Create airfoil instance af = creator.Airfoil() # Define NACA airfoil coordinates and mass - af.add_naca(2412) + af.add_naca(NACA_NUM) af.add_mass(AIRFOIL_MASS) - af.print_info(2) + # af.print_info(2) # Create spar instance af.spar = creator.Spar() @@ -64,7 +66,7 @@ def main(): 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_info(2) + # af.spar.print_info(2) # Create stringer instance af.stringer = creator.Stringer() @@ -72,10 +74,10 @@ def main(): af.stringer.add_coord(af.coord, af.spar.coord, 4, 7, 5, 6) af.stringer.add_area(STRINGER_AREA) af.stringer.add_mass(STRINGER_MASS) - af.stringer.print_info(2) + # af.stringer.print_info(2) # Plot components with matplotlib - # creator.plot(af, af.spar, af.stringer) + creator.plot(af, af.spar, af.stringer) # Save component info af.save_info(SAVE_PATH, _) -- cgit v1.2.3