From 76f3f92a300121f30998d60bd12b10f8c6fd0e2a Mon Sep 17 00:00:00 2001 From: blendoit Date: Mon, 7 Oct 2019 02:57:01 -0700 Subject: final Evaluator implementation --- creator/base.py | 17 +++++++++++------ creator/wing.py | 2 +- example_airfoil.py | 9 +++++---- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/creator/base.py b/creator/base.py index 5d90efd..33ea680 100644 --- a/creator/base.py +++ b/creator/base.py @@ -20,6 +20,9 @@ class Aircraft: self.propulsion = None self.wing = None + def __str__(self): + return self.name + class Component: """Basic component providing coordinates, tools and a component tree.""" @@ -38,11 +41,11 @@ class Component: print(num_of_dashes * '-') print(name) for k, v in self.__dict__.items(): - if type(v) != list: + if type(v) is not np.ndarray: print(f'{k}:\n', v) print(num_of_dashes * '-') for k, v in self.__dict__.items(): - if type(v) == list: + if type(v) is np.ndarray: print(f'{k}:\n', np.around(v, round)) return None @@ -54,14 +57,16 @@ class Component: try: with open(full_path, 'w') as f: for k, v in self.__dict__.items(): - if type(v) != list: - f.write(f'{k}:\n') + if type(v) is not np.ndarray: + f.write(f'{k}=\n') f.write(str(v)) + f.write("\n") # print(num_of_dashes * '-') for k, v in self.__dict__.items(): - if type(v) == list: - f.write(f'{k}:\n') + if type(v) is np.ndarray: + f.write(f'{k}=\n') f.write(str(v)) + f.write("\n") logging.debug(f'Successfully wrote to file {full_path}') except IOError: print(f'Unable to write {file_name} to specified directory.\n', diff --git a/creator/wing.py b/creator/wing.py index 472e928..b21a68c 100644 --- a/creator/wing.py +++ b/creator/wing.py @@ -55,7 +55,7 @@ class Airfoil(base.Component): def __str__(self): return self.name - def add_naca(self, naca_num): + def add_naca(self, naca_num=2412): """Generate surface geometry for a NACA airfoil. The nested functions perform the required steps to generate geometry, diff --git a/example_airfoil.py b/example_airfoil.py index 9626f6f..2828b27 100644 --- a/example_airfoil.py +++ b/example_airfoil.py @@ -18,9 +18,6 @@ import generator import time start_time = time.time() -# Airfoil dimensions (in) -NACA_NUM = 2412 - # Thicknesses SPAR_THICKNESS = 0.4 SKIN_THICKNESS = 0.1 @@ -46,7 +43,7 @@ eval = evaluator.Evaluator("eval") ac = creator.base.Aircraft(eval, "ac") af = creator.wing.Airfoil(ac, 'af') -af.add_naca(NACA_NUM) +af.add_naca(2412) # af.info_print(2) af.info_save() spar1 = creator.wing.Spar(af, 'spar1') @@ -59,10 +56,14 @@ spar2.info_save() ac2 = creator.base.Aircraft(eval, "ac2") af2 = creator.wing.Airfoil(ac2, 'af2') af2.add_naca(3412) +af2.info_save() spar3 = creator.wing.Spar(af2, 'spar3', 0.23) spar4 = creator.wing.Spar(af2, 'spar4', 0.67) +spar3.info_save() +spar4.info_save() for aircraft in eval.aircrafts: + print(aircraft) print(aircraft.wing) for spar in aircraft.wing.spars: print(spar.material["name"]) -- cgit v1.2.3