summaryrefslogtreecommitdiff
path: root/creator
diff options
context:
space:
mode:
authorblendoit <blendoit@gmail.com>2019-10-06 19:16:04 -0700
committerblendoit <blendoit@gmail.com>2019-10-06 19:16:04 -0700
commitdb1df0c0413949785dc5fa59a887bac00cf11265 (patch)
tree8ae2368aa194864a3f4697ecf6bd16aa78044d32 /creator
parent8202fe7e323b3f2ade911a828d4737b6ab34689f (diff)
attempt component tree
Diffstat (limited to 'creator')
-rw-r--r--creator/base.py15
-rw-r--r--creator/wing.py4
2 files changed, 9 insertions, 10 deletions
diff --git a/creator/base.py b/creator/base.py
index c46b297..24b452c 100644
--- a/creator/base.py
+++ b/creator/base.py
@@ -12,25 +12,24 @@ logging.basicConfig(filename='log.txt',
class Aircraft:
"""This class tracks all sub-components and is fed to the evaluator."""
- def __init__(self, parent, name):
- self.parent = parent
+ def __init__(self, evaluator, name):
+ evaluator.tree.update({"aircraft": self})
+ self.evaluator = evaluator
self.name = name
- parent.aircrafts.append(name)
+ self.tree = [] # Nested list of subcomponents
class Component:
- """Basic component providing coordinates and tools."""
+ """Basic component providing coordinates, tools and a component tree."""
def __init__(self, parent, name):
- self.parent = None
+ self.tree = [name]
+ parent.tree.append(self.tree)
self.name = name
self.x = np.array([])
self.z = np.array([])
self.material = None
self.mass = float()
- def __str__(self):
- return self.name
-
def set_material(self, material):
"""Set the component bulk material."""
self.material = material
diff --git a/creator/wing.py b/creator/wing.py
index 59f5bbe..cc7d29a 100644
--- a/creator/wing.py
+++ b/creator/wing.py
@@ -24,7 +24,7 @@ import resources.materials as mt
class Airfoil(base.Component):
"""This class represents a single NACA airfoil.
- The coordinates are saved as two lists
+ The coordinates are saved as two np.arrays
for the x- and z-coordinates. The coordinates start at
the leading edge, travel over the airfoil's upper edge,
then loop back to the leading edge via the lower edge.
@@ -141,9 +141,9 @@ class Spar(base.Component):
super().__init__(parent, name)
super().set_material(material)
self.cap_area = float()
- loc = loc_percent * parent.chord
# bi.bisect_left: returns index of first value in parent.x > loc
# This ensures that spar geom intersects with airfoil geom.
+ loc = loc_percent * parent.chord
# Spar upper coordinates
spar_u = bi.bisect_left(parent.x, loc) - 1
self.x = np.append(self.x, parent.x[spar_u])
Copyright 2019--2024 Marius PETER