diff options
author | blendoit <blendoit@gmail.com> | 2019-10-06 21:04:34 -0700 |
---|---|---|
committer | blendoit <blendoit@gmail.com> | 2019-10-06 21:04:34 -0700 |
commit | 94ff14d3d1ab01a63aea34636c24fdcd67d4ed79 (patch) | |
tree | 678e19f2f2aaea034a4e949a9db27e31cc310ac4 | |
parent | db1df0c0413949785dc5fa59a887bac00cf11265 (diff) |
dir structure for evaluator
-rw-r--r-- | creator/base.py | 10 | ||||
-rw-r--r-- | evaluator/__init__.py | 1 | ||||
-rw-r--r-- | evaluator/evaluator.py (renamed from evaluator.py) | 12 | ||||
-rw-r--r-- | example_airfoil.py | 3 |
4 files changed, 13 insertions, 13 deletions
diff --git a/creator/base.py b/creator/base.py index 24b452c..1e8646d 100644 --- a/creator/base.py +++ b/creator/base.py @@ -13,17 +13,19 @@ logging.basicConfig(filename='log.txt', class Aircraft: """This class tracks all sub-components and is fed to the evaluator.""" def __init__(self, evaluator, name): - evaluator.tree.update({"aircraft": self}) + self.tree = {name: self} + evaluator.tree[type(self).__name__] = self.tree self.evaluator = evaluator self.name = name - self.tree = [] # Nested list of subcomponents class Component: """Basic component providing coordinates, tools and a component tree.""" def __init__(self, parent, name): - self.tree = [name] - parent.tree.append(self.tree) + self.tree = {name: self} + # parent.tree.update(self.tree) + parent.tree[type(self).__name__] = self.tree + self.parent = parent self.name = name self.x = np.array([]) self.z = np.array([]) diff --git a/evaluator/__init__.py b/evaluator/__init__.py new file mode 100644 index 0000000..1561fb0 --- /dev/null +++ b/evaluator/__init__.py @@ -0,0 +1 @@ +from . import evaluator diff --git a/evaluator.py b/evaluator/evaluator.py index 096e9a0..d26ee13 100644 --- a/evaluator.py +++ b/evaluator/evaluator.py @@ -16,7 +16,7 @@ class Evaluator: """Performs structural evaluations on aircrafts. Individual aircrafts must claim an Evaluator object as parent.""" def __init__(self): - self.tree = {} # Dictionary contains aircrafts and subcomponents + self.tree = {} # Keys are component names, values are objects self.results = [] # # Evaluator knows all geometrical info from evaluated airfoil # self.airfoil = self.get_airfoil(aircraft) @@ -173,12 +173,10 @@ class Evaluator: # return None def update(self): - """Get all aircrafts' data.""" - for aircraft in self.tree: - # print(f"For {aircraft.name} tree is:") - # print("For", aircraft.name, " tree is:") - # print(self.tree) - self.results.append(self.analysis(aircraft)) + """Refresh evaluator aircraft tree.""" + print(self.tree) + + # self.results.append(self.analysis(aircraft)) def analysis(self, aircraft): """Perform all analysis calculations and store in class instance.""" diff --git a/example_airfoil.py b/example_airfoil.py index e559bb7..aa1a5f0 100644 --- a/example_airfoil.py +++ b/example_airfoil.py @@ -11,7 +11,7 @@ Generate a population of airfoils & optimize. import resources.materials as mt import creator -import evaluator +import evaluator.evaluator as evaluator import generator # from generator import @@ -63,7 +63,6 @@ spar3 = creator.wing.Spar(af2, 'spar3', 0.23) spar4 = creator.wing.Spar(af2, 'spar4', 0.67) eval.update() -# print("spar2 parent is:", af.parent) # eval.info_print(2) # # Create stringer instance |