From 32b6a6e80d22a6d6e8449821d3117252de3e89ba Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Mon, 15 Jul 2019 13:29:36 -0700 Subject: commence class-ification of gui --- gui.py | 89 +++--- wing_scripts/eye_beam_example.m | 70 +++++ wing_scripts/get_dp.m | 4 + wing_scripts/get_ds.m | 20 ++ wing_scripts/get_int.m | 35 +++ wing_scripts/get_z.m | 34 +++ wing_scripts/my_progress.m | 459 ++++++++++++++++++++++++++++ wing_scripts/stringersBeamExample.m | 47 +++ wing_scripts/wingAnalysis_190422.m | 579 ++++++++++++++++++++++++++++++++++++ 9 files changed, 1298 insertions(+), 39 deletions(-) create mode 100644 wing_scripts/eye_beam_example.m create mode 100644 wing_scripts/get_dp.m create mode 100644 wing_scripts/get_ds.m create mode 100644 wing_scripts/get_int.m create mode 100644 wing_scripts/get_z.m create mode 100644 wing_scripts/my_progress.m create mode 100644 wing_scripts/stringersBeamExample.m create mode 100644 wing_scripts/wingAnalysis_190422.m diff --git a/gui.py b/gui.py index cd036b1..a1b8d8e 100644 --- a/gui.py +++ b/gui.py @@ -13,9 +13,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import creator -import evaluator -import generator +from tools import creator, evaluator, generator +# import creator +# import evaluator +# import generator import tkinter as tk import tkinter.ttk as ttk @@ -23,6 +24,51 @@ from matplotlib.backends.backend_tkagg import ( FigureCanvasTkAgg, NavigationToolbar2Tk) +class MainWindow(tk.Frame): + """Main editor window.""" + + def __init__(self, *args, **kwargs): + tk.Frame.__init__(self, *args, **kwargs) + root = tk.Tk() + root.wm_title('MAE 154B - Airfoil Design, Evaluation, Optimization') + + # self.button = tk.Button(self, text="Create new window", + # command=self.create_window) + # self.button.pack(side="top") + frame_1 = ttk.Frame(root) + l_naca, e_naca = new_field(frame_1, 'naca') + l_chord, e_chord = new_field(frame_1, 'chord') + l_semi_span, e_semi_span = new_field(frame_1, 'semi_span') + af = generator.default_airfoil() + # Graph window + frame_2 = ttk.Frame(root) + fig, ax = creator.plot_geom(af, False) + plot = FigureCanvasTkAgg(fig, frame_2) + # plot.draw() + toolbar = NavigationToolbar2Tk(plot, frame_2) + # toolbar.update() + + l_naca.grid(row=0, column=0) + e_naca.grid(row=0, column=1, padx=4) + # b_naca.grid(row=0, column=2) + l_chord.grid(row=1, column=0) + e_chord.grid(row=1, column=1, padx=4) + l_semi_span.grid(row=2, column=0, padx=4) + e_semi_span.grid(row=2, column=1, padx=4) + frame_1.pack(side=tk.LEFT) + # Graph window + plot.get_tk_widget().pack(expand=1, fill=tk.BOTH) + toolbar.pack() + frame_2.pack(side=tk.LEFT) + + def create_window(self): + self.counter += 1 + window = tk.Toplevel(self) + window.wm_title("Window #%s" % self.counter) + label = tk.Label(window, text="This is window #%s" % self.counter) + label.pack(side="top", fill="both", expand=True, padx=100, pady=100) + + def new_field(parent, name): """Add a new user input field.""" @@ -46,40 +92,5 @@ def set_semi_span(name): print(semi_span) -root = tk.Tk() -root.wm_title('MAE 154B - Airfoil Design, Evaluation, Optimization') -# root.geometry('1000x400') - -# Object definition -# User inputs -frame_1 = ttk.Frame(root) -l_naca, e_naca = new_field(frame_1, 'naca') -l_chord, e_chord = new_field(frame_1, 'chord') -l_semi_span, e_semi_span = new_field(frame_1, 'semi_span') -af = generator.default_airfoil() -# Graph window -frame_2 = ttk.Frame(root) -fig, ax = creator.plot_geom(af, False) -plot = FigureCanvasTkAgg(fig, frame_2) -# plot.draw() -toolbar = NavigationToolbar2Tk(plot, frame_2) -# toolbar.update() - -# Layout -# User input -l_naca.grid(row=0, column=0) -e_naca.grid(row=0, column=1, padx=4) -# b_naca.grid(row=0, column=2) -l_chord.grid(row=1, column=0) -e_chord.grid(row=1, column=1, padx=4) -l_semi_span.grid(row=2, column=0, padx=4) -e_semi_span.grid(row=2, column=1, padx=4) -frame_1.pack(side=tk.LEFT) -# Graph window -plot.get_tk_widget().pack(expand=1, fill=tk.BOTH) -toolbar.pack() -frame_2.pack(side=tk.LEFT) - # plot.get_tk_widget().pack() - -root.mainloop() +MainWindow().mainloop() diff --git a/wing_scripts/eye_beam_example.m b/wing_scripts/eye_beam_example.m new file mode 100644 index 0000000..70b4d92 --- /dev/null +++ b/wing_scripts/eye_beam_example.m @@ -0,0 +1,70 @@ +% Bending/Shear stress example +close all; + +length = 20; % in +force = 10000; %lbs + +%eye-beam dimensions + +max_width = 4; % in +min_width = 1; % in +y_max = 4; % in +center_y = 2; % in + + +%max bending moment at the root... + +M = force*length; + +I = min_width*(2*center_y)^3/12 + 2*( max_width*(y_max-center_y)^3/12 + ... + max_width*(y_max-center_y)*((y_max+center_y)/2)^2); + +sigma_max = M * y_max / I; + + +% solve for shear stress distribution +% V / (I * t) * int(y*da) + +% Point 1: evaluated at location just before thickness changes from 4 to 1 in +tempCoeff = force / (I * max_width); +int_y_da = ((y_max+center_y)/2) * max_width*(y_max-center_y); +shear_1 = tempCoeff*int_y_da; + +% Point 2: evaluated at location just after thickness changes from 4 to 1 in +tempCoeff = force / (I * min_width); +shear_2 = tempCoeff*int_y_da; + + +% Point 3: evaluated at center of beam +tempCoeff = force / (I * min_width); +int_y_da = (center_y/2) * min_width*center_y; +shear_3 = shear_2+tempCoeff*int_y_da; + +%evaluating continous integral for width of 4.. +int_y_da_4 = force / (I * max_width)*4*(y_max^2/2 - (center_y:.1:y_max).^2/2); + +%evaluating continous integral for width of 1.. +int_y_da_1 = shear_2 + force / (I * min_width)*1*(center_y^2/2 - (0:.1:center_y).^2/2); + +figure; grid on; hold on;set(gcf,'color',[1 1 1]); +plot(int_y_da_4,center_y:.1:y_max,'linewidth',2) +plot(int_y_da_1,0:.1:center_y,'linewidth',2) +plot(int_y_da_1,0:-.1:-center_y,'linewidth',2) +plot(int_y_da_4,-center_y:-.1:-y_max,'linewidth',2) +plot([shear_1 shear_2],[center_y center_y],'linewidth',2) +plot([shear_1 shear_2],[-center_y -center_y],'linewidth',2) + +plot(shear_1,center_y,'o') +plot(shear_2,center_y,'o') +plot(shear_3,0,'o') +plot(shear_2,-center_y,'o') +plot(shear_1,-center_y,'o') + +xlabel('shear stress (lb/in^2)','fontsize',16,'fontweight','bold');ylabel('Distance from Center (in)','fontsize',16,'fontweight','bold') +set(gca,'FontSize',16,'fontweight','bold'); + + +figure; grid on; hold on;set(gcf,'color',[1 1 1]); +plot([0 4 4 2.5 2.5 4 4 0 0 1.5 1.5 0 0],[4 4 2 2 -2 -2 -4 -4 -2 -2 2 2 4],'linewidth',2) + + diff --git a/wing_scripts/get_dp.m b/wing_scripts/get_dp.m new file mode 100644 index 0000000..2a3281d --- /dev/null +++ b/wing_scripts/get_dp.m @@ -0,0 +1,4 @@ +function z = get_dp(xDist,zDist,Vx,Vz,Ix,Iz,Ixz,A) + +denom = (Ix*Iz-Ixz^2); +z = -A*xDist*(Ix*Vx-Ixz*Vz)/denom - A*zDist*(Iz*Vz-Ixz*Vx)/denom; diff --git a/wing_scripts/get_ds.m b/wing_scripts/get_ds.m new file mode 100644 index 0000000..2f0eb9d --- /dev/null +++ b/wing_scripts/get_ds.m @@ -0,0 +1,20 @@ +function ds = get_ds(xi,xf,u) + +dist = 0; +numSteps = 10; +dx = (xf-xi)/numSteps; +z0 = get_z(xi,u); +x0 = xi; +for i=1:10 + tempX = x0+dx; + if tempX > 0 + tempZ = get_z(tempX,u); + else + tempZ = 0; + end + dist = dist + (dx^2+(tempZ-z0)^2)^.5; + z0 = tempZ; + x0 = tempX; +end + +ds =dist; \ No newline at end of file diff --git a/wing_scripts/get_int.m b/wing_scripts/get_int.m new file mode 100644 index 0000000..edbfda3 --- /dev/null +++ b/wing_scripts/get_int.m @@ -0,0 +1,35 @@ +function z = get_int(xi,xf,u) + +M = 0.02; +P = 0.4; +T = 0.12; +a0 = 0.2969; +a1 = -0.126; +a2 = -0.3516; +a3 = 0.2843; +a4 = -0.1015; + + +%evaluate the integral of camber line, depending on xi and xf related to P + +if xf