No BSD License  

Highlights from
Wing Designer

image thumbnail
from Wing Designer by John Rogers
Wing Designer computes aircraft performance measures from wing and engine parameters.

InitializeGUI(airfoildata)
function [] = InitializeGUI(airfoildata)
%Initializes the GUI and establishes callback functions

% launch the figure
f.left = 100; f.bottom = 100; f.width = 800; f.height = 600;
fig = figure('Position',[f.left f.bottom f.width f.height],'Name','Wing Designer ver 1.6','NumberTitle','off');

%This block writes the interface for the Root dimensions
hroot.panel = uipanel('Parent',fig,'Position',[0 0.75 0.25 0.25],'Title','Root');
hroot.airfoiltext = uicontrol('Style','text','Parent',hroot.panel,'String','NACA Airfoil','Units','normalized',...
    'Position',[0.05 0.7 0.45 0.2]);
hroot.airfoil = uicontrol('Style','popupmenu','Parent',hroot.panel,'Max',3,'Min',1,...
    'String',airfoildata{1},'Value',1,'Units','normalized','Position',[0.55 0.7 0.4 0.2],...
    'BackgroundColor','white');
hroot.chordtext = uicontrol('Style','text','Parent',hroot.panel,'String','Chord (ft)','Units','normalized',...
    'Position',[0.05 0.5 0.45 0.15]);
hroot.chord = uicontrol('Style','edit','Parent',hroot.panel,'Max',1,'Min',1,...
    'Units','normalized','Position',[0.55 0.5 0.4 0.15],'BackgroundColor','white','String','1','Value',1);
hroot.angletext = uicontrol('Style','text','Parent',hroot.panel,'String','Angle of Incidence (deg)','Units','normalized',...
    'Position',[0.05 0.25 0.45 0.2]);
hroot.angle = uicontrol('Style','edit','Parent',hroot.panel,'Max',1,'Min',1,...
    'Units','normalized','Position',[0.55 0.25 0.4 0.15],'BackgroundColor','white','String','0','Value',0);
hroot.Retext = uicontrol('Style','text','Parent',hroot.panel,'String','Reynolds Number at root (1e6)','Units','normalized',...
    'Position',[0.05 0.05 0.45 0.2]);
hroot.Re = uicontrol('Style','text','Parent',hroot.panel,'String','xxxx','Units','normalized',...
    'Position',[0.55 0.05 0.4 0.15]);

%This block writes the interface for the Tip dimensions
htip.panel = uipanel('Parent',fig,'Position',[0 0.5 0.25 0.25],'Title','Tip');
htip.airfoiltext = uicontrol('Style','text','Parent',htip.panel,'String','NACA Airfoil','Units','normalized',...
    'Position',[0.05 0.7 0.45 0.2]);
htip.airfoil = uicontrol('Style','popupmenu','Parent',htip.panel,'Max',3,'Min',1,...
    'String',airfoildata{1},'Value',1,'Units','normalized','Position',[0.55 0.7 0.4 0.2],...
    'BackgroundColor','white');
htip.chordtext = uicontrol('Style','text','Parent',htip.panel,'String','Chord (ft)','Units','normalized',...
    'Position',[0.05 0.5 0.45 0.15]);
htip.chord = uicontrol('Style','edit','Parent',htip.panel,'Max',1,'Min',1,...
    'Units','normalized','Position',[0.55 0.5 0.4 0.15],'BackgroundColor','white','String','1','Value',1);
htip.angletext = uicontrol('Style','text','Parent',htip.panel,'String','Angle of Incidence (deg)','Units','normalized',...
    'Position',[0.05 0.25 0.45 0.2]);
htip.angle = uicontrol('Style','edit','Parent',htip.panel,'Max',1,'Min',1,...
    'Units','normalized','Position',[0.55 0.25 0.4 0.15],'BackgroundColor','white','String','0','Value',0);
htip.Retext = uicontrol('Style','text','Parent',htip.panel,'String','Reynolds Number at tip (1e6)','Units','normalized',...
    'Position',[0.05 0.05 0.45 0.2]);
htip.Re = uicontrol('Style','text','Parent',htip.panel,'String','xxxx','Units','normalized',...
    'Position',[0.55 0.05 0.4 0.15]);

%This block writes the interface for the remainder of the Wing dimensions
hwing.panel = uipanel('Parent',fig,'Position',[0 0 0.25 0.5],'Title','Wing');
hwing.spantext = uicontrol('Style','text','Parent',hwing.panel,'String','Span (ft)','Units','normalized',...
    'Position',[0.05 0.85 0.45 0.1]);
