summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--creator/base.py20
-rw-r--r--creator/wing.py21
-rw-r--r--evaluator/evaluator.py16
-rw-r--r--example_airfoil.py8
4 files changed, 31 insertions, 34 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 = []
diff --git a/evaluator/evaluator.py b/evaluator/evaluator.py
index e6b55b4..680f2d7 100644
--- a/evaluator/evaluator.py
+++ b/evaluator/evaluator.py
@@ -17,21 +17,9 @@ class Evaluator:
Individual aircrafts must claim an Evaluator object as parent."""
def __init__(self, name):
self.name = name
- self.tree = {} # Keys are component names, values are objects
+ self.aircrafts = []
self.results = []
- # # Evaluator knows all geometrical info from evaluated airfoil
- # self.airfoil = self.get_airfoil(aircraft)
- # self.spars = self.get_spars(aircraft)
- # self.stringers = self.get_stringers(aircraft)
- # # Lift
- # self.lift_rectangular = []
- # self.lift_elliptical = []
- # self.lift_total = []
- # # Drag
- # self.drag = []
- # # centroid
- # self.centroid = []
- # Inertia terms:
+
self.I_ = {'x': 0, 'z': 0, 'xz': 0}
def get_lift_rectangular(aircraft, lift):
diff --git a/example_airfoil.py b/example_airfoil.py
index 6c272a2..9626f6f 100644
--- a/example_airfoil.py
+++ b/example_airfoil.py
@@ -62,9 +62,11 @@ af2.add_naca(3412)
spar3 = creator.wing.Spar(af2, 'spar3', 0.23)
spar4 = creator.wing.Spar(af2, 'spar4', 0.67)
-# eval.update_tree()
-# ac2.update_tree()
-print(ac2.tree)
+for aircraft in eval.aircrafts:
+ print(aircraft.wing)
+ for spar in aircraft.wing.spars:
+ print(spar.material["name"])
+
# eval.info_print(2)
# # Create stringer instance
Copyright 2019--2024 Marius PETER