diff options
author | Marius Peter <blendoit@gmail.com> | 2019-06-30 10:41:31 -0700 |
---|---|---|
committer | Marius Peter <blendoit@gmail.com> | 2019-06-30 10:41:31 -0700 |
commit | d07acde07a51805bf4c5967ca5e3243b4163dc15 (patch) | |
tree | 45eea30b8ebf7b0e9fe7299643d35204a88b9ffa | |
parent | 59a41c177ce3f3e0f488708466ea0eec09da3294 (diff) |
spar placement
-rw-r--r-- | creator.py | 6 | ||||
-rw-r--r-- | gui.py | 46 | ||||
-rw-r--r-- | main.py | 8 |
3 files changed, 41 insertions, 19 deletions
@@ -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 @@ -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() @@ -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) |