summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--creator.py6
-rw-r--r--gui.py46
-rw-r--r--main.py8
3 files changed, 41 insertions, 19 deletions
diff --git a/creator.py b/creator.py
index eaf4d68..756a8f5 100644
--- a/creator.py
+++ b/creator.py
@@ -32,6 +32,7 @@ import numpy as np
from math import sin, cos, atan, sqrt
import bisect as bi
import matplotlib.pyplot as plt
+from matplotlib.figure import Figure
class Airfoil:
@@ -235,7 +236,7 @@ class Spar(Airfoil):
x = [airfoil.x[spar_x]]
z = [airfoil.z[spar_x]]
# Spar lower coordinates
- spar_x = bi.bisect_left(airfoil.x[::-1], loc) - 1
+ spar_x = bi.bisect_left(airfoil.x[::-1], loc)
x += [airfoil.x[-spar_x]]
z += [airfoil.z[-spar_x]]
self.x.append(x)
@@ -361,6 +362,7 @@ class Stringer(Airfoil):
def plot_geom(airfoil):
"""This function plots the airfoil's + sub-components' geometry."""
+ fig = Figure()
# Plot chord
x_chord = [0, airfoil.chord]
y_chord = [0, 0]
@@ -379,7 +381,7 @@ def plot_geom(airfoil):
for _ in range(len(airfoil.spar.x)):
x = (airfoil.spar.x[_])
y = (airfoil.spar.z[_])
- plt.plot(x, y, '-', color='b')
+ plt.plot(x, y, '-', color='y', linewidth='4')
except AttributeError:
print('No spars to plot.')
# Plot stringers
diff --git a/gui.py b/gui.py
index 42d2e07..0a41d8a 100644
--- a/gui.py
+++ b/gui.py
@@ -17,21 +17,41 @@ import creator
import tkinter as tk
import tkinter.ttk as ttk
+from matplotlib.backends.backend_tkagg import (
+ FigureCanvasTkAgg, NavigationToolbar2Tk)
+from matplotlib.figure import Figure
-def main():
- root = tk.Tk()
- root.title('MAE 154B - Airfoil Design, Evaluation, Optimization')
- root.geometry('1000x400')
+import numpy as np
- frame = ttk.Frame(root).grid(row=0, column=0)
- ttk.Label(frame, text='NACA Number').grid(row=0, sticky='W')
- ttk.Entry(frame).grid(row=0, column=1)
- ttk.Label(frame, text='Chord Length').grid(row=1, sticky='W')
- ttk.Entry(frame).grid(row=1, column=1)
- root.mainloop()
- return None
+root = tk.Tk()
+root.wm_title('MAE 154B - Airfoil Design, Evaluation, Optimization')
+# root.geometry('1000x400')
+# # User inputs
+# l_naca = ttk.Label(root, text='NACA Number')
+# e_naca = ttk.Entry(root)
+# l_chord = ttk.Label(root, text='Chord Length')
+# e_chord = ttk.Entry(root)
+# # Graph window
-if __name__ == '__main__':
- main()
+fig = Figure()
+t = np.arange(0, 3, .01)
+fig.add_subplot(111).plot(t, 2 * np.sin(2 * np.pi * t))
+
+canvas = FigureCanvasTkAgg(fig, master=root) # A tk.DrawingArea.
+canvas.draw()
+canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
+
+toolbar = NavigationToolbar2Tk(canvas, root)
+toolbar.update()
+canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
+
+
+# # Layout
+# l_naca.grid(row=0, sticky='W')
+# e_naca.grid(row=0, column=1)
+# l_chord.grid(row=1, sticky='W')
+# e_chord.grid(row=1, column=1)
+
+root.mainloop()
diff --git a/main.py b/main.py
index 1392218..592202a 100644
--- a/main.py
+++ b/main.py
@@ -72,8 +72,8 @@ def main():
# Create spar instance
af.spar = creator.Spar()
# Define the spar coordinates and mass, stored in single spar object
- af.spar.add_coord(af, 0.20)
- af.spar.add_coord(af, 0.65)
+ af.spar.add_coord(af, 0.23)
+ af.spar.add_coord(af, 0.57)
# Automatically adds spar caps for every previously defined
af.spar.add_spar_caps(SPAR_CAP_AREA)
af.spar.add_mass(SPAR_MASS)
@@ -104,8 +104,8 @@ def main():
eval.analysis(1, 1)
eval.info_print(2)
eval.info_save(SAVE_PATH, _)
- evaluator.plot_geom(eval)
- evaluator.plot_lift(eval)
+ # evaluator.plot_geom(eval)
+ # evaluator.plot_lift(eval)
pop = generator.Population(10)
Copyright 2019--2024 Marius PETER