hwing.span = uicontrol('Style','edit','Parent',hwing.panel,'Max',1,'Min',1,...
    'Units','normalized','Position',[0.55 0.85 0.4 0.1],'BackgroundColor','white','String','10','Value',10);
hwing.dihedraltext = uicontrol('Style','text','Parent',hwing.panel,'String','Dihedral (deg)','Units','normalized',...
    'Position',[0.05 0.70 0.45 0.1]);
hwing.dihedral = uicontrol('Style','edit','Parent',hwing.panel,'Max',1,'Min',1,...
    'Units','normalized','Position',[0.55 0.70 0.4 0.1],'BackgroundColor','white','String','0','Value',0);
hwing.sweeptext = uicontrol('Style','text','Parent',hwing.panel,'String','Sweep (deg)','Units','normalized',...
    'Position',[0.05 0.55 0.45 0.1]);
hwing.sweep = uicontrol('Style','edit','Parent',hwing.panel,'Max',1,'Min',1,...
    'Units','normalized','Position',[0.55 0.55 0.4 0.1],'BackgroundColor','white','String','0','Value',0);
hwing.tapertext = uicontrol('Style','text','Parent',hwing.panel,'String','Taper Ratio','Units','normalized',...
    'Position',[0.05 0.42 0.45 0.1]);
hwing.taper = uicontrol('Style','text','Parent',hwing.panel,'String',num2str(get(htip.chord,'Value')/get(hroot.chord,'Value')),'Units','normalized',...
    'Position',[0.55 0.42 0.4 0.1]);
hwing.twisttext = uicontrol('Style','text','Parent',hwing.panel,'String','Geometric Twist (deg)','Units','normalized',...
    'Position',[0.05 0.35 0.45 0.1]);
hwing.twist = uicontrol('Style','text','Parent',hwing.panel,'String',num2str(get(htip.angle,'Value')-get(hroot.angle,'Value')),'Units','normalized',...
    'Position',[0.55 0.35 0.4 0.1]);
hwing.nstext = uicontrol('Style','text','Parent',hwing.panel,'String','Number of Spanwise Panels','Units','normalized',...
    'Position',[0.05 0.20 0.45 0.1]);
hwing.ns = uicontrol('Style','edit','Parent',hwing.panel,'Max',1,'Min',1,...
    'Units','normalized','Position',[0.55 0.20 0.4 0.1],'BackgroundColor','white','String','10','Value',10);
hwing.nctext = uicontrol('Style','text','Parent',hwing.panel,'String','Number of Chordwise Panels','Units','normalized',...
    'Position',[0.05 0.05 0.45 0.1]);
hwing.nc = uicontrol('Style','edit','Parent',hwing.panel,'Max',1,'Min',1,...
    'Units','normalized','Position',[0.55 0.05 0.4 0.1],'BackgroundColor','white','String','6','Value',6);

%This block sets up the axes to display the wing geometry
cmenu = uicontextmenu;
hplot.fig = axes('OuterPosition',[0.25 0.5 0.5 0.5],'UIContextMenu',cmenu);
hplot.root = axes('OuterPosition',[0.25 0.35 0.25 0.15]);
hplot.tip = axes('OuterPosition',[0.5 0.35 0.25 0.15]);

hplot.item1 = uimenu(cmenu, 'Label', 'View from behind', 'Callback',{@ChangeView,hplot,-90,0,'behind'});
hplot.item2 = uimenu(cmenu, 'Label', 'View from above', 'Callback',{@ChangeView,hplot,0,90,'above'});
hplot.item3 = uimenu(cmenu, 'Label', 'View from side', 'Callback',{@ChangeView,hplot,0,0,'side'});
hplot.item4 = uimenu(cmenu, 'Label', 'View from above left', 'Callback',{@ChangeView,hplot,-37.5,30,'above left'});
hplot.item5 = uimenu(cmenu, 'Label', 'View from above and behind', 'Callback',{@ChangeView,hplot,70,20,'above and behind'});

%This block sets up the Cruise conditions
hcruise.panel = uipanel('Parent',fig,'Position',[0.75 0.60 0.25 0.4],'Title','Cruise');
hcruise.velocitytext = uicontrol('Style','text','Parent',hcruise.panel,'String','Velocity (knots)','Units','normalized',...
    'Position',[0.05 0.8 0.55 0.15]);
