summaryrefslogtreecommitdiff
path: root/creator
diff options
context:
space:
mode:
authorblendoit <blendoit@gmail.com>2019-10-07 02:18:34 -0700
committerblendoit <blendoit@gmail.com>2019-10-07 02:18:34 -0700
commit445a834e6a5e790a7f37730d6e5d8824b8f598f4 (patch)
treeabd6b56bc912bfaa74bb74e2c88733eb84c7deae /creator
parente05225247b4873fa1825a2adeee23f247c77ff03 (diff)
Component tree replaced with subcomponent list
Diffstat (limited to 'creator')
-rw-r--r--creator/base.py20
-rw-r--r--creator/wing.py21
2 files changed, 24 insertions, 17 deletions
diff --git a/creator/base.py b/creator/base.py
index f6342c8..5d90efd 100644
--- a/creator/base.py
+++ b/creator/base.py
@@ -13,23 +13,17 @@ logging.basicConfig(filename='log.txt',
class Aircraft:
"""This class tracks all sub-components and is fed to the evaluator."""
def __init__(self, evaluator, name):
- self.tree = {name: None}
- if type(self).__name__ not in evaluator.tree:
- evaluator.tree[name] = self.tree
- else:
- evaluator.tree[name] = self.tree
+ evaluator.aircrafts.append(self)
self.evaluator = evaluator
self.name = name
+ self.fuselage = None
+ self.propulsion = None
+ self.wing = None
+
class Component:
"""Basic component providing coordinates, tools and a component tree."""
def __init__(self, parent, name):
- self.tree = {type(self).__name__: name}
- # print(type(self).__name__)
- if type(self).__name__ not in parent.tree:
- parent.tree.update(self.tree)
- else:
- parent.tree[name] = self.tree
self.parent = parent
self.name = name
self.x = np.array([])
@@ -37,10 +31,6 @@ class Component:
self.material = None
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()} '
diff --git a/creator/wing.py b/creator/wing.py
index cc7d29a..472e928 100644
--- a/creator/wing.py
+++ b/creator/wing.py
@@ -40,13 +40,20 @@ class Airfoil(base.Component):
semi_span=150,
material=mt.aluminium):
super().__init__(parent, name)
+ parent.wing = self
if chord > 20:
self.chord = chord
else:
self.chord = 20
logging.debug('Chord too small, using minimum value of 20.')
+ parent
self.semi_span = semi_span
self.material = material
+ self.spars = []
+ self.stringers = []
+
+ def __str__(self):
+ return self.name
def add_naca(self, naca_num):
"""Generate surface geometry for a NACA airfoil.
@@ -139,7 +146,8 @@ class Spar(base.Component):
def __init__(self, parent, name, loc_percent=0.30, material=mt.aluminium):
"""Set spar location as percent of chord length."""
super().__init__(parent, name)
- super().set_material(material)
+ parent.spars.append(self)
+ self.material = material
self.cap_area = float()
# bi.bisect_left: returns index of first value in parent.x > loc
# This ensures that spar geom intersects with airfoil geom.
@@ -165,8 +173,17 @@ class Spar(base.Component):
class Stringer(base.Component):
"""Contains the coordinates of all stringers."""
- def __init__(self):
+ def __init__(self, parent, name, den_u, den_l, den_un, den_ul):
+ """
+ parameters:
+
+ den_u: upper stringer density
+ den_l: lower stringer density
+ den_un: upper nose stringer density
+ den_ul: upper nose stringer density
+ """
super().__init__()
+ parent.stringers.append(self)
self.x_start = []
self.x_end = []
self.z_start = []
Copyright 2019--2024 Marius PETER