summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Peter <blendoit@gmail.com>2019-06-22 13:51:49 -0700
committerMarius Peter <blendoit@gmail.com>2019-06-22 13:51:49 -0700
commit0e0aeea5d3300306c404ea2c5caff6cb4d66331f (patch)
treeb96ea1445ad30f0ea91ceb07c5f4bb315b0a82fc
parent5e5e39c621db0ebd69cac2fa21b1452261428fe7 (diff)
redefine plot() from class method to module method
-rw-r--r--creator.py99
-rw-r--r--evaluator.py107
-rw-r--r--main.py7
3 files changed, 109 insertions, 104 deletions
diff --git a/creator.py b/creator.py
index 1e375a6..33ed01d 100644
--- a/creator.py
+++ b/creator.py
@@ -224,55 +224,6 @@ class Airfoil(Coordinates):
print('z_c the camber z-coordinates:\n', np.around(self.x_u, round))
return None
- def plot(self):
- '''This function plots the entire airfoil's geometry.'''
-
- # Plot chord
- x_chord = [0, self.chord]
- y_chord = [0, 0]
- plt.plot(x_chord, y_chord, linewidth='1')
- # Plot quarter chord
- plt.plot(self.chord / 4, 0, '.', color='g', markersize=24)
- # Plot mean camber line
- plt.plot(self.x_c, self.y_c,
- '-.', color='r', linewidth='2',
- label='mean camber line')
- # Plot upper surface
- plt.plot(self.x_u, self.z_u,
- '', color='b', linewidth='1')
- # Plot lower surface
- plt.plot(self.x_l, self.z_l,
- '', color='b', linewidth='1')
-
- # Plot spars
- for _ in range(0, len(self.spar.x_u)):
- x = (self.spar.x_u[_], self.spar.x_l[_])
- y = (self.spar.z_u[_], self.spar.z_l[_])
- plt.plot(x, y, '.-', color='b')
-
- # Plot upper stringers
- for _ in range(0, len(self.stringer.x_u)):
- x = self.stringer.x_u[_]
- y = self.stringer.z_u[_]
- plt.plot(x, y, '.', color='y', markersize=12)
- # Plot lower stringers
- for _ in range(0, len(self.stringer.x_l)):
- x = self.stringer.x_l[_]
- y = self.stringer.z_l[_]
- plt.plot(x, y, '.', color='y', markersize=12)
-
- # Graph formatting
- plt.xlabel('X axis')
- plt.ylabel('Z axis')
-
- plot_bound = self.x_u[-1]
- plt.xlim(- 0.10 * plot_bound, 1.10 * plot_bound)
- plt.ylim(- (1.10 * plot_bound / 2), (1.10 * plot_bound / 2))
- plt.gca().set_aspect('equal', adjustable='box')
- plt.grid(axis='both', linestyle=':', linewidth=1)
- plt.show()
- return None
-
class Spar(Coordinates):
'''Contains a single spar's location.'''
@@ -411,6 +362,56 @@ class Stringer(Coordinates):
return None
+def plot(airfoil):
+ '''This function plots the airfoil's + sub-components' geometry.'''
+
+ # Plot chord
+ x_chord = [0, airfoil.chord]
+ y_chord = [0, 0]
+ plt.plot(x_chord, y_chord, linewidth='1')
+ # Plot quarter chord
+ plt.plot(airfoil.chord / 4, 0, '.', color='g', markersize=24)
+ # Plot mean camber line
+ plt.plot(airfoil.x_c, airfoil.y_c,
+ '-.', color='r', linewidth='2',
+ label='mean camber line')
+ # Plot upper surface
+ plt.plot(airfoil.x_u, airfoil.z_u,
+ '', color='b', linewidth='1')
+ # Plot lower surface
+ plt.plot(airfoil.x_l, airfoil.z_l,
+ '', color='b', linewidth='1')
+
+ # Plot spars
+ for _ in range(0, len(airfoil.spar.x_u)):
+ x = (airfoil.spar.x_u[_], airfoil.spar.x_l[_])
+ y = (airfoil.spar.z_u[_], airfoil.spar.z_l[_])
+ plt.plot(x, y, '.-', color='b')
+
+ # Plot upper stringers
+ for _ in range(0, len(airfoil.stringer.x_u)):
+ x = airfoil.stringer.x_u[_]
+ y = airfoil.stringer.z_u[_]
+ plt.plot(x, y, '.', color='y', markersize=12)
+ # Plot lower stringers
+ for _ in range(0, len(airfoil.stringer.x_l)):
+ x = airfoil.stringer.x_l[_]
+ y = airfoil.stringer.z_l[_]
+ plt.plot(x, y, '.', color='y', markersize=12)
+
+ # Graph formatting
+ plt.xlabel('X axis')
+ plt.ylabel('Z axis')
+
+ plot_bound = airfoil.x_u[-1]
+ plt.xlim(- 0.10 * plot_bound, 1.10 * plot_bound)
+ plt.ylim(- (1.10 * plot_bound / 2), (1.10 * plot_bound / 2))
+ plt.gca().set_aspect('equal', adjustable='box')
+ plt.grid(axis='both', linestyle=':', linewidth=1)
+ plt.show()
+ return None
+
+
def main():
return None
diff --git a/evaluator.py b/evaluator.py
index b0d90fd..c350974 100644
--- a/evaluator.py
+++ b/evaluator.py
@@ -21,7 +21,7 @@ from math import sqrt
import matplotlib.pyplot as plt
-class Airfoil:
+class Evaluator:
'''Performs structural evaluations for the airfoil passed as argument.'''
def __init__(self, airfoil):
@@ -143,7 +143,9 @@ class Airfoil:
return(x_centroid, z_centroid)
def get_I_x(self):
- pass
+ I_x = float()
+ i_x = int()
+ print(I_x)
def get_I_z(self):
pass
@@ -167,53 +169,54 @@ class Airfoil:
self.I_xz = self.get_I_xz()
return None
- def plot(self):
- '''This function plots analysis results over the airfoil's geometry.'''
-
- # Plot chord
- x_chord = [0, self.chord]
- y_chord = [0, 0]
- plt.plot(x_chord, y_chord, linewidth='1')
- # Plot quarter chord
- q = self.chord / 4
- plt.plot(q, 0, '.', color='g', markersize=24, label='quarter-chord')
- # Plot upper surface
- plt.plot(self.x_u, self.z_u,
- '', color='b', linewidth='1')
- # Plot lower surface
- plt.plot(self.x_l, self.z_l,
- '', color='b', linewidth='1')
-
- # Plot spars
- for _ in range(0, len(self.spar.x_u)):
- x = (self.spar.x_u[_], self.spar.x_l[_])
- y = (self.spar.z_u[_], self.spar.z_l[_])
- plt.plot(x, y, '.-', color='b')
-
- # Plot upper stringers
- for _ in range(0, len(self.stringer.x_u)):
- x = self.stringer.x_u[_]
- y = self.stringer.z_u[_]
- plt.plot(x, y, '.', color='y', markersize=12)
- # Plot lower stringers
- for _ in range(0, len(self.stringer.x_l)):
- x = self.stringer.x_l[_]
- y = self.stringer.z_l[_]
- plt.plot(x, y, '.', color='y', markersize=12)
-
- # Plot centroid
- x = self.centroid[0]
- y = self.centroid[1]
- plt.plot(x, y, '.', color='r', markersize=24, label='centroid')
-
- # Graph formatting
- plt.xlabel('X axis')
- plt.ylabel('Z axis')
-
- plot_bound = self.x_u[-1]
- plt.xlim(- 0.10 * plot_bound, 1.10 * plot_bound)
- plt.ylim(- (1.10 * plot_bound / 2), (1.10 * plot_bound / 2))
- plt.gca().set_aspect('equal', adjustable='box')
- plt.grid(axis='both', linestyle=':', linewidth=1)
- plt.show()
- return None
+
+def plot(evaluator):
+ '''This function plots analysis results over the airfoil's geometry.'''
+
+ # Plot chord
+ x_chord = [0, evaluator.chord]
+ y_chord = [0, 0]
+ plt.plot(x_chord, y_chord, linewidth='1')
+ # Plot quarter chord
+ q = evaluator.chord / 4
+ plt.plot(q, 0, '.', color='g', markersize=24, label='quarter-chord')
+ # Plot upper surface
+ plt.plot(evaluator.x_u, evaluator.z_u,
+ '', color='b', linewidth='1')
+ # Plot lower surface
+ plt.plot(evaluator.x_l, evaluator.z_l,
+ '', color='b', linewidth='1')
+
+ # Plot spars
+ for _ in range(0, len(evaluator.spar.x_u)):
+ x = (evaluator.spar.x_u[_], evaluator.spar.x_l[_])
+ y = (evaluator.spar.z_u[_], evaluator.spar.z_l[_])
+ plt.plot(x, y, '.-', color='b')
+
+ # Plot upper stringers
+ for _ in range(0, len(evaluator.stringer.x_u)):
+ x = evaluator.stringer.x_u[_]
+ y = evaluator.stringer.z_u[_]
+ plt.plot(x, y, '.', color='y', markersize=12)
+ # Plot lower stringers
+ for _ in range(0, len(evaluator.stringer.x_l)):
+ x = evaluator.stringer.x_l[_]
+ y = evaluator.stringer.z_l[_]
+ plt.plot(x, y, '.', color='y', markersize=12)
+
+ # Plot centroid
+ x = evaluator.centroid[0]
+ y = evaluator.centroid[1]
+ plt.plot(x, y, '.', color='r', markersize=24, label='centroid')
+
+ # Graph formatting
+ plt.xlabel('X axis')
+ plt.ylabel('Z axis')
+
+ plot_bound = evaluator.x_u[-1]
+ plt.xlim(- 0.10 * plot_bound, 1.10 * plot_bound)
+ plt.ylim(- (1.10 * plot_bound / 2), (1.10 * plot_bound / 2))
+ plt.gca().set_aspect('equal', adjustable='box')
+ plt.grid(axis='both', linestyle=':', linewidth=1)
+ plt.show()
+ return None
diff --git a/main.py b/main.py
index a112542..fb143cd 100644
--- a/main.py
+++ b/main.py
@@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
import creator # Create geometry
import evaluator # Evaluate geometry
import generator # Iteratevely evaluate instances of geometry and optimize
@@ -88,15 +89,15 @@ def main():
af.stringer.info_save(SAVE_PATH, _)
# Plot components with matplotlib
- af.plot()
+ creator.plot(af)
# evaluator.Evaluator instance contains airfoil analysis results.
- eval = evaluator.Airfoil(af)
+ eval = evaluator.Evaluator(af)
# The analysis is performed in the evaluator.py module.
eval.analysis()
eval.info_print(2)
eval.info_save(SAVE_PATH, _)
- eval.plot()
+ evaluator.plot(eval)
# Print final execution time
print("--- %s seconds ---" % (time.time() - start_time))
Copyright 2019--2024 Marius PETER