hcruise.velocity = uicontrol('Style','edit','Parent',hcruise.panel,'Max',1,'Min',1,...
    'Units','normalized','Position',[0.65 0.89 0.3 0.06],'BackgroundColor','white','String','292','Value',292);
hcruise.AOAtext = uicontrol('Style','text','Parent',hcruise.panel,'String','Angle of Attack (deg)','Units','normalized',...
    'Position',[0.05 0.77 0.55 0.11]);
hwing.AOA = uicontrol('Style','edit','Parent',hcruise.panel,'Max',1,'Min',1,...
    'Units','normalized','Position',[0.65 0.77 0.3 0.1],'BackgroundColor','white','String','0','Value',0);
hcruise.altitudetext = uicontrol('Style','text','Parent',hcruise.panel,'String','Standard Altitude (ft)','Units','normalized',...
    'Position',[0.05 0.65 0.55 0.11]);
hcruise.altitude = uicontrol('Style','edit','Parent',hcruise.panel,'String','28000','Units','normalized',...
    'Position',[0.65 0.65 0.3 0.1]);
[hcruise.dens, hcruise.a, hcruise.visc] = StandardAtmosphere(get(hcruise.altitude,'String'));
hcruise.densitytext = uicontrol('Style','text','Parent',hcruise.panel,'String','Density (kg/m^3)','Units','normalized',...
    'Position',[0.05 0.55 0.55 0.1]);
hcruise.density = uicontrol('Style','text','Parent',hcruise.panel,'String',num2str(round(hcruise.dens*1000)/1000),'Units','normalized',...
    'Position',[0.65 0.55 0.3 0.1]);
hcruise.viscositytext = uicontrol('Style','text','Parent',hcruise.panel,'String','Viscosity (kg/m-s)','Units','normalized',...
    'Position',[0.05 0.45 0.55 0.1]);
hcruise.viscosity = uicontrol('Style','text','Parent',hcruise.panel,'String',num2str(round(hcruise.visc*10000000)/10000000),'Units','normalized',...
    'Position',[0.65 0.45 0.3 0.1]);
hcruise.machtext = uicontrol('Style','text','Parent',hcruise.panel,'String','Mach number','Units','normalized',...
    'Position',[0.05 0.35 0.55 0.1]);
hcruise.mach = uicontrol('Style','text','Parent',hcruise.panel,'String',num2str(round(get(hcruise.velocity,'Value')*0.5144/hcruise.a*100)/100),'Units','normalized',...
    'Position',[0.65 0.35 0.3 0.1]);
hcruise.wettedareatext = uicontrol('Style','text','Parent',hcruise.panel,'String','Fuselage Wetted Area   (S/S_ref)','Units','normalized',...
    'Position',[0.05 0.25 0.55 0.12]);
hcruise.wettedarea = uicontrol('Style','edit','Parent',hcruise.panel,'Max',1,'Min',1,...
    'Units','normalized','Position',[0.65 0.25 0.3 0.1],'BackgroundColor','white','String','7.0');%dimensionless, from Fig 2.54, Anderson, Aircraft Performance and Design
hcruise.skinfrictiontext = uicontrol('Style','text','Parent',hcruise.panel,'String','Fuselage Skin Friction Coefficient','Units','normalized',...
    'Position',[0.05 0.1 0.55 0.11]);
hcruise.skinfriction = uicontrol('Style','edit','Parent',hcruise.panel,'Max',1,'Min',1,...
    'Units','normalized','Position',[0.65 0.1 0.3 0.12],'BackgroundColor','white','String','0.0040');%dimensionless, from Fig 2.55, Anderson, Aircraft Performance and Design
hcruise.weighttext = uicontrol('Style','text','Parent',hcruise.panel,'String','Empty Weight (lbf)','Units','normalized',...
    'Position',[0.05 0.01 0.55 0.08]);
hcruise.weight = uicontrol('Style','edit','Parent',hcruise.panel,'Max',1,'Min',1,...
    'Units','normalized','Position',[0.65 0.02 0.3 0.06],'BackgroundColor','white','String','83000');%(kg) Empty weight of C130

%This block sets up the Engine selection
hengine.panel = uibuttongroup('Units','normalized',...
    'Position',[0.75 0.25 0.25 0.35],'Title','Engine','Parent',fig);
hengine.prop= uicontrol('Style','Radio','String','Prop','Units','normalized',...
    'pos',[0.05 0.5 0.30 0.40],'parent',hengine.panel,'HandleVisibility','off');
