summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Peter <blendoit@gmail.com>2019-06-30 12:46:49 -0700
committerMarius Peter <blendoit@gmail.com>2019-06-30 12:46:49 -0700
commit67d94c01bd52ef011c4527b39c26a3419f8dd563 (patch)
treeb0d03907e24197bdc8579ad920d81e2f4112a8ed
parent4d8cb31d1fd94d2414c908aa78fabc5ea5d7d4b7 (diff)
move default airfoil generator from gui to generator.py
-rw-r--r--generator.py23
-rw-r--r--gui.py40
2 files changed, 31 insertions, 32 deletions
diff --git a/generator.py b/generator.py
index 6c9d03c..eb0ef65 100644
--- a/generator.py
+++ b/generator.py
@@ -20,6 +20,29 @@ which represents a collection of randomized airfoils.
import creator
+def default_airfoil():
+ """Generate the default airfoil."""
+
+ airfoil = creator.Airfoil.from_dimensions(100, 200)
+ airfoil.add_naca(2412)
+ airfoil.add_mass(10)
+
+ airfoil.spar = creator.Spar()
+ airfoil.spar.add_coord(airfoil, 0.23)
+ airfoil.spar.add_coord(airfoil, 0.57)
+ airfoil.spar.add_spar_caps(0.3)
+ airfoil.spar.add_mass(10)
+ airfoil.spar.add_webs(0.4)
+
+ airfoil.stringer = creator.Stringer()
+ airfoil.stringer.add_coord(airfoil, 3, 6, 5, 4)
+ airfoil.stringer.add_area(0.1)
+ airfoil.stringer.add_mass(5)
+ airfoil.stringer.add_webs(0.1)
+
+ return airfoil
+
+
class Population(creator.Airfoil):
"""Collection of random airfoils."""
diff --git a/gui.py b/gui.py
index 3213d0c..b987e05 100644
--- a/gui.py
+++ b/gui.py
@@ -14,6 +14,8 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import creator
+import evaluator
+import generator
import tkinter as tk
import tkinter.ttk as ttk
@@ -21,32 +23,6 @@ from matplotlib.backends.backend_tkagg import (
FigureCanvasTkAgg, NavigationToolbar2Tk)
-def make_airfoil():
- """Create airfoil instance."""
-
- airfoil = creator.Airfoil.from_dimensions(100, 200)
- airfoil.add_naca(2412)
- airfoil.add_mass(10)
-
- airfoil.spar = creator.Spar()
- airfoil.spar.add_coord(airfoil, 0.23)
- airfoil.spar.add_coord(airfoil, 0.57)
- airfoil.spar.add_spar_caps(0.3)
- airfoil.spar.add_mass(10)
- airfoil.spar.add_webs(0.4)
-
- airfoil.stringer = creator.Stringer()
- airfoil.stringer.add_coord(airfoil,
- 3,
- 6,
- 5,
- 4)
- airfoil.stringer.add_area(0.1)
- airfoil.stringer.add_mass(5)
- airfoil.stringer.add_webs(0.1)
- return airfoil
-
-
def main():
root = tk.Tk()
root.wm_title('MAE 154B - Airfoil Design, Evaluation, Optimization')
@@ -57,18 +33,18 @@ def main():
e_naca = ttk.Entry(root)
l_chord = ttk.Label(root, text='Chord Length')
e_chord = ttk.Entry(root)
- af = make_airfoil()
+ af = generator.default_airfoil()
# # Graph window
fig, ax = creator.plot_geom(af, False)
- canvas = FigureCanvasTkAgg(fig, master=root) # A tk.DrawingArea.
- canvas.draw()
- canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
+ plot = FigureCanvasTkAgg(fig, master=root)
+ plot.draw()
+ plot.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
- toolbar = NavigationToolbar2Tk(canvas, root)
+ toolbar = NavigationToolbar2Tk(plot, root)
toolbar.update()
- canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
+ plot.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
# # Layout
l_naca.pack()
Copyright 2019--2024 Marius PETER