diff options
-rw-r--r-- | creator.py | 17 | ||||
-rw-r--r-- | evaluator.py | 8 | ||||
-rw-r--r-- | main.py | 48 |
3 files changed, 40 insertions, 33 deletions
@@ -69,10 +69,6 @@ class Coordinates: def __str__(self):
return type(self).__name__
- def add_area(self, area):
- self.area = area
- return None
-
def print_info(self, round):
"""
Print all the component's coordinates to the terminal.
@@ -301,6 +297,7 @@ class Stringer(Coordinates): def __init__(self):
super().__init__(parent.chord, parent.semi_span)
+ self.area = float()
def add_coord(self, airfoil_coord, spar_coord,
stringer_u_1, stringer_u_2, stringer_l_1, stringer_l_2):
@@ -333,6 +330,7 @@ class Stringer(Coordinates): spar_z_l = spar_coord[3]
except:
print('Unable to initialize stringers. Were spars created?')
+
# Find distance between leading edge and first upper stringer
interval = spar_x_u[0] / (stringer_u_1 + 1)
# initialise first self.stringer_x_u at first interval
@@ -370,12 +368,21 @@ class Stringer(Coordinates): self.x_l.append(airfoil_x_l[index])
self.z_l.append(airfoil_z_l[index])
x += interval
-
super().pack_info()
return None
+ def add_area(self, area):
+ self.area = area
+ return None
+
def add_mass(self, mass):
self.mass = len(self.x_u) * mass + len(self.x_l) * mass
+ return None
+
+ def print_info(self, round):
+ super().print_info(round)
+ print('Stringer Area:\n', np.around(self.area, round))
+ return None
def plot(airfoil, spar, stringer):
diff --git a/evaluator.py b/evaluator.py index f3a05f4..4a65a4e 100644 --- a/evaluator.py +++ b/evaluator.py @@ -20,6 +20,8 @@ def get_centroid(airfoil): pass -def get_mass(*component): - for _ in len(component): - mass += component.mass +def get_total_mass(self, *component): + total_mass = float() + for _ in component: + total_mass += _.mass + return total_mass @@ -24,18 +24,25 @@ start_time = time.time() CHORD_LENGTH = 100 SEMI_SPAN = 200 -# mass +# m=Mass AIRFOIL_MASS = 100 # lbs SPAR_MASS = 10 # lbs STRINGER_MASS = 5 # lbs +# Area +STRINGER_AREA = 0.1 # sqin + # population information POP_SIZE = 1 SAVE_PATH = 'C:/Users/blend/github/UCLA_MAE_154B/save' -def create(): - '''Create an airfoil.''' +def main(): + ''' + Create an airfoil; + Evaluate an airfoil; + Generate a population of airfoils & optimize. + ''' # Create coordinate system specific to our airfoil dimensions. # TODO: imperial + metric unit setting @@ -49,7 +56,7 @@ def create(): # Define NACA airfoil coordinates and mass af.add_naca(2412) af.add_mass(AIRFOIL_MASS) - af.print_info(2) + # af.print_info(2) # Create spar instance af.spar = creator.Spar() @@ -57,41 +64,32 @@ def create(): 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() # Compute the stringer coordinates from their quantity in each zone 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) # 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, _) - af.spar.save_info(SAVE_PATH, _) - af.stringer.save_info(SAVE_PATH, _) - - # Print final execution time - print("--- %s seconds ---" % (time.time() - start_time)) - + # af.save_info(SAVE_PATH, _) + # af.spar.save_info(SAVE_PATH, _) + # af.stringer.save_info(SAVE_PATH, _) -def evaluate(): - '''Evaluate previously created airfoil(s).''' - pass + # Evaluate previously created airfoil(s). + total_mass = evaluator.get_total_mass(af, af.spar, af.stringer) + # Iteratively evaluate airfoils by defining genetic generations. + # pass -def generate(): - '''Iteratively evaluate airfoils by defining genetic generations.''' - pass - - -def main(): - create() - evaluate() - generate() + # Print final execution time + print("--- %s seconds ---" % (time.time() - start_time)) if __name__ == '__main__': |