hcruise.SFCtext = uicontrol('Style','text','Parent',hengine.panel,'String','SFC (lb/hp-hr)','Units','normalized',...
    'Position',[0.3 0.6 0.35 0.25]);
hengine.SFC = uicontrol('Style','edit','Parent',hengine.panel,'Max',1,'Min',1,...
    'Units','normalized','Position',[0.7 0.75 0.25 0.15],'BackgroundColor','white','String','0.49');%(lb/hp-hr) Standard SFC for gas engine
hcruise.propeffictext = uicontrol('Style','text','Parent',hengine.panel,'String','prop efficiency','Units','normalized',...
    'Position',[0.2 0.4 0.45 0.25]);
hengine.propeffic = uicontrol('Style','edit','Parent',hengine.panel,'Max',1,'Min',1,...
    'Units','normalized','Position',[0.7 0.55 0.25 0.15],'BackgroundColor','white','String','0.85');%Propeller efficiency
hengine.jet = uicontrol('Style','Radio','String','Jet','Units','normalized',...
    'pos',[0.05 0.25 0.30 0.40],'parent',hengine.panel,'HandleVisibility','off');
hcruise.TSFCtext = uicontrol('Style','text','Parent',hengine.panel,'String','TSFC (lb/hp-hr)','Units','normalized',...
    'Position',[0.3 0.25 0.35 0.25]);
hengine.TSFC = uicontrol('Style','edit','Parent',hengine.panel,'Max',1,'Min',1,...
    'Units','normalized','Position',[0.7 0.35 0.25 0.15],'BackgroundColor','white','String','0.69');%(lb/lb-hr) Standard TSFC for jet engine
hcruise.wingfueltext = uicontrol('Style','text','Parent',hengine.panel,'String','Wing volume used as fuel tanks (0%-100%)','Units','normalized',...
    'Position',[0.05 0.05 0.5 0.25]);
hengine.wingfuel = uicontrol('Style','edit','Parent',hengine.panel,'Max',1,'Min',1,...
    'Units','normalized','Position',[0.7 0.15 0.25 0.15],'BackgroundColor','white','String','25');% percent (0-100) of wing volume used as fuel tanks


%This block sets up the output from the calculations
houtput.panel = uipanel('Parent',fig,'Position',[0.25 0 0.75 0.25],'Title','Output');
houtput.lifttext = uicontrol('Style','text','Parent',houtput.panel,'String','Lift (lbf)','Units','normalized',...
    'Position',[0.05 0.70 0.15 0.20]);
houtput.lift = uicontrol('Style','text','Parent',houtput.panel,'String','0','Units','normalized',...
    'Position',[0.20 0.70 0.15 0.20]);
houtput.payloadtext = uicontrol('Style','text','Parent',houtput.panel,'String','Payload (lbf)','Units','normalized',...
    'Position',[0.4 0.70 0.15 0.20]);
houtput.payload = uicontrol('Style','text','Parent',houtput.panel,'String','0','Units','normalized',...
    'Position',[0.55 0.70 0.15 0.20]);
houtput.fuelweighttext = uicontrol('Style','text','Parent',houtput.panel,'String','Fuel Weight (lbf)','Units','normalized',...
    'Position',[0.7 0.70 0.15 0.20]);
houtput.fuelweight = uicontrol('Style','text','Parent',houtput.panel,'String','0','Units','normalized',...
    'Position',[0.85 0.70 0.15 0.20]);
houtput.totaldragtext = uicontrol('Style','text','Parent',houtput.panel,'String','Drag (lbf)','Units','normalized',...
    'Position',[0.05 0.45 0.15 0.20]);
houtput.totaldrag = uicontrol('Style','text','Parent',houtput.panel,'String','0','Units','normalized',...
    'Position',[0.20 0.45 0.15 0.20]);
houtput.inddragtext = uicontrol('Style','text','Parent',houtput.panel,'String','Induced Drag (lbf)','Units','normalized',...
    'Position',[0.40 0.45 0.15 0.20]);
houtput.inddrag = uicontrol('Style','text','Parent',houtput.panel,'String','0','Units','normalized',...
    'Position',[0.55 0.45 0.15 0.20]);
houtput.profdragtext = uicontrol('Style','text','Parent',houtput.panel,'String','Profile Drag (lbf)','Units','normalized',...
    'Position',[0.7 0.45 0.15 0.20]);
