summaryrefslogtreecommitdiff
path: root/creator/wing.py
diff options
context:
space:
mode:
authorblendoit <blendoit@gmail.com>2019-10-01 23:29:24 -0700
committerblendoit <blendoit@gmail.com>2019-10-01 23:29:24 -0700
commit93cc49e414766f2980e06cbe2b9b8be10ec4472d (patch)
tree93c2c9e44cab44f37f6dee6f7fdafbf53372464d /creator/wing.py
parentfa38b61ff2bd193fad1f320d2d59b8cb34ecd288 (diff)
Proper package structure
Diffstat (limited to 'creator/wing.py')
-rw-r--r--creator/wing.py59
1 files changed, 5 insertions, 54 deletions
diff --git a/creator/wing.py b/creator/wing.py
index 4988cb5..be8e18a 100644
--- a/creator/wing.py
+++ b/creator/wing.py
@@ -11,65 +11,16 @@ Functions:
plot_geom(airfoil): generates a 2D plot of the airfoil & any components.
"""
-import sys
-import os.path
+import creator.base as base
+
import logging
import numpy as np
from math import sin, cos, atan
import bisect as bi
import matplotlib.pyplot as plt
-logging.basicConfig(filename='log.txt',
- level=logging.DEBUG,
- format='%(asctime)s - %(levelname)s - %(message)s')
-
-
-class Component:
- """Basic component providing coordinates and tools."""
-
- # TODO: define defaults in separate module
- def __init__(self):
- self.x = np.array([])
- self.z = np.array([])
- self.material = str()
- self.mass = float()
-
- def set_material(self, material):
- """Set the component bulk material."""
- self.material = material
-
- 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) != list:
- print('{}:\n'.format(k), v)
- print(num_of_dashes * '-')
- for k, v in self.__dict__.items():
- if type(v) == list:
- print('{}:\n'.format(k), np.around(v, round))
- return None
-
- def info_save(self, save_path, number):
- """Save all the object's coordinates (must be full path)."""
- file_name = f'{str(self).lower()}_{number}.txt'
- full_path = os.path.join(save_path, file_name)
- try:
- with open(full_path, 'w') as sys.stdout:
- self.info_print(6)
- # This line required to reset behavior of sys.stdout
- sys.stdout = sys.__stdout__
- 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
-
-class Airfoil(Component):
+class Airfoil(base.Component):
"""This class represents a single NACA airfoil.
The coordinates are saved as two lists
@@ -185,7 +136,7 @@ class Airfoil(Component):
return None
-class Spar(Component):
+class Spar(base.Component):
"""Contains a single spar's data."""
def __init__(self, airfoil, loc_percent, material):
"""Set spar location as percent of chord length."""
@@ -214,7 +165,7 @@ class Spar(Component):
return None
-class Stringer(Component):
+class Stringer(base.Component):
"""Contains the coordinates of all stringers."""
def __init__(self):
super().__init__()
Copyright 2019--2024 Marius PETER