From 8b6f11119790c8c930734894a37d2a4aaa42462d Mon Sep 17 00:00:00 2001 From: blendoit Date: Fri, 1 Nov 2019 18:12:34 -0700 Subject: Start work on optimized multiprocessing random a/c gen. & eval. --- creator/base.py | 93 --------------------------------------------------------- 1 file changed, 93 deletions(-) delete mode 100644 creator/base.py (limited to 'creator/base.py') diff --git a/creator/base.py b/creator/base.py deleted file mode 100644 index 130add3..0000000 --- a/creator/base.py +++ /dev/null @@ -1,93 +0,0 @@ -"""The base.py module contains parent classes for components.""" - -import numpy as np -import os.path -import random -import logging - -import creator - -logging.basicConfig(filename='log_base.txt', - level=logging.DEBUG, - format='%(asctime)s - %(levelname)s - %(message)s') - - -class Aircraft: - """This class tracks all sub-components and is fed to the evaluator.""" - name = None - fuselage = None - propulsion = None - wing = None - properties = {} - - def __init__(self): - self.results = {} - - def __str__(self): - return self.name - - @classmethod - def from_default(cls): - aircraft = creator.base.Aircraft() - aircraft.name = 'default_aircraft_' + str(random.randrange(1000, 9999)) - airfoil = creator.wing.Airfoil(aircraft, 'default_airfoil') - airfoil.add_naca(2412) - soar1 = creator.wing.Spar(airfoil, 'default_spar_1', 0.30) - soar2 = creator.wing.Spar(airfoil, 'default_spar_2', 0.60) - stringer = creator.wing.Stringer(airfoil, 'default_stringer') - return aircraft - - -class Component: - """Basic component providing coordinates, tools and a component tree.""" - def __init__(self, parent, name): - self.parent = parent - self.name = name - self.x = np.array([]) - self.z = np.array([]) - self.y = np.array([]) - self.material = None - self.mass = float() - self.properties = {} - - def __str__(self): - return self.name - - def info_print(self, round): - """Print all the component's coordinates to the terminal.""" - name = f' CREATOR DATA FOR {str(self).upper()} ' - num_of_dashes = len(name) - print(num_of_dashes * '-') - print(name) - for k, v in self.__dict__.items(): - 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) is np.ndarray: - print(f'{k}:\n', np.around(v, round)) - return None - - def info_save(self, - save_path='/home/blendux/Projects/Aircraft_Studio/save'): - """Save all the object's coordinates (must be full path).""" - file_name = f'{self.name}_info.txt' - full_path = os.path.join(save_path, file_name) - try: - with open(full_path, 'w') as f: - for k, v in self.__dict__.items(): - 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) 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', - 'Was the full path passed to the function?') - return None -- cgit v1.2.3