houtput.profdrag = uicontrol('Style','text','Parent',houtput.panel,'String','0','Units','normalized',...
    'Position',[0.85 0.45 0.149 0.20]);
houtput.rangetext = uicontrol('Style','text','Parent',houtput.panel,'String','Range (miles)','Units','normalized',...
    'Position',[0.05 0.20 0.15 0.20]);
houtput.range = uicontrol('Style','text','Parent',houtput.panel,'String','0','Units','normalized',...
    'Position',[0.20 0.20 0.15 0.20]);
houtput.bendmomenttext = uicontrol('Style','text','Parent',houtput.panel,'String','Bending Moment (N-m)','Units','normalized',...
    'Position',[0.70 0.25 0.15 0.20]);
houtput.bendmoment = uicontrol('Style','text','Parent',houtput.panel,'String','0','Units','normalized',...
    'Position',[0.85 0.25 0.149 0.20]);
houtput.volumetext = uicontrol('Style','text','Parent',houtput.panel,'String','Wing Volume (ft^3)','Units','normalized',...
    'Position',[0.7 0.05 0.15 0.20]);
houtput.volume = uicontrol('Style','text','Parent',houtput.panel,'String','0','Units','normalized',...
    'Position',[0.85 0.05 0.149 0.20]);
houtput.SCOREtext = uicontrol('Style','text','Parent',houtput.panel,'String','Score','FontSize',14,'FontWeight','bold','Units','normalized',...
    'Position',[0.35 0.20 0.15 0.20]);
houtput.SCORE = uicontrol('Style','text','Parent',houtput.panel,'String','XXXX','FontWeight','bold','FontSize',14,'Units','normalized',...
    'Position',[0.5 0.20 0.2 0.20]);
houtput.calctimetext = uicontrol('Style','text','Parent',houtput.panel,'String','Calculation Time (sec)','Units','normalized',...
    'Position',[0.05 0.05 0.15 0.20]);
houtput.calctime = uicontrol('Style','text','Parent',houtput.panel,'String','0.00','Units','normalized',...
    'Position',[0.20 0.05 0.15 0.20]);

%This block sets up the Calculation pushbutton
hcalc.exec = uicontrol('Style','Pushbutton','String','Calculate',...
    'Units','normalized','pos',[0.35 0.25 0.3 0.1],'parent',fig,'HandleVisibility','off',...
    'Callback',{@ExecCalc,hroot,htip,hwing,hcruise,airfoildata,hengine,hplot,houtput});

% allows use of the keyboard
set(fig,'KeyPressFcn',{@guiManCommands,hroot,htip,hwing,hcruise,airfoildata,hengine,hplot,houtput});

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%This block is the callback function that performs the Execute Calculation
%routine
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function ExecCalc(source,event,root, tip, wing, cruise, airfoildata, engine, hplot, output) %#ok<INUSL>

[geo] = GetGeometryfromGUI(root, tip, wing, cruise, engine, hplot, output, airfoildata);
[panel, WingVolume]=DeterminePanelGeometry(geo,hplot);
[gamma, Fu_bar, Fv_bar, Fw_bar]=VortexStrength(panel,geo.dih);
[CL, u_U, v_U, w_U, l_t, l_s] = LiftCoeff(gamma, panel, geo, Fu_bar, Fv_bar, Fw_bar);
[y_cp] = SpanLoading(l_s, l_t, CL, geo, panel);
[CDi] = InducedDrag(gamma, geo, panel);
[CD0] = DetermineProfileDrag(airfoildata,geo,panel);
FinalOutput(CL, CDi, CD0, y_cp, geo, WingVolume, airfoildata, output);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%This block is the callback function that allows use of the enter button to perform
%the Execute Calculation function
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function guiManCommands(source, event, root, tip, wing, cruise, airfoildata, engine, hplot, output)

% case switches on hex codes corresponding to keyboard buttons
switch dec2hex(event.Character)
    case 'D'   % pressing the 'enter' button
        ExecCalc(source,event,root, tip, wing, cruise, airfoildata, engine, hplot, output)
    otherwise
        dec2hex(event.Character)
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%This block is the callback function that establishes the context menu callbacks
%associated with changing the view of the main plot by right-clicking
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function ChangeView(source, event, hplot, azimuth, elevation, pos) %#ok<INUSL>

view(hplot.fig,azimuth,elevation)
title(hplot.fig,['View from ' pos])
axis(hplot.fig,'equal')

Contact us at files@mathworks.com