plot() class methods revised & improved

Commit
7729848607e1ea945a31b89b73f3a3b1c4034977
Author
Marius Peter <blendoit@gmail.com>
Author date
Committer
Marius Peter <blendoit@gmail.com>
Committer date
Changed files
creator.py
index fb6e4e15..1a4ddb74 100644..100644
@@ -222,7 +222,7 @@
222 222 return None
223 223
224 224 def plot(self):
225 Removed: '''This function plots the elements passed as arguments.'''
225 Added: '''This function plots the entire airfoil's geometry.'''
226 226
227 227 # Plot chord
228 228 x_chord = [0, self.chord]
@@ -268,7 +268,9 @@
268 268 plt.ylim(- (1.10 * plot_bound / 2), (1.10 * plot_bound / 2))
269 269 plt.gca().set_aspect('equal', adjustable='box')
270 270 plt.grid(axis='both', linestyle=':', linewidth=1)
271 Removed: plt.show()
271 Added: plt.draw()
272 Added: plt.pause(1)
273 Added: # plt.close()
272 274 return None
273 275
274 276
evaluator.py
index 489b3465..01647a69 100644..100644
@@ -17,7 +17,8 @@
17 17 import sys
18 18 import os.path
19 19 import numpy as np
20 Removed: from math import sin, cos, atan, sqrt
20 Added: from math import sqrt
21 Added: import matplotlib.pyplot as plt
21 22
22 23
23 24 class Airfoil:
@@ -34,11 +35,22 @@
34 35 + airfoil.spar.mass
35 36 + airfoil.stringer.mass)
36 37 self.mass_dist = []
37 Removed:
38 Added: # Upper coordinates
39 Added: self.x_u = airfoil.x_u
40 Added: self.z_u = airfoil.z_u
41 Added: # Lower coordinates
42 Added: self.x_l = airfoil.x_l
43 Added: self.z_l = airfoil.z_l
44 Added: # Spars
45 Added: self.spar = airfoil.spar
46 Added: # Stringers
47 Added: self.stringer = airfoil.stringer
48 Added: # Lifts
38 49 self.lift_rectangular = []
39 50 self.lift_elliptical = []
40 51 self.lift = []
41 52
53 Added: # Drag
42 54 self.drag = []
43 55
44 56 def print_info(self, round):
@@ -142,5 +154,55 @@
142 154 self.centroid = self.get_centroid()
143 155 return None
144 156
145 Removed: # denominator
146 Removed: # z_c =
157 Added: def plot(self):
158 Added: '''This function plots analysis results over the airfoil's geometry.'''
159 Added:
160 Added: # Plot chord
161 Added: x_chord = [0, self.chord]
162 Added: y_chord = [0, 0]
163 Added: plt.plot(x_chord, y_chord, linewidth='1')
164 Added: # Plot quarter chord
165 Added: plt.plot(self.chord / 4, 0, '.', color='g', markersize=24)
166 Added: # Plot upper surface
167 Added: plt.plot(self.x_u, self.z_u,
168 Added: '', color='b', linewidth='1')
169 Added: # Plot lower surface
170 Added: plt.plot(self.x_l, self.z_l,
171 Added: '', color='b', linewidth='1')
172 Added:
173 Added: # Plot spars
174 Added: for _ in range(0, len(self.spar.x_u)):
175 Added: x = (self.spar.x_u[_], self.spar.x_l[_])
176 Added: y = (self.spar.z_u[_], self.spar.z_l[_])
177 Added: plt.plot(x, y, '.-', color='b')
178 Added:
179 Added: # Plot stringers
180 Added: # Upper stringers
181 Added: for _ in range(0, len(self.stringer.x_u)):
182 Added: x = self.stringer.x_u[_]
183 Added: y = self.stringer.z_u[_]
184 Added: plt.plot(x, y, '.', color='y', markersize=12)
185 Added: # Lower stringers
186 Added: for _ in range(0, len(self.stringer.x_l)):
187 Added: x = self.stringer.x_l[_]
188 Added: y = self.stringer.z_l[_]
189 Added: plt.plot(x, y, '.', color='y', markersize=12)
190 Added:
191 Added: # Centroid
192 Added: x = self.centroid[0]
193 Added: y = self.centroid[1]
194 Added: plt.plot(x, y, '.', color='r', markersize=24)
195 Added:
196 Added: # Graph formatting
197 Added: plt.xlabel('X axis')
198 Added: plt.ylabel('Z axis')
199 Added:
200 Added: plot_bound = self.x_u[-1]
201 Added: plt.xlim(- 0.10 * plot_bound, 1.10 * plot_bound)
202 Added: plt.ylim(- (1.10 * plot_bound / 2), (1.10 * plot_bound / 2))
203 Added: plt.gca().set_aspect('equal', adjustable='box')
204 Added: plt.grid(axis='both', linestyle=':', linewidth=1)
205 Added: plt.show()
206 Added: # plt.pause(1)
207 Added: # plt.close()
208 Added: return None
main.py
index 6d9fa9af..2cf4a2e2 100644..100644
@@ -77,7 +77,7 @@
77 77 # af.stringer.print_info(2)
78 78
79 79 # Plot components with matplotlib
80 Removed: af.plot()
80 Added: # af.plot()
81 81
82 82 # Save component info
83 83 # af.save_info(SAVE_PATH, _)
@@ -90,6 +90,7 @@
90 90 eval.analysis()
91 91 eval.print_info(2)
92 92 eval.save_info(SAVE_PATH, _)
93 Added: eval.plot()
93 94
94 95 # Print final execution time
95 96 print("--- %s seconds ---" % (time.time() - start_time))