initial commit

This commit is contained in:
2010-04-17 12:00:00 -05:00
commit 0da2092d89
460 changed files with 10528 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,7 @@
0 85 0 CB600155a.dat
2.32 82.73 2.27 CB600165a.dat
6.38 73.67 11.33 CB600175a.dat
14.2 52.13 30.6 CB600175a.dat
28.98 20 45 nasasc0718.dat
34.77 15 50 nasasc0714.dat
80 5 89 nasasc0714.dat

Binary file not shown.

View File

@@ -0,0 +1,16 @@
wingspan 160
M_cruise 0.8
M_landing 0.2
cLalpha_cruise 0.0567
cL0 0.1422
cMalpha_cruise -0.06
cM0 -0.1919
efficiency 0.8872
alt_cruise 35000
weight_cruise 160000
cd_correction 0
c_f 0.003

View File

@@ -0,0 +1,14 @@
QFLR5 v0.04 Beta
Wing name : sFD R013
Wing polar name : T1- 105.0 ft/ s-VLM2- 0. 00ft-Invisc id
Freestream speed : 104 .990 ft/s
alpha CL ICd PCd TCd CY Cm Rm Ym IYm QInf XCP
_________ ________ ________ _________ _________ _________ _________ _________ _________ _________ _________ _________
0 0.197841 0.002619 0 0.002619 0 -0.267136 0 0 0 32.001 0.1217
1 0.254737 0.00402 0 0.00402 0 -0.327464 0 0 0 32.001 0.1159
2 0.311422 0.005817 0 0.005817 0 -0.387557 0 0 0 32.001 0.1123
3 0.367837 0.008003 0 0.008003 0 -0.447341 0 0 0 32.001 0.1098
4 0.423924 0.010575 0 0.010575 0 -0.506744 0 0 0 32.001 0.108
5 0.479626 0.013523 0 0.013523 0 -0.565693 0 0 0 32.001 0.1067

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

349
Matlab code/Grimace.m Executable file
View File

@@ -0,0 +1,349 @@
%Grimace
%all alfas in DEGREES!
%by ascorrea, with help from Jacob Huffman
%"filler" variable just makes it easier to switch between Ronald and Grimace
function Grimace(filler, pranformfile, pranformConstraint)
%LOCATIONS--------------------------------------------------------------]
rootLOCATION='\\ad.uiuc.edu\ae\correa2\Desktop\AE441\AE441 - Home Edition\Matlab code\';
airfoilLOCATION='\\ad.uiuc.edu\ae\correa2\Desktop\AE441\AE441 - Home Edition\Airfoils';
pranformLOCATION='\\ad.uiuc.edu\ae\correa2\Desktop\AE441\AE441 - Home Edition\Planforms';
pranformConstraintLOCATION='\\ad.uiuc.edu\engr\ews\homes\desktop\AE441\AE441 - Home Edition\Planform Constraints';
paramLOCATION='\\ad.uiuc.edu\engr\ews\homes\desktop\AE441\AE441 - Home Edition\Parameter Files';
%-----------------------------------------------------------------------]
n=50;
h1=13.33;
h2=10.5;
cd(pranformLOCATION)
[spans, chords, offsets, airfoil]=textread(pranformfile, '%f %f %f %s');
cd(pranformConstraintLOCATION)
[spansCONST, chordsCONST, offsetsCONST, heightCONST]=textread(pranformConstraint, '%f %f %f %f');
cd(rootLOCATION)
cd(airfoilLOCATION)
[planformLE planformTE]=plotpranform(spans, chords, offsets, n);
[constraintLE constraintTE]=plotconstraint(spansCONST, chordsCONST, offsetsCONST, n);
plotheight=plotThick(spans, chords, offsets, airfoil, h1, n);
plotheight2=plotThick(spans, chords, offsets, airfoil, h2, n);
planformLE=[flipud(planformLE); -planformLE(:,1) planformLE(:,2)];
planformTE=[flipud(planformTE); -planformTE(:,1) planformTE(:,2)];
constraintLE=[flipud(constraintLE); -constraintLE(:,1) constraintLE(:,2)];
constraintTE=[flipud(constraintTE); -constraintTE(:,1) constraintTE(:,2)];
plotheight=[flipud(plotheight); -plotheight(:,1) plotheight(:,2)];
plotheight2=[flipud(plotheight2); -plotheight2(:,1) plotheight2(:,2)];
clf
hold on
plot(planformLE (:,1), planformLE(:,2),'k','LineWidth',2)
plot(planformTE (:,1), planformTE(:,2),'k','LineWidth',2)
plot(constraintLE (:,1), constraintLE(:,2),'LineWidth',1.5)
plot(constraintTE (:,1), constraintTE(:,2),'LineWidth',1.5)
plot(plotheight(:,1),plotheight(:,2),'r','LineWidth',1)
plot(plotheight2(:,1),plotheight2(:,2),'r--','LineWidth',1)
axis equal
axis off
hold off
cd(pranformLOCATION)
filename=regexprep(pranformfile, '.plan', 'grim.tiff');
print ('-dtiff', filename)
cd(rootLOCATION)
function [plotLE plotTE]=plotpranform(spans, chords, offsets, n)
Chords = findChords(n, chords, spans);
%plot planform
for i = 1:(size(chords)-1)
dist=0;
for j = 1:n
dist = (spans(i+1)-spans(i))./n;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
fitX(1)=spans(i);
fitX(2)=spans(i+1);
fitY(1)=offsets(i);
fitY(2)=offsets(i+1);
a = polyfit(fitX, fitY,1);
yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
end
end
plotLE=zeros(1,2);
plotTE=zeros(1,2);
for i=1:(size(chords)-1)
for j=1:n
plotLE=[plotLE; xplotLE(i,j) -yplotLE(i,j)];
plotTE=[plotTE; xplotLE(i,j) -(yplotLE(i,j)+Chords(i,j))];
end
end
plotTE(1,:)=[];
plotLE(1,:)=[];
end
function [plotLE plotTE]=plotconstraint(spans, chords, offsets, n)
%plot constraint
for i = 1:(size(chords)-1)
for j = 1:n
dist = (spans(i+1)-spans(i))./n;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
yplotLE(i,j) = offsets(i+1);
end
end
plotLE=zeros(1,2);
plotTE=zeros(1,2);
for i=1:(size(chords)-1)
for j=1:n
plotLE=[plotLE; xplotLE(i,j) -yplotLE(i,j)];
plotTE=[plotTE; xplotLE(i,j) (-yplotLE(i,j)-chords(i+1))];
end
end
plotTE(1,:)=[];
plotLE(1,:)=[];
end
function plotThick=plotThick(spans, chords, offsets, airfoil, h, n)
n=n/10;
Chords = findChords(n, chords, spans);
plotThickLE=zeros(1,2);
plotThickTE=zeros(1,2);
for i = 1:(size(chords)-1)
for j = 1:n
Chords(i,j);
dist = (spans(i+1)-spans(i))./n;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
fitX(1)=spans(i);
fitX(2)=spans(i+1);
fitY(1)=offsets(i);
fitY(2)=offsets(i+1);
a = polyfit(fitX, fitY,1);
yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
chordloc=linspace(0, Chords(i,j));
for k=1:length(chordloc)-1
thicknessLE(k)=findthickness(airfoil{i}, Chords(i,j), chordloc(k));
clc
fprintf('%g:%u:%u:%u/%g:%u:%u:%u',h,i,j,k,h,(length(chords)-1),n,(length(chordloc)-1))
if thicknessLE(k)>=h
plotThickLE=[plotThickLE; xplotLE(i,j) -(chordloc(k)+yplotLE(i,j))];
break
end
end
for k=1:length(chordloc)-1
thicknessTE(k)=findthickness(airfoil{i}, Chords(i,j), chordloc(length(chordloc)-k));
if thicknessTE(k)>=h
plotThickTE=[plotThickTE; xplotLE(i,j) -(chordloc(length(chordloc)-k)+yplotLE(i,j))];
break
end
end
end
end
plotLE=zeros(1,2);
plotTE=zeros(1,2);
for i=1:(size(chords)-1)
for j=1:n
plotLE=[plotLE; xplotLE(i,j) -yplotLE(i,j)];
plotTE=[plotTE; xplotLE(i,j) -(yplotLE(i,j)+Chords(i,j))];
end
end
plotTE(1,:)=[];
plotLE(1,:)=[];
plotThickLE(1,:)=[];
plotThickTE(1,:)=[];
plotThick=[plotThickLE; flipud(plotThickTE)];
end
function thickness=findthickness(airfoil, Chord, xLoc)
Airfoil = load(airfoil);
Airfoil = Airfoil*Chord;
% blah....goodnight
AirfoilX=Airfoil(:,1);
[min_diff, k]=min(abs(AirfoilX));
for j=1:k
AirfoilYupper(j)=Airfoil(j,2);
AirfoilXupper(j)=Airfoil(j,1);
end
for j=1:length(Airfoil)-k
AirfoilYlower(j)=Airfoil(length(Airfoil)-(j-1), 2);
AirfoilXlower(j)=Airfoil(length(Airfoil)-(j-1), 1);
end
AirfoilYupper=fliplr(AirfoilYupper);
AirfoilXupper=fliplr(AirfoilXupper);
AirfoilYlower=fliplr(AirfoilYlower);
AirfoilXlower=fliplr(AirfoilXlower);
AirfoilYlower=[0 AirfoilYlower];
AirfoilXlower=[0 AirfoilXlower];
[min_diff, k]=min(abs(AirfoilX));
[min_diff, kU]=min(abs(AirfoilXupper-xLoc));
[min_diff, kL]=min(abs(AirfoilXlower-xLoc));
if xLoc<AirfoilXupper(kU)
xFitU(1)=AirfoilXupper(kU-1);
xFitU(2)=AirfoilXupper(kU);
yFitU(1)=AirfoilYupper(kU-1);
yFitU(2)=AirfoilYupper(kU);
else
xFitU(1)=AirfoilXupper(kU);
xFitU(2)=AirfoilXupper(kU+1);
yFitU(1)=AirfoilYupper(kU);
yFitU(2)=AirfoilYupper(kU+1);
end
if xLoc<AirfoilXlower(kL)
xFitL(1)=AirfoilXlower(kL-1);
xFitL(2)=AirfoilXlower(kL);
yFitL(1)=AirfoilYlower(kL-1);
yFitL(2)=AirfoilYlower(kL);
else
xFitL(1)=AirfoilXlower(kL);
xFitL(2)=AirfoilXlower(kL+1);
yFitL(1)=AirfoilYlower(kL);
yFitL(2)=AirfoilYlower(kL+1);
end
aU = polyfit(xFitU, yFitU,1);
aL = polyfit(xFitL, yFitL,1);
% yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
% thickness = AirfoilYupper(xLoc_indu)-AirfoilYlower(xLoc_indl);
thickness = (aU(1)*xLoc+aU(2))-(aL(1)*xLoc+aL(2));
end
function Chords = findChords( n, Chord, X )
for( i = 1:(length(Chord)-1) )
Xtemp = linspace(X(i),X(i+1),n);
Chords(i,:) = (Chord(i+1)-Chord(i))./(X(i+1)-X(i)).*(Xtemp-X(i))+Chord(i);
end
end
function [wakeplot]=findwake(airfoil, chords, spans, offsets, n, alt, v_mach, laminarflow, width)
n=n/10;
[q v_fps dynvisc]=findconstants(alt, v_mach);
Chords = findChords(n, chords, spans);
thicknessplot=zeros(100,1);
wakeplotX=zeros(100,1);
wakeplotY=zeros(100,1);
width=width/2;
% for i = 1:(size(chords)-1)
for i=1:1:(size(chords)-1)
for j = 1:n
% wakecoord(j,:)=linspace(0, Chords(i,j), n);
dist = (spans(i+1)-spans(i))./n;
y(j)=spans(i)+j*dist;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
fitX(1)=spans(i);
fitX(2)=spans(i+1);
fitY(1)=offsets(i);
fitY(2)=offsets(i+1);
a = polyfit(fitX, fitY,1);
yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
x=linspace(0, Chords(i,j));
for k = 1:length(x)-1
thickness(k,j)=findthickness(airfoil{i}, Chords(i,j), x(k));
end
wakeX(k,j)=x(k)+yplotLE(i,j);
wakeY(k,j)=y(j);
end
for k = 1:100
wakeX(k,j)=x(k)+yplotLE(i,j);
wakeY(k,j)=y(j);
end
thickness=[thicknessplot, wake];
wakeplotX=[wakeplotX, wakeX];
wakeplotY=[wakeplotY, wakeY];
end
end
thicknessplot(:,1)=[ ];
wakeplotX(:,1)=[ ];
wakeplotY(:,1)=[ ];
wakeplot(1,:)=[0];
flipud(thicknessplot);
surf(wakeplotY, wakeplotX, thicknessplot)
end
function [q v_fps dynvisc]=findconstants(alt, v_mach)
if alt < 36152
temp=59-.00356*alt;
press=2116*((temp+459.7)/518.6)^5.256;
elseif alt < 82345
temp=-70;
press=473.1*exp(1.73-.000048*alt);
else
print('Program Not Valid for given altitude')
end
%slpcuft: clugs ber cubic foot
density_slpcuft=press/(1718*(temp+459.7));
v_fps=v_mach*sqrt(1.4*1718*(temp+459.7));
q=finddynpress(alt, v_mach);
S = 110.4;
beta = 1.458e-6;
temp_k=[(temp-32) / (1.8)] + 273 ;
viscosity_pascalseconds = (beta*temp_k^(1.5))/(temp_k+S);
%kgpmcu:kilograms per meter cubed
%msqpse:meters squared per second
%sqftpsec:square feet per second
density_kgpmcu=density_slpcuft*515.4;
dynamic_viscosity_msqpsec=viscosity_pascalseconds/density_kgpmcu;
dynamic_viscosity_sqftpsec=dynamic_viscosity_msqpsec*10.76;
dynvisc=dynamic_viscosity_sqftpsec;
density=density_slpcuft;
end
end

257
Matlab code/Grimacelite.m Executable file
View File

@@ -0,0 +1,257 @@
%Grimace
%all alfas in DEGREES!
%by ascorrea, with help from Jacob Huffman
%"filler" variable just makes it easier to switch between Ronald and Grimace
function Grimacelite(filler, pranformfile, pranformConstraint)
%LOCATIONS--------------------------------------------------------------]
% rootLOCATION='\\ad.uiuc.edu\ae\correa2\Desktop\AE441\AE441 - Home Edition\Matlab code\';
% airfoilLOCATION='\\ad.uiuc.edu\ae\correa2\Desktop\AE441\AE441 - Home Edition\Airfoils';
% pranformLOCATION='\\ad.uiuc.edu\ae\correa2\Desktop\AE441\AE441 - Home Edition\Planforms';
% pranformConstraintLOCATION='\\ad.uiuc.edu\engr\ews\homes\desktop\AE441\AE441 - Home Edition\Planform Constraints';
% paramLOCATION='\\ad.uiuc.edu\engr\ews\homes\desktop\AE441\AE441 - Home Edition\Parameter Files';
rootLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Matlab code';
% airfoilLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Airfoils';
% pranformLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Planforms';
% pranformConstraintLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Planform Constraints';
% paramLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Parameter Files';
airfoilLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Airfoils';
pranformLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/XFLR Outputs/Trade Study planform';
pranformConstraintLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Planform Constraints';
paramLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/XFLR Outputs/Trade Study planform';
%-----------------------------------------------------------------------]
n=50;
cd(pranformLOCATION)
[spans, chords, offsets, airfoil]=textread(pranformfile, '%f %f %f %s');
cd(pranformConstraintLOCATION)
[spansCONST, chordsCONST, offsetsCONST, heightCONST]=textread(pranformConstraint, '%f %f %f %f');
cd(rootLOCATION)
cd(airfoilLOCATION)
[planformLE planformTE]=plotpranform(spans, chords, offsets, n);
[constraintLE constraintTE]=plotconstraint(spansCONST, chordsCONST, offsetsCONST, n);
planformLE=[flipud(planformLE); -planformLE(:,1) planformLE(:,2)];
planformTE=[flipud(planformTE); -planformTE(:,1) planformTE(:,2)];
plotplan=[planformLE; flipud(planformTE);planformLE(1,:)];
clf
hold on
plot(plotplan (:,1), plotplan(:,2), 'k', 'LineWidth', 2)
axis equal
axis off
hold off
cd(pranformLOCATION)
filename=regexprep(pranformfile, '.plan', 'grimlite.tiff');
print ('-dtiff', filename)
cd(rootLOCATION)
function [plotLE plotTE]=plotpranform(spans, chords, offsets, n)
Chords = findChords(n, chords, spans);
%plot planform
for i = 1:(size(chords)-1)
dist=0;
for j = 1:n
Chords(i,j);
dist = (spans(i+1)-spans(i))./n;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
fitX(1)=spans(i);
fitX(2)=spans(i+1);
fitY(1)=offsets(i);
fitY(2)=offsets(i+1);
a = polyfit(fitX, fitY,1);
yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
end
end
plotLE=zeros(1,2);
plotTE=zeros(1,2);
for i=1:(size(chords)-1)
for j=1:n
plotLE=[plotLE; xplotLE(i,j) -yplotLE(i,j)];
plotTE=[plotTE; xplotLE(i,j) -(yplotLE(i,j)+Chords(i,j))];
end
end
plotTE(1,:)=[];
plotLE(1,:)=[];
end
function [plotLE plotTE]=plotconstraint(spans, chords, offsets, n)
%plot constraint
for i = 1:(size(chords)-1)
for j = 1:n
dist = (spans(i+1)-spans(i))./n;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
yplotLE(i,j) = offsets(i+1);
end
end
plotLE=zeros(1,2);
plotTE=zeros(1,2);
for i=1:(size(chords)-1)
for j=1:n
plotLE=[plotLE; xplotLE(i,j) -yplotLE(i,j)];
plotTE=[plotTE; xplotLE(i,j) (-yplotLE(i,j)-chords(i+1))];
end
end
plotTE(1,:)=[];
plotLE(1,:)=[];
end
function plotThick=plotThick(spans, chords, offsets, airfoil, h, n)
n=n/10;
Chords = findChords(n, chords, spans);
plotThickLE=zeros(1,2);
plotThickTE=zeros(1,2);
for i = 1:(size(chords)-1)
for j = 1:n
Chords(i,j);
dist = (spans(i+1)-spans(i))./n;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
fitX(1)=spans(i);
fitX(2)=spans(i+1);
fitY(1)=offsets(i);
fitY(2)=offsets(i+1);
a = polyfit(fitX, fitY,1);
yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
chordloc=linspace(0, Chords(i,j));
for k=1:length(chordloc)-1
thicknessLE(k)=findthickness(airfoil{i}, Chords(i,j), chordloc(k));
clc
fprintf('%g:%u:%u:%u/%g:%u:%u:%u',h,i,j,k,h,(length(chords)-1),n,(length(chordloc)-1))
if thicknessLE(k)>=h
plotThickLE=[plotThickLE; xplotLE(i,j) -(chordloc(k)+yplotLE(i,j))];
break
end
end
for k=1:length(chordloc)-1
thicknessTE(k)=findthickness(airfoil{i}, Chords(i,j), chordloc(length(chordloc)-k));
if thicknessTE(k)>=h
plotThickTE=[plotThickTE; xplotLE(i,j) -(chordloc(length(chordloc)-k)+yplotLE(i,j))];
break
end
end
end
end
plotLE=zeros(1,2);
plotTE=zeros(1,2);
for i=1:(size(chords)-1)
for j=1:n
plotLE=[plotLE; xplotLE(i,j) -yplotLE(i,j)];
plotTE=[plotTE; xplotLE(i,j) -(yplotLE(i,j)+Chords(i,j))];
end
end
plotTE(1,:)=[];
plotLE(1,:)=[];
plotThickLE(1,:)=[];
plotThickTE(1,:)=[];
plotThick=[plotThickLE; flipud(plotThickTE)];
end
function thickness=findthickness(airfoil, Chord, xLoc)
Airfoil = load(airfoil);
Airfoil = Airfoil*Chord;
% blah....goodnight
AirfoilX=Airfoil(:,1);
[min_diff, k]=min(abs(AirfoilX));
for j=1:k
AirfoilYupper(j)=Airfoil(j,2);
AirfoilXupper(j)=Airfoil(j,1);
end
for j=1:length(Airfoil)-k
AirfoilYlower(j)=Airfoil(length(Airfoil)-(j-1), 2);
AirfoilXlower(j)=Airfoil(length(Airfoil)-(j-1), 1);
end
AirfoilYupper=fliplr(AirfoilYupper);
AirfoilXupper=fliplr(AirfoilXupper);
AirfoilYlower=fliplr(AirfoilYlower);
AirfoilXlower=fliplr(AirfoilXlower);
AirfoilYlower=[0 AirfoilYlower];
AirfoilXlower=[0 AirfoilXlower];
[min_diff, k]=min(abs(AirfoilX));
[min_diff, kU]=min(abs(AirfoilXupper-xLoc));
[min_diff, kL]=min(abs(AirfoilXlower-xLoc));
if xLoc<AirfoilXupper(kU)
xFitU(1)=AirfoilXupper(kU-1);
xFitU(2)=AirfoilXupper(kU);
yFitU(1)=AirfoilYupper(kU-1);
yFitU(2)=AirfoilYupper(kU);
else
xFitU(1)=AirfoilXupper(kU);
xFitU(2)=AirfoilXupper(kU+1);
yFitU(1)=AirfoilYupper(kU);
yFitU(2)=AirfoilYupper(kU+1);
end
if xLoc<AirfoilXlower(kL)
xFitL(1)=AirfoilXlower(kL-1);
xFitL(2)=AirfoilXlower(kL);
yFitL(1)=AirfoilYlower(kL-1);
yFitL(2)=AirfoilYlower(kL);
else
xFitL(1)=AirfoilXlower(kL);
xFitL(2)=AirfoilXlower(kL+1);
yFitL(1)=AirfoilYlower(kL);
yFitL(2)=AirfoilYlower(kL+1);
end
aU = polyfit(xFitU, yFitU,1);
aL = polyfit(xFitL, yFitL,1);
% yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
% thickness = AirfoilYupper(xLoc_indu)-AirfoilYlower(xLoc_indl);
thickness = (aU(1)*xLoc+aU(2))-(aL(1)*xLoc+aL(2));
end
function Chords = findChords( n, Chord, X )
for( i = 1:(length(Chord)-1) )
Xtemp = linspace(X(i),X(i+1),n);
Chords(i,:) = (Chord(i+1)-Chord(i))./(X(i+1)-X(i)).*(Xtemp-X(i))+Chord(i);
end
end
end

BIN
Matlab code/Legacy/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,60 @@
Centerbody 3
0.927434 0.030867
0.885738 0.037894
0.832426 0.044544
0.770708 0.050733
0.703824 0.054767
0.634967 0.057296
0.567289 0.058793
0.503215 0.059528
0.443412 0.059717
0.388348 0.059516
0.338469 0.059099
0.294235 0.058631
0.256072 0.058263
0.223760 0.058026
0.196178 0.057792
0.172167 0.057433
0.150558 0.056791
0.130182 0.055719
0.109959 0.054041
0.089801 0.051717
0.070408 0.048804
0.052499 0.045333
0.036815 0.041386
0.024065 0.037043
0.014845 0.032427
0.008795 0.027556
0.005152 0.022433
0.003127 0.017031
0.001941 0.011266
0.000833 0.004850
0.000868 -0.006228
0.002777 -0.014501
0.006960 -0.024027
0.014590 -0.033727
0.026905 -0.043466
0.045147 -0.053006
0.070516 -0.061993
0.104060 -0.070058
0.145165 -0.076927
0.192399 -0.082424
0.244294 -0.086545
0.299425 -0.089280
0.356322 -0.090523
0.413532 -0.090135
0.469635 -0.087990
0.523580 -0.084127
0.574750 -0.078781
0.622524 -0.072162
0.666283 -0.064484
0.705419 -0.055972
0.739322 -0.046855
0.767373 -0.037351
0.789853 -0.027657
0.808793 -0.017830
0.826372 -0.007917
0.844831 0.002026
0.866348 0.011975
0.893151 0.021929
0.927426 0.031964

View File

@@ -0,0 +1 @@
0 0.610000000000000 0 n0011sc.dat

Binary file not shown.

View File

@@ -0,0 +1,7 @@
0 85 0 n0012.dat
2.32 82.73 2.27 n0012.dat
6.38 73.67 11.33 n0012.dat
14.2 52.13 30.6 n0012.dat
28.98 20 55 nasasc2-0714.dat
34.77 15 60 nasasc2-0714.dat
70 7.5 803 nasasc2-0714.dat

View File

@@ -0,0 +1,7 @@
0, 0.607142857, 0, 'CB50015.dat'
0.016571429, 0.590928571, 0.02, 'CB50015.dat'
0.045571429, 0.526214286, 0.08, 'CB50015.dat'
0.101428571, 0.371428571, 0.22, 'CB50015.dat'
0.207, 0.142857143, 0.39, 'nasasc-718.dat'
0.248357143, 0.107142857, 0.43, 'nasasc2-714.dat'
0.5, 0.053571429, 0.54, 'nasasc2-714.dat'

View File

@@ -0,0 +1,54 @@
%function Area = WhettedArea( fileName, wingSpan )
function WhettedArea(fileName,wingSpan, n)
% fileName = 'AirData.mat';
% wingSpan = 1;
% n = 50;
Area = 0;
pranformArea = 0;
PlanData1 = load(fileName);
PlanData = PlanData1.(fileName(1:end-4));
Chords = findChords(n, PlanData);
for i = 1:(size(PlanData,1)-1)
for j = 1:n
dist = wingSpan*(PlanData{i+1,1}-PlanData{i,1})./n;
Area = Area+findPerim( PlanData{i,4}, Chords(i,j), wingSpan).*dist;
% fprintf('Chord: %f Perimiter: %f Area: %f\n', Chords(i,j), findPerim( PlanData{i,4}, Chords(i,j), wingSpan), Area)
end
end
for i = 1:(size(PlanData,1)-1)
for j = 1:n
dist = wingSpan*(PlanData{i+1,1}-PlanData{i,1})./n;
pranformArea = pranformArea+Chords(i,j).*dist;
% fprintf('Chord: %f pranformArea: %f \n', Chords(i,j), pranformArea)
end
end
WetArea = Area *2;
pranformArea = pranformArea*2;
fprintf('Planform Area: %f, Wetted Area: %f \n', pranformArea, WetArea)
end
function Chords = findChords( n, PlanData )
Chord = cell2mat(PlanData(:,2));
X = cell2mat(PlanData(:,1));
for( i = 1:(length(Chord)-1) )
Xtemp = linspace(X(i),X(i+1),n);
Chords(i,:) = (Chord(i+1)-Chord(i))./(X(i+1)-X(i)).*(Xtemp-X(i))+Chord(i);
end
end
function peri = findPerim( airFile, chord, span)
peri = 0;
Airfoil = load(airFile);
Airfoil = Airfoil*chord*span;
for i = 1:(size(Airfoil,1)-1)
peri = peri + sqrt((Airfoil(i+1,1)-Airfoil(i,1))^2+(Airfoil(i+1,2)-Airfoil(i,2))^2);
end
end

View File

@@ -0,0 +1,60 @@
%function Area = WhettedArea( fileName, wingSpan )
function WhettedAreaflubbed(fileName,wingSpan, n)
% fileName = 'AirData.mat';
% wingSpan = 1;
% n = 50;
engineArea=600;
Area = 0;
pranformArea = 0;
cd('\\ad.uiuc.edu\ae\correa2\Desktop\AE441\Matlab code\Jacobi\Planforms')
[spans, chords, offsets, airfoil]=textread(fileName, '%f %f %f %s');
Chords = findChords(n, chords, spans);
cd('\\ad.uiuc.edu\ae\correa2\Desktop\AE441\Matlab code\Jacobi\Airfoils')
for i = 1:(size(chords)-1)
for j = 1:n
Chords(i,j);
dist = wingSpan*(spans(i+1)-spans(i))./n;
Area = Area+findPerim( airfoil{i}, Chords(i,j), wingSpan).*dist;
end
end
for i = 1:(size(chords)-1)
for j = 1:n
dist = wingSpan*(spans(i+1)-spans(i))./n;
pranformArea = pranformArea+Chords(i,j).*dist;
% fprintf('Chord: %f pranformArea: %f \n', Chords(i,j), pranformArea)
end
end
Area = Area *2+engineArea;
WetArea = Area;
pranformArea = pranformArea*2;
fprintf('Planform Area: %f, Wetted Area: %f \n', pranformArea, WetArea)
cd('\\ad.uiuc.edu\ae\correa2\Desktop\AE441\Matlab code\Jacobi\')
end
function Chords = findChords( n, Chord, X )
% Chord = PlanData(:,2);
% X = PlanData(:,1);
for( i = 1:(length(Chord)-1) )
Xtemp = linspace(X(i),X(i+1),n);
Chords(i,:) = (Chord(i+1)-Chord(i))./(X(i+1)-X(i)).*(Xtemp-X(i))+Chord(i);
end
end
function peri = findPerim( airFile, chord, span)
peri = 0;
Airfoil = load(airFile);
Airfoil = Airfoil*chord*span;
for i = 1:(size(Airfoil,1)-1)
peri = peri + sqrt((Airfoil(i+1,1)-Airfoil(i,1))^2+(Airfoil(i+1,2)-Airfoil(i,2))^2);
end
end

View File

@@ -0,0 +1,357 @@
%Master 441 Code
%all alfas in DEGREES!
%by ascorrea
function MASTER441(paramfile, pranformfile, pranformConstraint)
diary
% datafile=input('Input data file: \nNote: You must delete the header
% before using \n:','s');
%DIRECTORY
%LOCATIONS--------------------------------------------------------------]
% rootLOCATION='\\ad.uiuc.edu\ae\correa2\Desktop\AE441\Matlab code\';
% airfoilLOCATION='\\ad.uiuc.edu\ae\correa2\Desktop\AE441\Airfoils';
% pranformLOCATION='\\ad.uiuc.edu\ae\correa2\Desktop\AE441\Planforms';
% pranformConstraintLOCATION='\\ad.uiuc.edu\engr\ews\homes\desktop\AE441\Pl
% anform Constraints';
rootLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Matlab code';
airfoilLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Airfoils';
pranformLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Planforms';
pranformConstraintLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Planform Constraints';
paramLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Parameter Files';
%-----------------------------------------------------------------------]
n=50;
cd(paramLOCATION);
[variablenames, variablevalues]=textread(paramfile, '%s %f');
cd(pranformLOCATION)
[spans, chords, offsets, airfoil]=textread(pranformfile, '%f %f %f %s');
cd(pranformConstraintLOCATION)
[spansCONST, chordsCONST, offsetsCONST, heightCONST]=textread(pranformConstraint, '%f %f %f %f');
cd(rootLOCATION)
for k = 1:length(variablenames)
eval([variablenames{k} '= variablevalues(k);']);
end
cd(airfoilLOCATION)
h1=13.33;
h2=10.5;
h3=9.5;
[sref swet]=WhettedArea(spans, chords, offsets, airfoil,n);
[planformLE planformTE]=plotpranform(spans, chords, offsets, airfoil, h1, n);
[constraintLE constraintTE]=plotconstraint(spansCONST, chordsCONST, offsetsCONST, n);
plotheight=plotThick(spans, chords, offsets, airfoil, h1, n);
plotheight2=plotThick(spans, chords, offsets, airfoil, h2, n);
plotheight3=plotThick(spans, chords, offsets, airfoil, h3, n);
cd(rootLOCATION)
wingspan=2*spans(end);
AR=wingspan^2/sref;
%CRUISE------------------------------------------------------------------]
cd0_cruise=findcd0(c_f, M_cruise, sref, swet);
% finddragpolar(cd0_cruise, cLalpha_cruise, cL0, efficiency, AR, cd_correction, 'cruise')
cLreq_cruise=findcLrequired(alt_cruise, sref, M_cruise, weight_cruise);
alphareq_cruise=findalpharequired(cLalpha_cruise, cL0, cLreq_cruise);
cD_cruise=findcD(AR, efficiency, cd0_cruise, cLreq_cruise, cd_correction);
eloverdee_cruise=cLreq_cruise/cD_cruise;
cM_cruise=cMalpha_cruise*alphareq_cruise+cM0;
hold on
plot(planformLE (:,1), planformLE(:,2))
plot(planformTE (:,1), planformTE(:,2))
plot(constraintLE (:,1), constraintLE(:,2))
plot(constraintTE (:,1), constraintTE(:,2))
plot(plotheight(:,1),plotheight(:,2),'r')
plot(plotheight2(:,1),plotheight2(:,2),'r')
plot(plotheight3(:,1),plotheight3(:,2),'r')
hold off
fprintf('\n----------Cruise----------\n')
fprintf('alfa: %f, Cd0: %f, CL: %f, CD: %f, CM: %f, L/D: %f \n', alphareq_cruise, cd0_cruise, cLreq_cruise, cD_cruise, cM_cruise, eloverdee_cruise)
cd(rootLOCATION)
end
function q=findcd0(c_f, M, sref, swet)
if M>.7
c_f=c_f*(1-.09*M^2);
end
q=c_f*(swet/sref);
end
function q=findcLalpha(AR, M, clalpha, sweep, sex, sref, doverb)
%ascorrea
betasquared=1-M^2;
beta=sqrt(betasquared);
eta=clalpha/(2*pi/beta);
numer=2*pi*AR;
denom1=(AR^2*beta^2)/eta^2;
denom2=(tand(sweep)^2/betasquared);
denom=2+sqrt(4+denom1*(1+denom2));
F=1.07*(1+doverb)^2;
cLalpha=(numer/denom)*(sex/sref)*F;
q=cLalpha;
end
function finddragpolar(cd0, cl_alfa, cL0, e, ar, cd_correction, filename)
alphadeg=[-12:2];
% alpha=(pi/180)*(alphadeg);
alpha=alphadeg;
cL_alfa=cl_alfa*(ar/(ar+(2*(ar+4)/(ar+2))));
for i=1:length(alpha)
C_L(i)=cL_alfa*(alpha(i))+cL0;
cd_i(i)=C_L(i)^2/(pi*ar*e);
C_d(i)=cd0+cd_i(i)+cd_correction;
end
graphname='Drag Polar';
hold on
axisX0=linspace(0,max(cd));
axisY0=zeros(1,length(axisX0));
plot(axisX0, axisY0,'k--');
plot(C_d, C_L);
plot(C_d, C_L, '.');
title(graphname);
xlabel('C_d');
ylabel('C_L');
axis([0, .04, -1, 1.5]);
% for i=1:length(alphadeg)
% alphalabel=num2str(alphadeg(i));
% label=[' \alpha =' alphalabel];
% text(C_d(i), C_L(i), label)
% end
print ('-dtiff', filename)
close(1)
end
function q=findcLrequired(alt, s, v_mach, lift)
if alt < 36152
temp=59-.00356*alt;
press=2116*((temp+459.7)/518.6)^5.256;
elseif alt < 82345
temp=-70;
press=473.1*exp(1.73-.000048*alt);
else
print('Program Not Valid for given altitude')
end
density=press/(1718*(temp+459.7));
v_fps=v_mach*sqrt(1.4*1718*(temp+459.7));
q=.5*density*v_fps^2;
q=lift/(q*s);
end
function q=findalpharequired(cLalpha, cL0, cLrequired)
q=(cLrequired-cL0)/cLalpha;
end
function q=findcD(ar, e, cd0, C_L, cd_correction)
% e=4.61*(1-.045*ar^.68)*cosd(sweep_LE)^.15-3.1;
cd_i=C_L^2/(pi*ar*e);
cd_i=C_L^2/(pi*ar*e);
q=cd0+cd_i+cd_correction;
end
function [pranformArea WetArea]=WhettedArea(spans, chords, offsets, airfoil, n)
% fileName = 'AirData.mat';
wingSpan = 1;
% n = 50;
engineArea=600;
Area = 0;
pranformArea = 0;
Chords = findChords(n, chords, spans);
for i = 1:(size(chords)-1)
for j = 1:n
Chords(i,j);
dist = wingSpan*(spans(i+1)-spans(i))./n;
Area = Area+findPerim( airfoil{i}, Chords(i,j), wingSpan).*dist;
end
end
for i = 1:(size(chords)-1)
for j = 1:n
dist = wingSpan*(spans(i+1)-spans(i))./n;
pranformArea = pranformArea+Chords(i,j).*dist;
% fprintf('Chord: %f pranformArea: %f \n', Chords(i,j), pranformArea)
end
end
Area = Area *2+engineArea;
WetArea = Area;
pranformArea = pranformArea*2;
fprintf('Planform Area: %f, Wetted Area: %f \n', pranformArea, WetArea)
end
function Chords = findChords( n, Chord, X )
for( i = 1:(length(Chord)-1) )
Xtemp = linspace(X(i),X(i+1),n);
Chords(i,:) = (Chord(i+1)-Chord(i))./(X(i+1)-X(i)).*(Xtemp-X(i))+Chord(i);
end
end
function peri = findPerim(airFile, chord, span)
peri = 0;
Airfoil = load(airFile);
Airfoil = Airfoil*chord*span;
for i = 1:(size(Airfoil,1)-1)
peri = peri + sqrt((Airfoil(i+1,1)-Airfoil(i,1))^2+(Airfoil(i+1,2)-Airfoil(i,2))^2);
end
end
function [plotLE plotTE]=plotpranform(spans, chords, offsets, airfoil, h, n)
Chords = findChords(n, chords, spans);
%plot planform
for i = 1:(size(chords)-1)
dist=0;
for j = 1:n
Chords(i,j);
dist = (spans(i+1)-spans(i))./n;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
fitX(1)=spans(i);
fitX(2)=spans(i+1);
fitY(1)=offsets(i);
fitY(2)=offsets(i+1);
a = polyfit(fitX, fitY,1);
yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
end
end
for i = 1:(size(chords)-1)
dist=0;
for j = 1:n
Chords(i,j);
dist = (spans(i+1)-spans(i))./n;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
fitX(1)=spans(i);
fitX(2)=spans(i+1);
fitY(1)=offsets(i);
fitY(2)=offsets(i+1);
a = polyfit(fitX, fitY,1);
yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
end
end
plotLE=zeros(1,2);
plotTE=zeros(1,2);
for i=1:(size(chords)-1)
for j=1:n
plotLE=[plotLE; xplotLE(i,j) -yplotLE(i,j)];
plotTE=[plotTE; xplotLE(i,j) -(yplotLE(i,j)+Chords(i,j))];
end
end
plotTE(1,:)=[];
plotLE(1,:)=[];
end
function [plotLE plotTE]=plotconstraint(spans, chords, offsets, n)
%plot constraint
for i = 1:(size(chords)-1)
dist=0;
for j = 1:n
dist = (spans(i+1)-spans(i))./n;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
yplotLE(i,j) = offsets(i+1);
end
end
plotLE=zeros(1,2);
plotTE=zeros(1,2);
for i=1:(size(chords)-1)
for j=1:n
plotLE=[plotLE; xplotLE(i,j) -yplotLE(i,j)];
plotTE=[plotTE; xplotLE(i,j) (-yplotLE(i,j)-chords(i+1))];
end
end
plotTE(1,:)=[];
plotLE(1,:)=[];
end
function plotThick=plotThick(spans, chords, offsets, airfoil, h, n)
Chords = findChords(n, chords, spans);
plotThickLE=zeros(1,2);
plotThickTE=zeros(1,2);
for i=1:size(chords)-1
for j=size(spans)
chordloc=linspace(0, chords(i));
for k=1:length(chordloc)
thickness(k)=findthickness(airfoil{i}, chords(i), chordloc(k));
if thickness(k)>=h
plotThickLE=[plotThickLE; spans(i) -(chordloc(k)+offsets(i))];
break
end
end
for k=1:length(chordloc)-1
thicknessLE(k)=findthickness(airfoil{i}, chords(i), chordloc(length(chordloc)-k));
if thickness(k)>=h
plotThickTE=[plotThickTE; spans(i) -(chordloc(length(chordloc)-k)+offsets(i))];
break
end
end
end
end
plotThickLE(1,:)=[];
plotThickTE(1,:)=[];
plotThick=[plotThickLE; flipud(plotThickTE)];
end
function thickness=findthickness(airfoil, Chord, xLoc)
Airfoil = load(airfoil);
Airfoil = Airfoil*Chord;
% blah....goodnight
AirfoilX=Airfoil(:,1);
[min_diff, k]=min(abs(AirfoilX));
for j=1:k
AirfoilYupper(j)=Airfoil(j,2);
AirfoilXupper(j)=Airfoil(j,1);
end
for j=1:length(Airfoil)-k
AirfoilYlower(j)=Airfoil(length(Airfoil)-(j-1), 2);
AirfoilXlower(j)=Airfoil(length(Airfoil)-(j-1), 1);
end
[min_diff, k]=min(abs(AirfoilX));
[min_diff, xLoc_indu]=min(abs(AirfoilXupper-xLoc));
[min_diff, xLoc_indl]=min(abs(AirfoilXlower-xLoc));
thickness = AirfoilYupper(xLoc_indu)-AirfoilYlower(xLoc_indl);
end

411
Matlab code/Legacy/MASTER441.m Executable file
View File

@@ -0,0 +1,411 @@
%Master 441 Code
%all alfas in DEGREES!
%by ascorrea
function MASTER441(paramfile, pranformfile, pranformConstraint)
diary
% datafile=input('Input data file: \nNote: You must delete the header
% before using \n:','s');
%DIRECTORY
%LOCATIONS--------------------------------------------------------------]
% rootLOCATION='\\ad.uiuc.edu\ae\correa2\Desktop\AE441\Matlab code\';
% airfoilLOCATION='\\ad.uiuc.edu\ae\correa2\Desktop\AE441\Airfoils';
% pranformLOCATION='\\ad.uiuc.edu\ae\correa2\Desktop\AE441\Planforms';
% pranformConstraintLOCATION='\\ad.uiuc.edu\engr\ews\homes\desktop\AE441\Pl
% anform Constraints';
rootLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Matlab code';
airfoilLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Airfoils';
pranformLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Planforms';
pranformConstraintLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Planform Constraints';
paramLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Parameter Files';
%-----------------------------------------------------------------------]
n=50;
cd(paramLOCATION);
[variablenames, variablevalues]=textread(paramfile, '%s %f');
cd(pranformLOCATION)
[spans, chords, offsets, airfoil]=textread(pranformfile, '%f %f %f %s');
cd(pranformConstraintLOCATION)
[spansCONST, chordsCONST, offsetsCONST, heightCONST]=textread(pranformConstraint, '%f %f %f %f');
cd(airfoilLOCATION)
[sref swet]=WhettedArea(spans, chords, offsets, airfoil, n);
cd(rootLOCATION)
h1=13.33;
h2=10.5;
h3=9.5;
for k = 1:length(variablenames)
eval([variablenames{k} '= variablevalues(k);']);
end
wingspan=2*spans(end);
AR=wingspan^2/sref;
%CRUISE------------------------------------------------------------------]
cd0_cruise=findcd0(c_f, M_cruise, sref, swet);
% finddragpolar(cd0_cruise, cLalpha_cruise, cL0, efficiency, AR, cd_correction, 'cruise')
cLreq_cruise=findcLrequired(alt_cruise, sref, M_cruise, weight_cruise);
alphareq_cruise=findalpharequired(cLalpha_cruise, cL0, cLreq_cruise);
cD_cruise=findcD(AR, efficiency, cd0_cruise, cLreq_cruise, cd_correction);
eloverdee_cruise=cLreq_cruise/cD_cruise;
cM_cruise=cMalpha_cruise*alphareq_cruise+cM0;
hold on
cd(airfoilLOCATION)
[planformLE planformTE]=plotpranform(spans, chords, offsets, n);
[constraintLE constraintTE]=plotconstraint(spansCONST, chordsCONST, offsetsCONST, n);
plotheight=plotThick(spans, chords, offsets, airfoil, h1, n);
plotheight2=plotThick(spans, chords, offsets, airfoil, h2, n);
plotheight3=plotThick(spans, chords, offsets, airfoil, h3, n);
planformLE=[flipud(planformLE); -planformLE(:,1) planformLE(:,2)];
planformTE=[flipud(planformTE); -planformTE(:,1) planformTE(:,2)];
constraintLE=[flipud(constraintLE); -constraintLE(:,1) constraintLE(:,2)];
constraintTE=[flipud(constraintTE); -constraintTE(:,1) constraintTE(:,2)];
plotheight=[flipud(plotheight); -plotheight(:,1) plotheight(:,2)];
plotheight2=[flipud(plotheight2); -plotheight2(:,1) plotheight2(:,2)];
plotheight3=[flipud(plotheight3); -plotheight3(:,1) plotheight3(:,2)];
plot(planformLE (:,1), planformLE(:,2))
plot(planformTE (:,1), planformTE(:,2))
plot(constraintLE (:,1), constraintLE(:,2))
plot(constraintTE (:,1), constraintTE(:,2))
plot(plotheight(:,1),plotheight(:,2),'r')
plot(plotheight2(:,1),plotheight2(:,2),'r:')
plot(plotheight3(:,1),plotheight3(:,2),'r-.')
axis equal
hold off
fprintf('\n----------Cruise----------\n')
fprintf('alfa: %f, Cd0: %f, CL: %f, CD: %f, CM: %f, L/D: %f \n', alphareq_cruise, cd0_cruise, cLreq_cruise, cD_cruise, cM_cruise, eloverdee_cruise)
cd(rootLOCATION)
end
function q=findcd0(c_f, M, sref, swet)
if M>.7
c_f=c_f*(1-.09*M^2);
end
q=c_f*(swet/sref);
end
function q=findcLalpha(AR, M, clalpha, sweep, sex, sref, doverb)
%ascorrea
betasquared=1-M^2;
beta=sqrt(betasquared);
eta=clalpha/(2*pi/beta);
numer=2*pi*AR;
denom1=(AR^2*beta^2)/eta^2;
denom2=(tand(sweep)^2/betasquared);
denom=2+sqrt(4+denom1*(1+denom2));
F=1.07*(1+doverb)^2;
cLalpha=(numer/denom)*(sex/sref)*F;
q=cLalpha;
end
function finddragpolar(cd0, cl_alfa, cL0, e, ar, cd_correction, filename)
alphadeg=[-12:2];
% alpha=(pi/180)*(alphadeg);
alpha=alphadeg;
cL_alfa=cl_alfa*(ar/(ar+(2*(ar+4)/(ar+2))));
for i=1:length(alpha)
C_L(i)=cL_alfa*(alpha(i))+cL0;
cd_i(i)=C_L(i)^2/(pi*ar*e);
C_d(i)=cd0+cd_i(i)+cd_correction;
end
graphname='Drag Polar';
hold on
axisX0=linspace(0,max(cd));
axisY0=zeros(1,length(axisX0));
plot(axisX0, axisY0,'k--');
plot(C_d, C_L);
plot(C_d, C_L, '.');
title(graphname);
xlabel('C_d');
ylabel('C_L');
axis([0, .04, -1, 1.5]);
% for i=1:length(alphadeg)
% alphalabel=num2str(alphadeg(i));
% label=[' \alpha =' alphalabel];
% text(C_d(i), C_L(i), label)
% end
print ('-dtiff', filename)
close(1)
end
function q=findcLrequired(alt, s, v_mach, lift)
if alt < 36152
temp=59-.00356*alt;
press=2116*((temp+459.7)/518.6)^5.256;
elseif alt < 82345
temp=-70;
press=473.1*exp(1.73-.000048*alt);
else
print('Program Not Valid for given altitude')
end
density=press/(1718*(temp+459.7));
v_fps=v_mach*sqrt(1.4*1718*(temp+459.7));
q=.5*density*v_fps^2;
q=lift/(q*s);
end
function q=findalpharequired(cLalpha, cL0, cLrequired)
q=(cLrequired-cL0)/cLalpha;
end
function q=findcD(ar, e, cd0, C_L, cd_correction)
% e=4.61*(1-.045*ar^.68)*cosd(sweep_LE)^.15-3.1;
cd_i=C_L^2/(pi*ar*e);
cd_i=C_L^2/(pi*ar*e);
q=cd0+cd_i+cd_correction;
end
function [pranformArea WetArea]=WhettedArea(spans, chords, ~, airfoil, n)
% fileName = 'AirData.mat';
wingSpan = 1;
% n = 50;
engineArea=600;
Area = 0;
pranformArea = 0;
Chords = findChords(n, chords, spans);
for i = 1:(size(chords)-1)
for j = 1:n
Chords(i,j);
dist = wingSpan*(spans(i+1)-spans(i))./n;
Area = Area+findPerim( airfoil{i}, Chords(i,j), wingSpan).*dist;
end
end
for i = 1:(size(chords)-1)
for j = 1:n
dist = wingSpan*(spans(i+1)-spans(i))./n;
pranformArea = pranformArea+Chords(i,j).*dist;
% fprintf('Chord: %f pranformArea: %f \n', Chords(i,j), pranformArea)
end
end
Area = Area *2+engineArea;
WetArea = Area;
pranformArea = pranformArea*2;
fprintf('Planform Area: %f, Wetted Area: %f \n', pranformArea, WetArea)
end
function Chords = findChords( n, Chord, X )
for( i = 1:(length(Chord)-1) )
Xtemp = linspace(X(i),X(i+1),n);
Chords(i,:) = (Chord(i+1)-Chord(i))./(X(i+1)-X(i)).*(Xtemp-X(i))+Chord(i);
end
end
function peri = findPerim(airFile, chord, span)
peri = 0;
Airfoil = load(airFile);
Airfoil = Airfoil*chord*span;
for i = 1:(size(Airfoil,1)-1)
peri = peri + sqrt((Airfoil(i+1,1)-Airfoil(i,1))^2+(Airfoil(i+1,2)-Airfoil(i,2))^2);
end
end
function [plotLE plotTE]=plotpranform(spans, chords, offsets, n)
Chords = findChords(n, chords, spans);
%plot planform
for i = 1:(size(chords)-1)
dist=0;
for j = 1:n
Chords(i,j);
dist = (spans(i+1)-spans(i))./n;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
fitX(1)=spans(i);
fitX(2)=spans(i+1);
fitY(1)=offsets(i);
fitY(2)=offsets(i+1);
a = polyfit(fitX, fitY,1);
yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
end
end
plotLE=zeros(1,2);
plotTE=zeros(1,2);
for i=1:(size(chords)-1)
for j=1:n
plotLE=[plotLE; xplotLE(i,j) -yplotLE(i,j)];
plotTE=[plotTE; xplotLE(i,j) -(yplotLE(i,j)+Chords(i,j))];
end
end
plotTE(1,:)=[];
plotLE(1,:)=[];
end
function [plotLE plotTE]=plotconstraint(spans, chords, offsets, n)
%plot constraint
for i = 1:(size(chords)-1)
for j = 1:n
dist = (spans(i+1)-spans(i))./n;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
yplotLE(i,j) = offsets(i+1);
end
end
plotLE=zeros(1,2);
plotTE=zeros(1,2);
for i=1:(size(chords)-1)
for j=1:n
plotLE=[plotLE; xplotLE(i,j) -yplotLE(i,j)];
plotTE=[plotTE; xplotLE(i,j) (-yplotLE(i,j)-chords(i+1))];
end
end
plotTE(1,:)=[];
plotLE(1,:)=[];
end
function plotThick=plotThick(spans, chords, offsets, airfoil, h, n)
n=n/25;
Chords = findChords(n, chords, spans);
plotThickLE=zeros(1,2);
plotThickTE=zeros(1,2);
for i = 1:(size(chords)-1)
for j = 1:n
Chords(i,j);
dist = (spans(i+1)-spans(i))./n;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
fitX(1)=spans(i);
fitX(2)=spans(i+1);
fitY(1)=offsets(i);
fitY(2)=offsets(i+1);
a = polyfit(fitX, fitY,1);
yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
chordloc=linspace(0, Chords(i,j));
for k=1:length(chordloc)-1
thickness(k)=findthickness(airfoil{i}, Chords(i,j), chordloc(k));
if thickness(k)>=h
plotThickLE=[plotThickLE; xplotLE(i,j) -(chordloc(k)+yplotLE(i,j))];
break
end
end
for k=1:length(chordloc)-1
thicknessLE(k)=findthickness(airfoil{i}, chords(i), chordloc(length(chordloc)-k));
if thickness(k)>=h
plotThickTE=[plotThickTE; xplotLE(i,j) -(chordloc(length(chordloc)-k)+yplotLE(i,j))];
break
end
end
end
end
plotLE=zeros(1,2);
plotTE=zeros(1,2);
for i=1:(size(chords)-1)
for j=1:n
plotLE=[plotLE; xplotLE(i,j) -yplotLE(i,j)];
plotTE=[plotTE; xplotLE(i,j) -(yplotLE(i,j)+Chords(i,j))];
end
end
plotTE(1,:)=[];
plotLE(1,:)=[];
plotThickLE(1,:)=[];
plotThickTE(1,:)=[];
plotThick=[plotThickLE; flipud(plotThickTE)];
end
function thickness=findthickness(airfoil, Chord, xLoc)
Airfoil = load(airfoil);
Airfoil = Airfoil*Chord;
% blah....goodnight
AirfoilX=Airfoil(:,1);
[min_diff, k]=min(abs(AirfoilX));
for j=1:k
AirfoilYupper(j)=Airfoil(j,2);
AirfoilXupper(j)=Airfoil(j,1);
end
for j=1:length(Airfoil)-k
AirfoilYlower(j)=Airfoil(length(Airfoil)-(j-1), 2);
AirfoilXlower(j)=Airfoil(length(Airfoil)-(j-1), 1);
end
AirfoilYupper=fliplr(AirfoilYupper);
AirfoilXupper=fliplr(AirfoilXupper);
AirfoilYlower=fliplr(AirfoilYlower);
AirfoilXlower=fliplr(AirfoilXlower);
AirfoilYlower=[0 AirfoilYlower];
AirfoilXlower=[0 AirfoilXlower];
[min_diff, k]=min(abs(AirfoilX));
[min_diff, kU]=min(abs(AirfoilXupper-xLoc));
[min_diff, kL]=min(abs(AirfoilXlower-xLoc));
if xLoc<AirfoilXupper(kU)
xFitU(1)=AirfoilXupper(kU-1);
xFitU(2)=AirfoilXupper(kU);
yFitU(1)=AirfoilYupper(kU-1);
yFitU(2)=AirfoilYupper(kU);
else
xFitU(1)=AirfoilXupper(kU);
xFitU(2)=AirfoilXupper(kU+1);
yFitU(1)=AirfoilYupper(kU);
yFitU(2)=AirfoilYupper(kU+1);
end
if xLoc<AirfoilXlower(kL)
xFitL(1)=AirfoilXlower(kL-1);
xFitL(2)=AirfoilXlower(kL);
yFitL(1)=AirfoilYlower(kL-1);
yFitL(2)=AirfoilYlower(kL);
else
xFitL(1)=AirfoilXlower(kL);
xFitL(2)=AirfoilXlower(kL+1);
yFitL(1)=AirfoilYlower(kL);
yFitL(2)=AirfoilYlower(kL+1);
end
aU = polyfit(xFitU, yFitU,1);
aL = polyfit(xFitL, yFitL,1);
% yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
% thickness = AirfoilYupper(xLoc_indu)-AirfoilYlower(xLoc_indl);
thickness = (aU(1)*xLoc+aU(2))-(aL(1)*xLoc+aL(2));
end

31
Matlab code/Legacy/clreqcalc.m Executable file
View File

@@ -0,0 +1,31 @@
%ascorrea
%program to calculate required cl. valid up till 82345 ft
%from www.grc.nasa.gov/WWW/K-12/airplane/atmos.html
alt=input('Altitude (ft): ');
s=input('Input Wing Planform Area (sq.ft.): ');
v_mach=input('Input speed (Mach): ');
lift=input('Input required lift: ');
eloverdee=input('Input L/D requirement: ');
if alt < 36152
temp=59-.00356*alt;
press=2116*((temp+459.7)/518.6)^5.256;
elseif alt < 82345
temp=-70;
press=473.1*exp(1.73-.000048*alt);
else
print('Program Not Valid for given altitude')
end
density=press/(1718*(temp+459.7));
v_fps=v_mach*sqrt(1.4*1718*(temp+459.7));
q=.5*density*v_fps^2;
cl_req=lift/(q*s);
fprintf('Cl_req: %f\n', cl_req);
cd_req=cl_req/eloverdee;
fprintf('Cd_req: %f\n', cd_req);

View File

@@ -0,0 +1,27 @@
%ascorrea
% FUCKA YOU EMPILICAR DATAR!!!
fprintf('Fuselage Data');
R_wf=input('\nInput Fuselage-wing Interference Factor (Fig 5.11):');
C_fr=input('Input Flat Plate Friction Coeff. Fuselage(Fig 5.13)');
fnratio=input('Input finesse ratio:');
S_wetf=input('Input Fuselage Wetted Area:');
fprintf('\nWing Data');
R_ls=input('\nInput Lifting Surface Correction Factor:');
C_fw=input('Input Flat Plate Friction Coeff. Wing(Fig 5.13)');
L_prime=input('Input Airfoil Thickness Location Factor:');
thickratio=input('Input Airfoil thickness (t/c):');
S_wetw=input('Input Wing Wetted Area:');
S_w=input('Input wing planform area:');
answer=input('\n\nCompressible? Yes (1) or No (2)');
if answer==1
M=input('Input Speed (Mach):');
c_fw=c_fw*(1-.09*M^2);
end
C_lw=input('Input lift Coeff.');
C_dof=R_wf*C_fr*(1+(60/fnratio^3)+.0025*fnratio)*(S_wetf)/(S_w);
C_dow=
fprintf('Cdo: %f', Cd)

View File

@@ -0,0 +1,83 @@
%ascorrea
function dragpolar
count=1;
for answer=[1 2]
for answer2=[1 2 3]
% answer=input('Input Aviator (1), Sleak (2):');
% answer2=input('Take-off (1), Cruise (2), Landing (3):');
cd0Aviator=.01866;
cd0Sleak=.02056;
alphadeg=[-12:2:12];
alpha=(pi/180)*(alphadeg);
if answer==1
if answer2==1;
for i=1:length(alpha)
CL(i)=5.221144*(alpha(i))+.2581;
Cd(i)=cd0Aviator+CL(i)^2/(.8*pi()*10);
end
graphname='Drag Polar, Aviator, Take-off';
end
elseif answer==2
if answer2==1;
for i=1:length(alpha)
CL(i)=3.522567397*(alpha(i))+.4088;
CLcanard(i)=(4.122266*(alpha(i))+.4891)*(379.28/1496);
Cd(i)=cd0Sleak+CL(i)^2/(.8*pi()*7.9)+CLcanard(i)^2/(.8*pi()*7.831);
end
graphname='Drag Polar, Sleak, Take-Off';
end
if answer2==2;
for i=1:length(alpha)
CL(i)=2.887819338*(alpha(i))+.4007;
% Cd(i)=cd0Sleak+CL(i)^2/(.8*pi()*10);
CLcanard(i)=(3.819627*(alpha(i))+.4886)*(379.28/1496);
Cd(i)=cd0Sleak+CL(i)^2/(.8*pi()*7.9)+CLcanard(i)^2/(.8*pi()*7.831);
end
graphname='Drag Polar, Sleak, Cruise';
end
if answer2==3;
for i=1:length(alpha)
CL(i)=3.499816553*(alpha(i))+.3987;
% Cd(i)=cd0Sleak+CL(i)^2/(.8*pi()*10);
CLcanard(i)=(4.12721*(alpha(i))+.4891)*(379.28/1496);
Cd(i)=cd0Sleak+CL(i)^2/(.8*pi()*7.9)+CLcanard(i)^2/(.8*pi()*7.831);
end
graphname='Drag Polar, Sleak, landing';
end
else
error('Invalid Choice')
end
hold on
figure(count)
hold on
axisX0=linspace(0,max(cd));
axisY0=zeros(1,length(axisX0));
figure(count)
hold on
plot(axisX0, axisY0,'k--');
figure(count)
hold on
plot(Cd, CL);
figure(count)
hold on
plot(Cd, CL, '.');
title(graphname);
xlabel('C_d');
ylabel('C_L');
axis([0, .08, -1, 1.5]);
for i=1:length(alphadeg)
alphalabel=num2str(alphadeg(i));
label=[' \alpha =' alphalabel];
text(Cd(i), CL(i), label)
end
count=count+1;
end
end
end

View File

@@ -0,0 +1,48 @@
%ascorrea
function dragpolar
count=1;
cd0=input('Input cd0: ');
cl_alfa=input('Input cL_alfa(1/rad): ');
cL0=input('Input cL0: ');
sweep_LE=input('Input leading edge sweep (deg): ');
ar=input('Input aspect ratio: ');
cd_correction=input('Input Cd correction due to Transonic: ');
alphadeg=[-12:2];
alpha=(pi/180)*(alphadeg);
cL_alfa=cl_alfa*(ar/(ar+(2*(ar+4)/(ar+2))));
for i=1:length(alpha)
C_L(i)=cL_alfa*(alpha(i))+cL0;
e=4.61*(1-.045*ar^.68)*cosd(sweep_LE)^.15-3.1;
cd_i(i)=C_L(i)^2/(pi*ar*e);
C_d(i)=cd0+cd_i(i)+cd_correction;
end
graphname='Drag Polar';
hold on
figure(count)
hold on
axisX0=linspace(0,max(cd));
axisY0=zeros(1,length(axisX0));
figure(count)
hold on
plot(axisX0, axisY0,'k--');
figure(count)
hold on
plot(C_d, C_L);
figure(count)
hold on
plot(C_d, C_L, '.');
title(graphname);
xlabel('C_d');
ylabel('C_L');
axis([0, .08, -1, 1.5]);
for i=1:length(alphadeg)
alphalabel=num2str(alphadeg(i));
label=[' \alpha =' alphalabel];
text(C_d(i), C_L(i), label)
end
count=count+1;

View File

@@ -0,0 +1,24 @@
%ascorrea
AR=input('AR:');
M=input('Mach:');
clalpha=input('Cl alpha:');
sweep=input('Sweep at Max Thickness:');
sex=input('S exposed:');
sref=input('S reference:');
doverb=input('Finesse Ratio:');
betasquared=1-M^2;
beta=sqrt(betasquared);
eta=clalpha/(2*pi/beta);
numer=2*pi*AR;
denom1=(AR^2*beta^2)/eta^2;
denom2=(tand(sweep)^2/betasquared);
denom=2+sqrt(4+denom1*(1+denom2));
F=1.07*(1+doverb)^2;
cLalpha=(numer/denom)*(sex/sref)*F;
fprintf('CLalpha= %f\n', cLalpha);

View File

@@ -0,0 +1,13 @@
%ascorrea
%calculates induced drag coefficient for LE sweep > 30 deg
c_L=input('Input c_L: ');
ar=input('Input aspect ratio: ');
sweep_LE=input('Input leading edge sweep (deg): ');
e=4.61*(1-.045*ar^.68)*cosd(sweep_LE)^.15-3.1;
cd_i=c_L^2/(pi*ar*e);
fprintf('cd_i: %f \n', cd_i);

View File

@@ -0,0 +1,35 @@
%omkar
nu_ft2ps = 1.764e-4;
rho_slugpft3 = 0.0020451;
c_ft = 10;
xtr_ft = .2*c_ft;
ft_2_in = 12;
Vinf_fps = 198;
q = 0.5 * rho_slugpft3 * (Vinf_fps^2);
Re_xtr = Vinf_fps * xtr_ft / nu_ft2ps;
delta_xtr_ft=( 5.2 * xtr_ft )/(Re_xtr)^0.5;
delta_l_ft = ((delta_xtr_ft*((Vinf_fps)^0.2))/(0.37*((nu_ft2ps)^0.2)))^(1/0.8);
lt_ft = c_ft - xtr_ft + delta_l_ft;
Re_lt = Vinf_fps * lt_ft / nu_ft2ps;
delta_ft = 0.37 * lt_ft /(Re_lt)^0.2
% for k = 1:100
% if (k <= 100*lam)
% Re_x = v_fps * x(k) / dynvisc;
% delta_x=( 5.2 * x(k) )/(Re_x)^0.5;
% wake(j,k)= delta_x;
% else %if turbulent
% x_tr=x(100*lam);
% Re_xtr = v_fps * x_tr / dynvisc;
% delta_xtr=( 5.2 * x_tr )/(Re_xtr)^0.5;
% delta_l = ((delta_xtr*((v_fps)^0.2))/(0.37*((dynvisc)^0.2)))^(1/0.8);
% lt = x(k) - x_tr + delta_l;
% Re_lt = v_fps * lt / dynvisc;
% delta = 0.37 * lt /(Re_lt)^0.2;
% wake(j,k) = delta;
% end
%
% end

14
Matlab code/Legacy/penis.m Executable file
View File

@@ -0,0 +1,14 @@
function penis
while true
for k = logspace(-.1,-3,15)
for j = 1:25
for i = 1:j
fprintf(' ');
end
fprintf('8=====>\n')
pause(k)
clc
end
end
end

520
Matlab code/Ronald.m Executable file
View File

@@ -0,0 +1,520 @@
%Ronald
%all alfas in DEGREES!
%by ascorrea, with help from Jacob Huffman
%"filler" variable just makes it easier to switch between Ronald and Grimace
function Ronald(paramfile, pranformfile, filler)
%DIRECTORY LOCATIONS--------------------------------------------------------------]
rootLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Matlab Code';
airfoilLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Airfoils';
pranformLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Planforms';
pranformConstraintLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Planform Constraints';
paramLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Parameter Files';
outputsLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/superGrimace Outputs';
%-----------------------------------------------------------------------]
n=50;
cd(paramLOCATION);
[variablenames, variablevalues]=textread(paramfile, '%s %f');
cd(pranformLOCATION)
[spans, chords, offsets, airfoil]=textread(pranformfile, '%f %f %f %s');
cd(airfoilLOCATION)
[sref swet]=WhettedArea(spans, chords, offsets, airfoil, n);
for k = 1:length(variablenames)
eval([variablenames{k} '= variablevalues(k);']);
end
Dragredux_BLI=(1-Dragredux_BLI/100);
wingspan=2*spans(end);
AR=wingspan^2/sref;
wakeplot=findwake(airfoil, chords, spans, offsets, n, alt_cruise, M_cruise, laminarflow_cruise, fuse_width);
%TAKEOFF------------------------------------------------------------------]
% cd0_to=findcd0(c_f, M_to, sref, swet);
cd0_to=findcd0(spans, chords, offsets, airfoil, n, laminarflow_to, alt_to, M_to, sref, c_f, D_engine, cd_landinggear, sfront_landinggear, fuse_width);
% finddragpolar(cd0_to, cLalpha_to, cL0, efficiency_to, AR, cd_correction, 'Takeoff')
% cLreq_to=findcLrequired(alt_to, sref, M_to, weight_to);
cLreq_to=.48;
alphareq_to=findalpharequired(cLalpha, cL0, cLreq_to);
cD_to=findcD(AR, efficiency_to, cd0_to, cLreq_to, cd_correction);
eloverdee_to=cLreq_to/cD_to;
cM_to=cMalpha*alphareq_to+cM0;
q_to=finddynpress(alt_to, M_to);
cD_to=cD_to*Dragredux_BLI;
cd0_to=cd0_to*Dragredux_BLI;
D_to=cD_to*q_to*sref;
%CRUISE------------------------------------------------------------------]
cd0_cruise=findcd0(spans, chords, offsets, airfoil, n, laminarflow_cruise, alt_cruise, M_cruise, sref, c_f, D_engine, 0, 0, fuse_width);
% finddragpolar(cd0_cruise, cLalpha, cL0, efficiency_cruise, AR, cd_correction, 'Cruise')
cLreq_cruise=findcLrequired(alt_cruise, sref, M_cruise, weight_cruise);
alphareq_cruise=findalpharequired(cLalpha, cL0, cLreq_cruise);
cD_cruise=findcD(AR, efficiency_cruise, cd0_cruise, cLreq_cruise, cd_correction);
cM_cruise=cMalpha*alphareq_cruise+cM0;
q_cruise=finddynpress(alt_cruise, M_cruise);
cD_cruise=cD_cruise*Dragredux_BLI;
cd0_cruise=cd0_cruise*Dragredux_BLI;
D_cruise=cD_cruise*q_cruise*sref;
eloverdee_cruise=cLreq_cruise/cD_cruise;
%LOITER------------------------------------------------------------------]
cd0_loiter=findcd0(spans, chords, offsets, airfoil, n, laminarflow_loiter, alt_loiter, M_loiter, sref, c_f, D_engine, 0, 0, fuse_width);
% finddragpolar(cd0_loiter, cLalpha_loiter, cL0, efficiency_loiter, AR, cd_correction, 'Loiter')
cLreq_loiter=findcLrequired(alt_loiter, sref, M_loiter, weight_loiter);
alphareq_loiter=findalpharequired(cLalpha, cL0, cLreq_loiter);
cD_loiter=findcD(AR, efficiency_loiter, cd0_loiter, cLreq_loiter, cd_correction);
cM_loiter=cMalpha*alphareq_loiter+cM0;
q_loiter=finddynpress(alt_loiter, M_loiter);
cD_loiter=cD_loiter*Dragredux_BLI;
cd0_loiter=cd0_loiter*Dragredux_BLI;
D_loiter=cD_loiter*q_loiter*sref;
eloverdee_loiter=cLreq_loiter/cD_loiter;
%LANDING------------------------------------------------------------------]
cd0_landing=findcd0(spans, chords, offsets, airfoil, n, laminarflow_landing, alt_landing, M_landing, sref, c_f, D_engine, cd_landinggear, sfront_landinggear, fuse_width);
% finddragpolar(cd0_landing, cLalpha_landing, cL0, efficiency_landing, AR, cd_correction, 'Landing')
% cLreq_landing=findcLrequired(alt_landing, sref, M_landing, weight_landing);
cLreq_landing=.401;
alphareq_landing=findalpharequired(cLalpha, cL0, cLreq_landing);
cD_landing=findcD(AR, efficiency_landing, cd0_landing, cLreq_landing, cd_correction);
cM_landing=cMalpha*alphareq_landing+cM0;
q_landing=finddynpress(alt_landing, M_landing);
cD_landing=cD_landing*Dragredux_BLI;
cd0_landing=cd0_landing*Dragredux_BLI;
D_landing=cD_landing*q_landing*sref;
eloverdee_landing=cLreq_landing/cD_landing;
cd(pranformLOCATION)
filenameplan=regexprep(pranformfile, '.plan', 'ronaldplus.tiff');
filenameoutput=regexprep(pranformfile, '.plan', 'ronaldplus.txt');
plottitle=regexprep(pranformfile, '.plan', '');
fid = fopen(filenameoutput, 'w');
fprintf(plottitle);
fprintf('---------------------------------------------------\n');
fprintf(fid, plottitle);
fprintf(fid,'---------------------------------------------------\n');
fprintf('Wingspan: %f, AR: %f, Planform Area: %f, Wetted Area: %f \n', wingspan, AR, sref, swet);
fprintf(fid, 'Wingspan: %f, AR: %f, Planform Area: %f, Wetted Area: %f \n', wingspan, AR, sref, swet);
fprintf('\n----------Takeoff--------------------------------\n alfa: %f, Cd0: %f, CL: %f, CD: %f, D: %f, CM: %f, L/D: %f \n', alphareq_to, cd0_to, cLreq_to, cD_to, D_to, cM_to, eloverdee_to);
fprintf(fid, '\n----------Takeoff--------------------------------\n alfa: %f, Cd0: %f, CL: %f, CD: %f, D: %f, CM: %f, L/D: %f \n', alphareq_to, cd0_to, cLreq_to, cD_to, D_to, cM_to, eloverdee_to);
fprintf('\n----------Cruise---------------------------------\n alfa: %f, Cd0: %f, CL: %f, CD: %f, D: %f, CM: %f, L/D: %f \n', alphareq_cruise, cd0_cruise, cLreq_cruise, cD_cruise, D_cruise, cM_cruise, eloverdee_cruise);
fprintf(fid, '\n----------Cruise---------------------------------\n alfa: %f, Cd0: %f, CL: %f, CD: %f, D: %f, CM: %f, L/D: %f \n', alphareq_cruise, cd0_cruise, cLreq_cruise, cD_cruise, D_cruise, cM_cruise, eloverdee_cruise);
fprintf('\n----------Loiter---------------------------------\n alfa: %f, Cd0: %f, CL: %f, CD: %f, D: %f, CM: %f, L/D: %f \n', alphareq_loiter, cd0_loiter, cLreq_loiter, cD_loiter, D_loiter, cM_loiter, eloverdee_loiter);
fprintf(fid, '\n----------Loiter---------------------------------\n alfa: %f, Cd0: %f, CL: %f, CD: %f, D: %f, CM: %f, L/D: %f \n', alphareq_loiter, cd0_loiter, cLreq_loiter, cD_loiter, D_loiter, cM_loiter, eloverdee_loiter);
fprintf('\n----------Landing--------------------------------\n alfa: %f, Cd0: %f, CL: %f, CD: %f, D: %f, CM: %f, L/D: %f \n', alphareq_landing, cd0_landing, cLreq_landing, cD_landing, D_landing, cM_landing, eloverdee_landing);
fprintf(fid, '\n----------Landing--------------------------------\n alfa: %f, Cd0: %f, CL: %f, CD: %f, D: %f, CM: %f, L/D: %f \n', alphareq_landing, cd0_landing, cLreq_landing, cD_landing, D_landing, cM_landing, eloverdee_landing);
fclose(fid);
cd(rootLOCATION)
end
% function cd0=findcd0(c_f, M, sref, swet)
% if M>.7
% c_f=c_f*(1-.09*M^2);
% end
% cd0=c_f*(swet/sref);
% end
function cd0=findcd0(spans, chords, offsets, airfoil, n, laminarflow, alt, v_mach, sref, c_f, D_engine, cd_lg, Sfront_lg, width)
wingSpan = 1;
% n = 50;
width=width/2;
[q v_fps dynvisc]=findconstants(alt, v_mach);
drag=0;
drag_fuse=0;
drag_wing=0;
Chords = findChords(n, chords, spans);
for i = 1:(size(chords)-1)
for j = 1:n
dist = wingSpan*(spans(i+1)-spans(i))./n;
chordloc=linspace(0, Chords(i,j));
delta_x = Chords(i,j)/100;
if spans(i)>width
for k = 1:100
x(k)= k * Chords(i,j)/100;
Re_x(k)= v_fps * x(k)/dynvisc;
if (k <= 100*laminarflow )
cf_x(k) = 0.664 /(sqrt(Re_x(k)));
else % Turbulent
cf_x(k) = 0.455 /(log(0.06 * Re_x(k))^2);
end
xcf_x(k)=x(k)*cf_x(k);
end
t = trapz(cf_x);
Cf = 2 * delta_x * t /Chords(i,j);
drag_section = q*Cf*findPerim(airfoil{i}, Chords(i,j), wingSpan).*dist;
drag_wing=drag_wing+drag_section;
else
for k = 1:100
x(k)= k * Chords(i,j)/100;
Re_x(k)= v_fps * x(k)/dynvisc;
if (k <= 100*laminarflow -10)
cf_x(k) = 0.664 /(sqrt(Re_x(k)));
else % Turbulent
cf_x(k) = 0.455 /(log(0.06 * Re_x(k))^2);
end
xcf_x(k)=x(k)*cf_x(k);
end
t = trapz(cf_x);
Cf = 2 * delta_x * t /Chords(i,j);
drag_section = q*Cf*findPerim(airfoil{i}, Chords(i,j), wingSpan).*dist;
drag_fuse=drag_fuse+drag_section;
end
t = trapz(cf_x);
Cf = 2 * delta_x * t /Chords(i,j);
drag_section = q*Cf*findPerim(airfoil{i}, Chords(i,j), wingSpan).*dist;
drag=drag+drag_section;
end
end
if v_mach>.7
c_f=c_f*(1-.09*v_mach)^2;
end
% cd0engine=c_f*(s_engine/sref);
D_lg=Sfront_lg*q*cd_lg;
D_wing=drag_wing*2;
D_fuse=drag_fuse*2;
drag_tot=D_wing+D_engine+D_lg+D_fuse;
cd0=drag_tot/(q*sref);
cD_lg=D_lg/(q*sref);
cD_engine=D_engine/(q*sref);
cD_wing=D_wing/(q*sref);
cD_fuse=D_fuse/(q*sref);
end
function finddragpolar(cd0, cl_alfa, cL0, e, ar, cd_correction, filename)
alphadeg=[-12:10];
% alpha=(pi/180)*(alphadeg);
alpha=alphadeg;
cL_alfa=cl_alfa*(ar/(ar+(2*(ar+4)/(ar+2))));
for i=1:length(alpha)
C_L(i)=cL_alfa*(alpha(i))+cL0;
cd_i(i)=C_L(i)^2/(pi*ar*e);
C_d(i)=cd0+cd_i(i)+cd_correction;
end
graphname='Drag Polar';
hold on
grid on
axisX0=linspace(0,max(cd));
axisY0=zeros(1,length(axisX0));
plot(axisX0, axisY0,'k--');
plot(C_d, C_L, 'k', 'LineWidth', 2);
plot(C_d, C_L, 'k.');
title(graphname);
xlabel('C_d', 'FontSize', 16);
ylabel('C_L', 'FontSize', 16);
axis([0, .02, -.3, .4]);
set(gca, 'FontSize',16)
% for i=1:length(alphadeg)
% alphalabel=num2str(alphadeg(i));
% label=[' \alpha =' alphalabel];
% text(C_d(i), C_L(i), label)
% end
print ('-dtiff', filename)
grid off
close(1)
end
function q=finddynpress(alt, v_mach)
if alt < 36152
temp=59-.00356*alt;
press=2116*((temp+459.7)/518.6)^5.256;
elseif alt < 82345
temp=-70;
press=473.1*exp(1.73-.000048*alt);
else
print('Program Not Valid for given altitude')
end
%slpcuft: clugs ber cubic foot
density_slpcuft=press/(1718*(temp+459.7));
v_fps=v_mach*sqrt(1.4*1718*(temp+459.7));
q=.5*density_slpcuft*v_fps^2;
end
function [q v_fps dynvisc]=findconstants(alt, v_mach)
if alt < 36152
temp=59-.00356*alt;
press=2116*((temp+459.7)/518.6)^5.256;
elseif alt < 82345
temp=-70;
press=473.1*exp(1.73-.000048*alt);
else
print('Program Not Valid for given altitude')
end
%slpcuft: clugs ber cubic foot
density_slpcuft=press/(1718*(temp+459.7));
v_fps=v_mach*sqrt(1.4*1718*(temp+459.7));
q=finddynpress(alt, v_mach);
S = 110.4;
beta = 1.458e-6;
temp_k=[(temp-32) / (1.8)] + 273 ;
viscosity_pascalseconds = (beta*temp_k^(1.5))/(temp_k+S);
%kgpmcu:kilograms per meter cubed
%msqpse:meters squared per second
%sqftpsec:square feet per second
density_kgpmcu=density_slpcuft*515.4;
dynamic_viscosity_msqpsec=viscosity_pascalseconds/density_kgpmcu;
dynamic_viscosity_sqftpsec=dynamic_viscosity_msqpsec*10.76;
dynvisc=dynamic_viscosity_sqftpsec;
density=density_slpcuft;
end
function cLreq=findcLrequired(alt, s, v_mach, lift)
q=finddynpress(alt, v_mach);
cLreq=lift/(q*s);
end
function alpha=findalpharequired(cLalpha, cL0, cLrequired)
alpha=(cLrequired-cL0)/cLalpha;
end
function cD=findcD(ar, e, cd0, C_L, cd_correction)
% e=4.61*(1-.045*ar^.68)*cosd(sweep_LE)^.15-3.1;
cd_i=C_L^2/(pi*ar*e);
cd_i=C_L^2/(pi*ar*e);
cD=cd0+cd_i+cd_correction;
end
function [pranformArea WetArea]=WhettedArea(spans, chords, offsets, airfoil, n)
% fileName = 'AirData.mat';
wingSpan = 1;
% n = 50;
engineArea=0;
Area = 0;
pranformArea = 0;
Chords = findChords(n, chords, spans);
for i = 1:(size(chords)-1)
for j = 1:n
Chords(i,j);
dist = wingSpan*(spans(i+1)-spans(i))./n;
Area = Area+findPerim( airfoil{i}, Chords(i,j), wingSpan).*dist;
end
end
for i = 1:(size(chords)-1)
for j = 1:n
dist = wingSpan*(spans(i+1)-spans(i))./n;
pranformArea = pranformArea+Chords(i,j).*dist;
% fprintf('Chord: %f pranformArea: %f \n', Chords(i,j), pranformArea)
end
end
Area = Area *2+engineArea;
WetArea = Area;
pranformArea = pranformArea*2;
end
function Chords = findChords( n, Chord, X )
for( i = 1:(length(Chord)-1) )
Xtemp = linspace(X(i),X(i+1),n);
Chords(i,:) = (Chord(i+1)-Chord(i))./(X(i+1)-X(i)).*(Xtemp-X(i))+Chord(i);
end
end
function peri = findPerim(airFile, chord, span)
peri = 0;
Airfoil = load(airFile);
Airfoil = Airfoil*chord*span;
for i = 1:(size(Airfoil,1)-1)
peri = peri + sqrt((Airfoil(i+1,1)-Airfoil(i,1))^2+(Airfoil(i+1,2)-Airfoil(i,2))^2);
end
end
function [plotLE plotTE]=plotpranform(spans, chords, offsets, n)
Chords = findChords(n, chords, spans);
%plot planform
for i = 1:(size(chords)-1)
dist=0;
for j = 1:n
Chords(i,j);
dist = (spans(i+1)-spans(i))./n;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
fitX(1)=spans(i);
fitX(2)=spans(i+1);
fitY(1)=offsets(i);
fitY(2)=offsets(i+1);
a = polyfit(fitX, fitY,1);
yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
end
end
plotLE=zeros(1,2);
plotTE=zeros(1,2);
for i=1:(size(chords)-1)
for j=1:n
plotLE=[plotLE; xplotLE(i,j) -yplotLE(i,j)];
plotTE=[plotTE; xplotLE(i,j) -(yplotLE(i,j)+Chords(i,j))];
end
end
plotTE(1,:)=[];
plotLE(1,:)=[];
end
function [wakeplot]=findwake(airfoil, chords, spans, offsets, n, alt, v_mach, laminarflow, width)
[q v_fps dynvisc]=findconstants(alt, v_mach);
Chords = findChords(n, chords, spans);
wakeplot=zeros(100,1);
wakeplotX=zeros(100,1);
wakeplotY=zeros(100,1);
width=width/2;
% for i = 1:(size(chords)-1)
for i=1:1:(size(chords)-1)
for j = 1:n
% wakecoord(j,:)=linspace(0, Chords(i,j), n);
dist = (spans(i+1)-spans(i))./n;
y(j)=spans(i)+j*dist;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
fitX(1)=spans(i);
fitX(2)=spans(i+1);
fitY(1)=offsets(i);
fitY(2)=offsets(i+1);
a = polyfit(fitX, fitY,1);
yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
if spans(i)>width
lam=laminarflow;
else
lam=laminarflow-.15;
end
x=linspace(0, Chords(i,j));
for k = 1:length(x)
if (k <= 100*lam)
delta_x=( 5.2 * x(k) )*(v_fps*x(k)/dynvisc)^-0.5;
wake(k,j)= delta_x;
else %if turbulent
x_tr=x(100*lam);
Re_xtr = v_fps * x_tr / dynvisc;
delta_xtr=(5.2*x_tr)*(v_fps*x(k)/dynvisc)^-(0.5);
delta_l = ((delta_xtr*((v_fps)^0.2))/(0.37*((dynvisc)^0.2)))^(1/0.8);
lt = x(k) - x_tr + delta_l;
Re_lt = v_fps * lt / dynvisc;
delta = 0.37 * lt /(Re_lt)^0.2;
wake(k,j) = delta;
end
wakeX(k,j)=x(k)+yplotLE(i,j);
wakeY(k,j)=y(j);
end
for k = 1:100
wakeX(k,j)=x(k)+yplotLE(i,j);
wakeY(k,j)=y(j);
end
wakeplot=[wakeplot, wake];
wakeplotX=[wakeplotX, wakeX];
wakeplotY=[wakeplotY, wakeY];
end
end
wakeplot(:,1)=[ ];
wakeplotX(:,1)=[ ];
wakeplotY(:,1)=[ ];
wakeplot(1,:)=[0];
flipud(wakeplot);
end
function thickness=findthickness(airfoil, Chord, xLoc)
Airfoil = load(airfoil);
Airfoil = Airfoil*Chord;
% blah....goodnight
AirfoilX=Airfoil(:,1);
[min_diff, k]=min(abs(AirfoilX));
for j=1:k
AirfoilYupper(j)=Airfoil(j,2);
AirfoilXupper(j)=Airfoil(j,1);
end
for j=1:length(Airfoil)-k
AirfoilYlower(j)=Airfoil(length(Airfoil)-(j-1), 2);
AirfoilXlower(j)=Airfoil(length(Airfoil)-(j-1), 1);
end
AirfoilYupper=fliplr(AirfoilYupper);
AirfoilXupper=fliplr(AirfoilXupper);
AirfoilYlower=fliplr(AirfoilYlower);
AirfoilXlower=fliplr(AirfoilXlower);
AirfoilYlower=[0 AirfoilYlower];
AirfoilXlower=[0 AirfoilXlower];
[min_diff, k]=min(abs(AirfoilX));
[min_diff, kU]=min(abs(AirfoilXupper-xLoc));
[min_diff, kL]=min(abs(AirfoilXlower-xLoc));
if xLoc<AirfoilXupper(kU)
xFitU(1)=AirfoilXupper(kU-1);
xFitU(2)=AirfoilXupper(kU);
yFitU(1)=AirfoilYupper(kU-1);
yFitU(2)=AirfoilYupper(kU);
else
xFitU(1)=AirfoilXupper(kU);
xFitU(2)=AirfoilXupper(kU+1);
yFitU(1)=AirfoilYupper(kU);
yFitU(2)=AirfoilYupper(kU+1);
end
if xLoc<AirfoilXlower(kL)
xFitL(1)=AirfoilXlower(kL-1);
xFitL(2)=AirfoilXlower(kL);
yFitL(1)=AirfoilYlower(kL-1);
yFitL(2)=AirfoilYlower(kL);
else
xFitL(1)=AirfoilXlower(kL);
xFitL(2)=AirfoilXlower(kL+1);
yFitL(1)=AirfoilYlower(kL);
yFitL(2)=AirfoilYlower(kL+1);
end
aU = polyfit(xFitU, yFitU,1);
aL = polyfit(xFitL, yFitL,1);
% yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
% thickness = AirfoilYupper(xLoc_indu)-AirfoilYlower(xLoc_indl);
thickness = (aU(1)*xLoc+aU(2))-(aL(1)*xLoc+aL(2));
end

539
Matlab code/Ronaldplus.m Executable file
View File

@@ -0,0 +1,539 @@
%Ronald
%all alfas in DEGREES!
%by ascorrea, with help from Jacob Huffman
%"filler" variable just makes it easier to switch between Ronald and Grimace
function Ronald(paramfile, pranformfile, filler)
testrange={'20'};
for testnumber=1:length(testrange)
prefix='FDR0';
name=strcat(prefix, testrange{testnumber});
paramfile=strcat(name, '.param');
pranformfile=strcat(name, '.plan');
%DIRECTORY LOCATIONS--------------------------------------------------------------]
rootLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Matlab Code';
airfoilLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Airfoils';
pranformLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Planforms';
pranformConstraintLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Planform Constraints';
paramLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Parameter Files';
outputsLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Ronaldplus Outputs';
%-----------------------------------------------------------------------]
n=50;
cd(paramLOCATION);
[variablenames, variablevalues]=textread(paramfile, '%s %f');
inputvalues=num2str(variablevalues);
input=strcat(variablenames, inputvalues);
[constantnames, constantvalues]=textread('constants.param', '%s %f');
cd(pranformLOCATION)
[spans, chords, offsets, airfoil]=textread(pranformfile, '%f %f %f %s');
cd(airfoilLOCATION)
[sref swet]=WhettedArea(spans, chords, offsets, airfoil, n);
for k = 1:length(variablenames)
eval([variablenames{k} '= variablevalues(k);']);
end
for k = 1:length(constantnames)
eval([constantnames{k} '= constantvalues(k);']);
end
Dragredux_BLI=(1-Dragredux_BLI/100);
wingspan=2*spans(end);
AR=wingspan^2/sref;
% wakeplot=findwake(airfoil, chords, spans, offsets, n, alt_cruise, M_cruise, laminarflow_cruise, fuse_width);
%TAKEOFF------------------------------------------------------------------]
% cd0_to=findcd0(c_f, M_to, sref, swet);
[cd0_to D_wing_to D_fuse_to]=findcd0(spans, chords, offsets, airfoil, n, laminarflow_to, alt_to, M_to, sref, c_f, D_engine, cd_landinggear, sfront_landinggear, fuse_width);
% finddragpolar(cd0_to, cLalpha_to, cL0, efficiency_to, AR, cd_correction, 'Takeoff')
% cLreq_to=findcLrequired(alt_to, sref, M_to, weight_to);
cLreq_to=.48;
alphareq_to=findalpharequired(cLalpha, cL0, cLreq_to);
cD_to=findcD(AR, efficiency_to, cd0_to, cLreq_to, cd_correction);
eloverdee_to=cLreq_to/cD_to;
cM_to=cMalpha*alphareq_to+cM0;
q_to=finddynpress(alt_to, M_to);
cD_to=cD_to*Dragredux_BLI;
cd0_to=cd0_to*Dragredux_BLI;
D_to=cD_to*q_to*sref;
%CRUISE------------------------------------------------------------------]
[cd0_cruise D_wing_cruise D_fuse_cruise]=findcd0(spans, chords, offsets, airfoil, n, laminarflow_cruise, alt_cruise, M_cruise, sref, c_f, D_engine, 0, 0, fuse_width);
% finddragpolar(cd0_cruise, cLalpha, cL0, efficiency_cruise, AR, cd_correction, 'Cruise')
cLreq_cruise=findcLrequired(alt_cruise, sref, M_cruise, weight_cruise);
alphareq_cruise=findalpharequired(cLalpha, cL0, cLreq_cruise);
cD_cruise=findcD(AR, efficiency_cruise, cd0_cruise, cLreq_cruise, cd_correction);
cM_cruise=cMalpha*alphareq_cruise+cM0;
q_cruise=finddynpress(alt_cruise, M_cruise);
cD_cruise=cD_cruise*Dragredux_BLI;
cd0_cruise=cd0_cruise*Dragredux_BLI;
D_cruise=cD_cruise*q_cruise*sref;
eloverdee_cruise=cLreq_cruise/cD_cruise;
%LOITER------------------------------------------------------------------]
[cd0_loiter D_wing_loiter D_fuse_loiter]=findcd0(spans, chords, offsets, airfoil, n, laminarflow_loiter, alt_loiter, M_loiter, sref, c_f, D_engine, 0, 0, fuse_width);
% finddragpolar(cd0_loiter, cLalpha_loiter, cL0, efficiency_loiter, AR, cd_correction, 'Loiter')
cLreq_loiter=findcLrequired(alt_loiter, sref, M_loiter, weight_loiter);
alphareq_loiter=findalpharequired(cLalpha, cL0, cLreq_loiter);
cD_loiter=findcD(AR, efficiency_loiter, cd0_loiter, cLreq_loiter, cd_correction);
cM_loiter=cMalpha*alphareq_loiter+cM0;
q_loiter=finddynpress(alt_loiter, M_loiter);
cD_loiter=cD_loiter*Dragredux_BLI;
cd0_loiter=cd0_loiter*Dragredux_BLI;
D_loiter=cD_loiter*q_loiter*sref;
eloverdee_loiter=cLreq_loiter/cD_loiter;
%LANDING------------------------------------------------------------------]
[cd0_landing D_wing_landing D_fuse_landing]=findcd0(spans, chords, offsets, airfoil, n, laminarflow_landing, alt_landing, M_landing, sref, c_f, D_engine, cd_landinggear, sfront_landinggear, fuse_width);
% finddragpolar(cd0_landing, cLalpha_landing, cL0, efficiency_landing, AR, cd_correction, 'Landing')
% cLreq_landing=findcLrequired(alt_landing, sref, M_landing, weight_landing);
cLreq_landing=.401;
alphareq_landing=findalpharequired(cLalpha, cL0, cLreq_landing);
cD_landing=findcD(AR, efficiency_landing, cd0_landing, cLreq_landing, cd_correction);
cM_landing=cMalpha*alphareq_landing+cM0;
q_landing=finddynpress(alt_landing, M_landing);
cD_landing=cD_landing*Dragredux_BLI;
cd0_landing=cd0_landing*Dragredux_BLI;
D_landing=cD_landing*q_landing*sref;
eloverdee_landing=cLreq_landing/cD_landing;
cd(outputsLOCATION)
filenameplan=regexprep(pranformfile, '.plan', '_planform.tiff');
filenameoutput=regexprep(pranformfile, '.plan', '.txt');
plottitle=regexprep(pranformfile, '.plan', '');
fid = fopen(filenameoutput, 'w');
plottitle
fprintf(fid, plottitle);
fprintf(fid,'\nOutputs--------------------------------------------------\n');
fprintf(fid, 'Wingspan: %f, AR: %f, Planform Area: %f, Wetted Area: %f \n', wingspan, AR, sref, swet);
fprintf(fid, '\n----------Takeoff--------------------------------\n alfa: %f, Cd0: %f, CL: %f, CD: %f, D: %f, CM: %f, L/D: %f \n', alphareq_to, cd0_to, cLreq_to, cD_to, D_to, cM_to, eloverdee_to);
fprintf(fid, '\n----------Cruise---------------------------------\n alfa: %f, Cd0: %f, CL: %f, CD: %f, D: %f, CM: %f, L/D: %f \n D_Wing:%f, D_fuselage:%f', alphareq_cruise, cd0_cruise, cLreq_cruise, cD_cruise, D_cruise, cM_cruise, eloverdee_cruise, D_wing_cruise, D_fuse_cruise);
fprintf(fid, '\n----------Loiter---------------------------------\n alfa: %f, Cd0: %f, CL: %f, CD: %f, D: %f, CM: %f, L/D: %f \n', alphareq_loiter, cd0_loiter, cLreq_loiter, cD_loiter, D_loiter, cM_loiter, eloverdee_loiter);
fprintf(fid, '\n----------Landing--------------------------------\n alfa: %f, Cd0: %f, CL: %f, CD: %f, D: %f, CM: %f, L/D: %f \n', alphareq_landing, cd0_landing, cLreq_landing, cD_landing, D_landing, cM_landing, eloverdee_landing);
fprintf(fid, '\nInputs--------------------------------------------------\n');
for k=1:length(input)-1
fprintf(fid, '%s %s \n',input{k}, input{k+1});
end
fclose(fid);
cd(rootLOCATION)
end
end
% function cd0=findcd0(c_f, M, sref, swet)
% if M>.7
% c_f=c_f*(1-.09*M^2);
% end
% cd0=c_f*(swet/sref);
% end
function [cd0 D_wing D_fuse]=findcd0(spans, chords, offsets, airfoil, n, laminarflow, alt, v_mach, sref, c_f, D_engine, cd_lg, Sfront_lg, width)
wingSpan = 1;
% n = 50;
width=width/2;
[q v_fps dynvisc]=findconstants(alt, v_mach);
drag=0;
drag_fuse=0;
drag_wing=0;
Chords = findChords(n, chords, spans);
for i = 1:(size(chords)-1)
for j = 1:n
dist = wingSpan*(spans(i+1)-spans(i))./n;
chordloc=linspace(0, Chords(i,j));
delta_x = Chords(i,j)/100;
if spans(i)>width
for k = 1:100
x(k)= k * Chords(i,j)/100;
Re_x(k)= v_fps * x(k)/dynvisc;
if (k <= 100*laminarflow )
cf_x(k) = 0.664 /(sqrt(Re_x(k)));
else % Turbulent
cf_x(k) = 0.455 /(log(0.06 * Re_x(k))^2);
end
xcf_x(k)=x(k)*cf_x(k);
end
t = trapz(cf_x);
Cf = 2 * delta_x * t /Chords(i,j);
drag_section = q*Cf*findPerim(airfoil{i}, Chords(i,j), wingSpan).*dist;
drag_wing=drag_wing+drag_section;
else
for k = 1:100
x(k)= k * Chords(i,j)/100;
Re_x(k)= v_fps * x(k)/dynvisc;
if (k <= 100*laminarflow -10)
cf_x(k) = 0.664 /(sqrt(Re_x(k)));
else % Turbulent
cf_x(k) = 0.455 /(log(0.06 * Re_x(k))^2);
end
xcf_x(k)=x(k)*cf_x(k);
end
t = trapz(cf_x);
Cf = 2 * delta_x * t /Chords(i,j);
drag_section = q*Cf*findPerim(airfoil{i}, Chords(i,j), wingSpan).*dist;
drag_fuse=drag_fuse+drag_section;
end
t = trapz(cf_x);
Cf = 2 * delta_x * t /Chords(i,j);
drag_section = q*Cf*findPerim(airfoil{i}, Chords(i,j), wingSpan).*dist;
drag=drag+drag_section;
end
end
if v_mach>.7
c_f=c_f*(1-.09*v_mach)^2;
end
% cd0engine=c_f*(s_engine/sref);
D_lg=Sfront_lg*q*cd_lg;
D_wing=drag_wing*2;
D_fuse=drag_fuse*2;
drag_tot=D_wing+D_engine+D_lg+D_fuse;
cd0=drag_tot/(q*sref);
cD_lg=D_lg/(q*sref);
cD_engine=D_engine/(q*sref);
cD_wing=D_wing/(q*sref);
cD_fuse=D_fuse/(q*sref);
end
function finddragpolar(cd0, cl_alfa, cL0, e, ar, cd_correction, filename)
alphadeg=[-12:10];
% alpha=(pi/180)*(alphadeg);
alpha=alphadeg;
cL_alfa=cl_alfa*(ar/(ar+(2*(ar+4)/(ar+2))));
for i=1:length(alpha)
C_L(i)=cL_alfa*(alpha(i))+cL0;
cd_i(i)=C_L(i)^2/(pi*ar*e);
C_d(i)=cd0+cd_i(i)+cd_correction;
end
graphname='Drag Polar';
hold on
grid on
axisX0=linspace(0,max(cd));
axisY0=zeros(1,length(axisX0));
plot(axisX0, axisY0,'k--');
plot(C_d, C_L, 'k', 'LineWidth', 2);
plot(C_d, C_L, 'k.');
title(graphname);
xlabel('C_d', 'FontSize', 16);
ylabel('C_L', 'FontSize', 16);
axis([0, .02, -.3, .4]);
set(gca, 'FontSize',16)
% for i=1:length(alphadeg)
% alphalabel=num2str(alphadeg(i));
% label=[' \alpha =' alphalabel];
% text(C_d(i), C_L(i), label)
% end
print ('-dtiff', filename)
grid off
close(1)
end
function q=finddynpress(alt, v_mach)
if alt < 36152
temp=59-.00356*alt;
press=2116*((temp+459.7)/518.6)^5.256;
elseif alt < 82345
temp=-70;
press=473.1*exp(1.73-.000048*alt);
else
print('Program Not Valid for given altitude')
end
%slpcuft: clugs ber cubic foot
density_slpcuft=press/(1718*(temp+459.7));
v_fps=v_mach*sqrt(1.4*1718*(temp+459.7));
q=.5*density_slpcuft*v_fps^2;
end
function [q v_fps dynvisc]=findconstants(alt, v_mach)
if alt < 36152
temp=59-.00356*alt;
press=2116*((temp+459.7)/518.6)^5.256;
elseif alt < 82345
temp=-70;
press=473.1*exp(1.73-.000048*alt);
else
print('Program Not Valid for given altitude')
end
%slpcuft: clugs ber cubic foot
density_slpcuft=press/(1718*(temp+459.7));
v_fps=v_mach*sqrt(1.4*1718*(temp+459.7));
q=finddynpress(alt, v_mach);
S = 110.4;
beta = 1.458e-6;
temp_k=[(temp-32) / (1.8)] + 273 ;
viscosity_pascalseconds = (beta*temp_k^(1.5))/(temp_k+S);
%kgpmcu:kilograms per meter cubed
%msqpse:meters squared per second
%sqftpsec:square feet per second
density_kgpmcu=density_slpcuft*515.4;
dynamic_viscosity_msqpsec=viscosity_pascalseconds/density_kgpmcu;
dynamic_viscosity_sqftpsec=dynamic_viscosity_msqpsec*10.76;
dynvisc=dynamic_viscosity_sqftpsec;
density=density_slpcuft;
end
function cLreq=findcLrequired(alt, s, v_mach, lift)
q=finddynpress(alt, v_mach);
cLreq=lift/(q*s);
end
function alpha=findalpharequired(cLalpha, cL0, cLrequired)
alpha=(cLrequired-cL0)/cLalpha;
end
function cD=findcD(ar, e, cd0, C_L, cd_correction)
% e=4.61*(1-.045*ar^.68)*cosd(sweep_LE)^.15-3.1;
cd_i=C_L^2/(pi*ar*e);
cd_i=C_L^2/(pi*ar*e);
cD=cd0+cd_i+cd_correction;
end
function [pranformArea WetArea]=WhettedArea(spans, chords, offsets, airfoil, n)
% fileName = 'AirData.mat';
wingSpan = 1;
% n = 50;
engineArea=0;
Area = 0;
pranformArea = 0;
Chords = findChords(n, chords, spans);
for i = 1:(size(chords)-1)
for j = 1:n
Chords(i,j);
dist = wingSpan*(spans(i+1)-spans(i))./n;
Area = Area+findPerim( airfoil{i}, Chords(i,j), wingSpan).*dist;
end
end
for i = 1:(size(chords)-1)
for j = 1:n
dist = wingSpan*(spans(i+1)-spans(i))./n;
pranformArea = pranformArea+Chords(i,j).*dist;
% fprintf('Chord: %f pranformArea: %f \n', Chords(i,j), pranformArea)
end
end
Area = Area *2+engineArea;
WetArea = Area;
pranformArea = pranformArea*2;
end
function Chords = findChords( n, Chord, X )
for( i = 1:(length(Chord)-1) )
Xtemp = linspace(X(i),X(i+1),n);
Chords(i,:) = (Chord(i+1)-Chord(i))./(X(i+1)-X(i)).*(Xtemp-X(i))+Chord(i);
end
end
function peri = findPerim(airFile, chord, span)
peri = 0;
Airfoil = load(airFile);
Airfoil = Airfoil*chord*span;
for i = 1:(size(Airfoil,1)-1)
peri = peri + sqrt((Airfoil(i+1,1)-Airfoil(i,1))^2+(Airfoil(i+1,2)-Airfoil(i,2))^2);
end
end
function [plotLE plotTE]=plotpranform(spans, chords, offsets, n)
Chords = findChords(n, chords, spans);
%plot planform
for i = 1:(size(chords)-1)
dist=0;
for j = 1:n
Chords(i,j);
dist = (spans(i+1)-spans(i))./n;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
fitX(1)=spans(i);
fitX(2)=spans(i+1);
fitY(1)=offsets(i);
fitY(2)=offsets(i+1);
a = polyfit(fitX, fitY,1);
yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
end
end
plotLE=zeros(1,2);
plotTE=zeros(1,2);
for i=1:(size(chords)-1)
for j=1:n
plotLE=[plotLE; xplotLE(i,j) -yplotLE(i,j)];
plotTE=[plotTE; xplotLE(i,j) -(yplotLE(i,j)+Chords(i,j))];
end
end
plotTE(1,:)=[];
plotLE(1,:)=[];
end
function [wakeplot]=findwake(airfoil, chords, spans, offsets, n, alt, v_mach, laminarflow, width)
[q v_fps dynvisc]=findconstants(alt, v_mach);
Chords = findChords(n, chords, spans);
wakeplot=zeros(100,1);
wakeplotX=zeros(100,1);
wakeplotY=zeros(100,1);
width=width/2;
% for i = 1:(size(chords)-1)
for i=1:1:(size(chords)-1)
for j = 1:n
% wakecoord(j,:)=linspace(0, Chords(i,j), n);
dist = (spans(i+1)-spans(i))./n;
y(j)=spans(i)+j*dist;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
fitX(1)=spans(i);
fitX(2)=spans(i+1);
fitY(1)=offsets(i);
fitY(2)=offsets(i+1);
a = polyfit(fitX, fitY,1);
yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
if spans(i)>width
lam=laminarflow;
else
lam=laminarflow-.15;
end
x=linspace(0, Chords(i,j));
for k = 1:length(x)
if (k <= 100*lam)
delta_x=( 5.2 * x(k) )*(v_fps*x(k)/dynvisc)^-0.5;
wake(k,j)= delta_x;
else %if turbulent
x_tr=x(100*lam);
Re_xtr = v_fps * x_tr / dynvisc;
delta_xtr=(5.2*x_tr)*(v_fps*x(k)/dynvisc)^-(0.5);
delta_l = ((delta_xtr*((v_fps)^0.2))/(0.37*((dynvisc)^0.2)))^(1/0.8);
lt = x(k) - x_tr + delta_l;
Re_lt = v_fps * lt / dynvisc;
delta = 0.37 * lt /(Re_lt)^0.2;
wake(k,j) = delta;
end
wakeX(k,j)=x(k)+yplotLE(i,j);
wakeY(k,j)=y(j);
end
for k = 1:100
wakeX(k,j)=x(k)+yplotLE(i,j);
wakeY(k,j)=y(j);
end
wakeplot=[wakeplot, wake];
wakeplotX=[wakeplotX, wakeX];
wakeplotY=[wakeplotY, wakeY];
end
end
wakeplot(:,1)=[ ];
wakeplotX(:,1)=[ ];
wakeplotY(:,1)=[ ];
wakeplot(1,:)=[0];
flipud(wakeplot);
end
function thickness=findthickness(airfoil, Chord, xLoc)
Airfoil = load(airfoil);
Airfoil = Airfoil*Chord;
% blah....goodnight
AirfoilX=Airfoil(:,1);
[min_diff, k]=min(abs(AirfoilX));
for j=1:k
AirfoilYupper(j)=Airfoil(j,2);
AirfoilXupper(j)=Airfoil(j,1);
end
for j=1:length(Airfoil)-k
AirfoilYlower(j)=Airfoil(length(Airfoil)-(j-1), 2);
AirfoilXlower(j)=Airfoil(length(Airfoil)-(j-1), 1);
end
AirfoilYupper=fliplr(AirfoilYupper);
AirfoilXupper=fliplr(AirfoilXupper);
AirfoilYlower=fliplr(AirfoilYlower);
AirfoilXlower=fliplr(AirfoilXlower);
AirfoilYlower=[0 AirfoilYlower];
AirfoilXlower=[0 AirfoilXlower];
[min_diff, k]=min(abs(AirfoilX));
[min_diff, kU]=min(abs(AirfoilXupper-xLoc));
[min_diff, kL]=min(abs(AirfoilXlower-xLoc));
if xLoc<AirfoilXupper(kU)
xFitU(1)=AirfoilXupper(kU-1);
xFitU(2)=AirfoilXupper(kU);
yFitU(1)=AirfoilYupper(kU-1);
yFitU(2)=AirfoilYupper(kU);
else
xFitU(1)=AirfoilXupper(kU);
xFitU(2)=AirfoilXupper(kU+1);
yFitU(1)=AirfoilYupper(kU);
yFitU(2)=AirfoilYupper(kU+1);
end
if xLoc<AirfoilXlower(kL)
xFitL(1)=AirfoilXlower(kL-1);
xFitL(2)=AirfoilXlower(kL);
yFitL(1)=AirfoilYlower(kL-1);
yFitL(2)=AirfoilYlower(kL);
else
xFitL(1)=AirfoilXlower(kL);
xFitL(2)=AirfoilXlower(kL+1);
yFitL(1)=AirfoilYlower(kL);
yFitL(2)=AirfoilYlower(kL+1);
end
aU = polyfit(xFitU, yFitU,1);
aL = polyfit(xFitL, yFitL,1);
% yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
% thickness = AirfoilYupper(xLoc_indu)-AirfoilYlower(xLoc_indl);
thickness = (aU(1)*xLoc+aU(2))-(aL(1)*xLoc+aL(2));
end

24
Matlab code/airfoil.m Executable file
View File

@@ -0,0 +1,24 @@
%ASCorrea
function airfoil(airfoilfilename)
rootLOCATION='\\ad.uiuc.edu\ae\correa2\Desktop\AE441\AE441 - Home Edition\Matlab code\';
airfoilLOCATION='\\ad.uiuc.edu\ae\correa2\Desktop\AE441\AE441 - Home Edition\Airfoils';
% airfoilfilename=input('Input airfoil dat file: \nNote: You must delete the header before using \n:','s');
% airfoilfilename='flatplate.dat'
cd(airfoilLOCATION)
data=load(airfoilfilename);
plottitle=regexprep(airfoilfilename, '.dat', '');
dataX=data(:,1);
dataY=data(:,2);
plot(dataX, dataY, 'k', 'LineWidth', 2)
axis equal
axis off
title(['Airfoil ' , plottitle])
print ('-dtiff', plottitle)
cd(rootLOCATION)
end

58
Matlab code/strut/ARfit.m Executable file
View File

@@ -0,0 +1,58 @@
function [AR,xLE]=ARfit(P,t)
global tmax
% This function calculates the AR of a rectangle fitted inside an airfoil
% described by the cubic spline function in P. The value t is the thickness
% if the required rectangle (<t/c max).
% OUTPUT:
% AR=Aspect ratio of fitted rectangle
% xLE=Forward x-position of rectangle.
% Penalty functions for going out of bounds
flag=0;
x1=tmax/1000;
if (t>tmax-x1)
tsave=t;
t=tmax-x1;
flag=2;
elseif (t<x1)
tsave=t;
t=x1;
flag=1;
end;
N=50;
theta=(pi-logspace(-1,pi,N))/2;
theta(1)=[];
theta=[fliplr(theta) pi-theta];
f1=ppval(P,theta).*sin(theta)-t/2;
f2=[f1(2:N*2-2) f1(N*2-2)];
FF=abs(sign(f1)-sign(f2));
roots=find(FF>0);
thetaTE=reversefit(P,t/2,theta(roots(1)));
rTE=ppval(P,thetaTE);
xTE=rTE*cos(thetaTE);
thetaLE=reversefit(P,t/2,theta(roots(2)));
rLE=ppval(P,thetaLE);
xLE=rLE*cos(thetaLE);
l=abs(xTE-xLE);
AR=l/t;
if flag==1
x3=2*x1;
y1=AR;
y2=1.1*AR;
a = (y1-y2)/(-2*x3*x1+x1^2);
b=(y1-a*x1^2-y2)/x1;
AR=a*tsave^2+b*tsave+y2;
elseif flag==2
x3=tmax-x1*.001;
x2=tmax;
x1=tmax-2*x1;
a=-AR/((x2^2-x3^2)-2*x1*(x2-x3));
b=-2*a*x1;
c=-a*x2^2-b*x2;
AR=a*tsave^2+b*tsave+c;
end;

60
Matlab code/strut/CB3.dat Executable file
View File

@@ -0,0 +1,60 @@
Centerbody 3
0.92743 0.03097
0.88580 0.03617
0.83259 0.04000
0.77100 0.04266
0.70420 0.04437
0.63540 0.04534
0.56776 0.04578
0.50371 0.04585
0.44392 0.04568
0.38886 0.04536
0.33898 0.04499
0.29474 0.04467
0.25657 0.04450
0.22425 0.04448
0.19666 0.04448
0.17264 0.04438
0.15102 0.04404
0.13063 0.04334
0.11039 0.04214
0.09021 0.04042
0.07079 0.03824
0.05285 0.03564
0.03713 0.03269
0.02434 0.02944
0.01508 0.02594
0.00899 0.02216
0.00531 0.01807
0.00325 0.01363
0.00203 0.00880
0.00088 0.00354
0.00084 -0.00546
0.00269 -0.01211
0.00680 -0.01962
0.01437 -0.02765
0.02663 -0.03587
0.04482 -0.04397
0.07014 -0.05160
0.10364 -0.05845
0.14471 -0.06435
0.19192 -0.06920
0.24380 -0.07289
0.29892 -0.07532
0.35581 -0.07639
0.41302 -0.07600
0.46913 -0.07405
0.52309 -0.07058
0.57428 -0.06580
0.62208 -0.05990
0.66587 -0.05307
0.70504 -0.04551
0.73898 -0.03742
0.76707 -0.02899
0.78959 -0.02039
0.80857 -0.01167
0.82619 -0.00288
0.84469 0.00592
0.86625 0.01468
0.89310 0.02334
0.92743 0.03186

60
Matlab code/strut/CB4.dat Executable file
View File

@@ -0,0 +1,60 @@
Centerbody 4
0.91334 0.02171
0.87802 0.03287
0.82202 0.04154
0.75161 0.04805
0.67304 0.05272
0.59260 0.05591
0.51655 0.05793
0.44911 0.05907
0.39005 0.05946
0.33849 0.05924
0.29356 0.05851
0.25442 0.05742
0.22019 0.05607
0.19013 0.05455
0.16366 0.05285
0.14022 0.05098
0.11921 0.04894
0.10008 0.04672
0.08226 0.04433
0.06558 0.04169
0.05009 0.03871
0.03589 0.03528
0.02306 0.03128
0.01169 0.02660
0.00186 0.02118
-0.00621 0.01519
-0.01228 0.00894
-0.01609 0.00272
-0.01740 -0.00318
-0.01595 -0.00844
-0.01403 -0.01488
-0.01170 -0.01993
-0.00658 -0.02531
0.00278 -0.03084
0.01782 -0.03636
0.03997 -0.04172
0.07067 -0.04676
0.11111 -0.05130
0.16022 -0.05517
0.21577 -0.05819
0.27553 -0.06016
0.33725 -0.06092
0.39870 -0.06026
0.45764 -0.05800
0.51190 -0.05397
0.56072 -0.04828
0.60476 -0.04132
0.64472 -0.03348
0.68132 -0.02516
0.71528 -0.01676
0.74732 -0.00867
0.77814 -0.00131
0.80793 0.00506
0.83590 0.01040
0.86111 0.01467
0.88263 0.01788
0.89954 0.01999
0.91093 0.02099
0.91585 0.02087

60
Matlab code/strut/CB40015.dat Executable file
View File

@@ -0,0 +1,60 @@
Centerbody 4
0.913338 0.021800
0.877970 0.034797
0.821913 0.045691
0.751433 0.054894
0.672786 0.062540
0.592283 0.068148
0.516194 0.071685
0.448734 0.073592
0.389666 0.074289
0.338105 0.074109
0.293179 0.073245
0.254045 0.071912
0.219823 0.070247
0.189772 0.068366
0.163313 0.066266
0.139884 0.063965
0.118886 0.061463
0.099769 0.058747
0.081963 0.055821
0.065298 0.052587
0.049825 0.048941
0.035645 0.044756
0.022837 0.039891
0.011493 0.034215
0.001693 0.027642
-0.006343 0.020334
-0.012373 0.012545
-0.016127 0.004160
-0.017398 -0.003265
-0.015915 -0.009781
-0.013964 -0.017422
-0.011608 -0.023477
-0.006454 -0.030168
0.002946 -0.037244
0.018028 -0.044397
0.040218 -0.051317
0.070955 -0.057764
0.111427 -0.063556
0.160565 -0.068479
0.216135 -0.072286
0.275908 -0.074779
0.337635 -0.075783
0.399083 -0.075073
0.458015 -0.072478
0.512259 -0.067836
0.561057 -0.061299
0.605070 -0.053312
0.645000 -0.044314
0.681569 -0.034760
0.715496 -0.025094
0.747503 -0.015741
0.778291 -0.007162
0.808052 0.000349
0.835995 0.006731
0.861180 0.011979
0.882675 0.016154
0.899562 0.019146
0.910935 0.020782
0.915849 0.020892

60
Matlab code/strut/CB40018.dat Executable file
View File

@@ -0,0 +1,60 @@
Centerbody 4
0.913335 0.021890
0.877920 0.036739
0.821804 0.049876
0.751254 0.061793
0.672529 0.072440
0.591963 0.080485
0.515834 0.085551
0.448354 0.088233
0.389278 0.089240
0.337716 0.089099
0.292793 0.088100
0.253666 0.086521
0.219452 0.084540
0.189411 0.082295
0.162962 0.079792
0.139544 0.077056
0.118558 0.074088
0.099454 0.070872
0.081662 0.067405
0.065013 0.063573
0.049557 0.059256
0.035397 0.054309
0.022612 0.048573
0.011294 0.041892
0.001524 0.034156
-0.006478 0.025521
-0.012468 0.016180
-0.016165 0.005614
-0.017396 -0.003349
-0.015880 -0.011133
-0.013898 -0.019978
-0.011515 -0.027052
-0.006327 -0.035066
0.003113 -0.043699
0.018238 -0.052500
0.040470 -0.060992
0.071243 -0.068857
0.111748 -0.075911
0.160913 -0.081897
0.216504 -0.086498
0.276291 -0.089516
0.338024 -0.090767
0.399471 -0.090007
0.458394 -0.087074
0.512622 -0.081815
0.561398 -0.074424
0.605384 -0.065401
0.645284 -0.055237
0.681820 -0.044437
0.715714 -0.033494
0.747688 -0.022870
0.778445 -0.013063
0.808175 -0.004401
0.836091 0.003033
0.861250 0.009268
0.882720 0.014415
0.899584 0.018292
0.910941 0.020569
0.915849 0.020918

73
Matlab code/strut/CB600185b.dat Executable file
View File

@@ -0,0 +1,73 @@
1.00000 0.00000
0.97500 0.00996
0.95000 0.01900
0.92500 0.02718
0.90000 0.03460
0.87500 0.04131
0.85000 0.04739
0.82500 0.05288
0.80000 0.05785
0.77500 0.06232
0.75000 0.06636
0.72500 0.06998
0.70000 0.07325
0.67500 0.07617
0.65000 0.07879
0.62500 0.08112
0.60000 0.08320
0.55000 0.08664
0.50000 0.08924
0.45000 0.09109
0.40000 0.09218
0.35000 0.09250
0.30000 0.09204
0.25000 0.09067
0.20000 0.08803
0.17500 0.08599
0.15000 0.08328
0.12500 0.07968
0.10000 0.07485
0.07500 0.06855
0.05000 0.05962
0.03750 0.05414
0.02500 0.04820
0.01250 0.03472
0.00652 0.03090
0.00200 0.01606
0.00000 0.00000
0.00200 -0.01606
0.00652 -0.03090
0.01250 -0.03472
0.02500 -0.04820
0.03750 -0.05414
0.05000 -0.05962
0.07500 -0.06855
0.10000 -0.07485
0.12500 -0.07968
0.15000 -0.08328
0.17500 -0.08599
0.20000 -0.08803
0.25000 -0.09067
0.30000 -0.09204
0.35000 -0.09250
0.40000 -0.09218
0.45000 -0.09109
0.50000 -0.08924
0.55000 -0.08664
0.60000 -0.08320
0.62500 -0.08112
0.65000 -0.07879
0.67500 -0.07617
0.70000 -0.07325
0.72500 -0.06998
0.75000 -0.06636
0.77500 -0.06232
0.80000 -0.05785
0.82500 -0.05288
0.85000 -0.04739
0.87500 -0.04131
0.90000 -0.03460
0.92500 -0.02718
0.95000 -0.01900
0.97500 -0.00996
1.00000 0.00000

10
Matlab code/strut/FFunc1.m Executable file
View File

@@ -0,0 +1,10 @@
function FF = FFunc1(theta,P);
% Derivative of function 1
FF=derppval(P,theta)*sin(theta)+ppval(P,theta)*cos(theta);
if theta < 0
FF=-2*theta+pi;
elseif theta > pi
FF=-2*theta+pi;
end;

10
Matlab code/strut/Func1.m Executable file
View File

@@ -0,0 +1,10 @@
function F = Func1(theta,P,yrqd);
% Derivative of function 1
F=ppval(P,theta)*sin(theta)-yrqd;
if theta < 0
F=-theta^2+pi*theta-yrqd;
elseif theta > pi
F=-theta^2+pi*theta-yrqd;
end;

60
Matlab code/strut/GB30015.dat Executable file
View File

@@ -0,0 +1,60 @@
Centerbody 3
0.927434 0.030867
0.885738 0.037894
0.832426 0.044544
0.770708 0.050733
0.703824 0.054767
0.634967 0.057296
0.567289 0.058793
0.503215 0.059528
0.443412 0.059717
0.388348 0.059516
0.338469 0.059099
0.294235 0.058631
0.256072 0.058263
0.223760 0.058026
0.196178 0.057792
0.172167 0.057433
0.150558 0.056791
0.130182 0.055719
0.109959 0.054041
0.089801 0.051717
0.070408 0.048804
0.052499 0.045333
0.036815 0.041386
0.024065 0.037043
0.014845 0.032427
0.008795 0.027556
0.005152 0.022433
0.003127 0.017031
0.001941 0.011266
0.000833 0.004850
0.000868 -0.006228
0.002777 -0.014501
0.006960 -0.024027
0.014590 -0.033727
0.026905 -0.043466
0.045147 -0.053006
0.070516 -0.061993
0.104060 -0.070058
0.145165 -0.076927
0.192399 -0.082424
0.244294 -0.086545
0.299425 -0.089280
0.356322 -0.090523
0.413532 -0.090135
0.469635 -0.087990
0.523580 -0.084127
0.574750 -0.078781
0.622524 -0.072162
0.666283 -0.064484
0.705419 -0.055972
0.739322 -0.046855
0.767373 -0.037351
0.789853 -0.027657
0.808793 -0.017830
0.826372 -0.007917
0.844831 0.002026
0.866348 0.011975
0.893151 0.021929
0.927426 0.031964

61
Matlab code/strut/Newton.m Executable file
View File

@@ -0,0 +1,61 @@
function x=newton(Fs,FPs,P0,y,P,TOL);
% NEWTON-RAPHSON ALGORITHM 2.3
%
% To find a solution to f(x) = 0 given an
% initial approximation p0:
%
% y,P can be used for additional info if the function
% requires it.
%
% Initially written by Burden and Faires, revised by
% B.A. Broughton, 10/01/1999
%
% INPUT: initial approximation p0; tolerance TOL;
% maximum number of iterations NO.
%
% OUTPUT: approximate solution p or a message of failure
TRUE = 1;
FALSE = 0;
F = inline(Fs,'x','P','y');
FP = inline(FPs,'x','P');
NO=150;
OUP = 1;
F0 = F(P0,P,y);
% STEP 1
I = 1;
OK = TRUE;
% STEP 2
while I <= NO & OK == TRUE
% STEP 3
% compute P(I)
FP0 = FP(P0,P);
D = F0/FP0;
% STEP 6
P0 = P0 - D;
F0 = F(P0,P,y);
% STEP 4
if abs(D) < TOL
% procedure completed successfully
% fprintf(OUP,'\nApproximate solution = %.10e\n',P0);
% fprintf(OUP,'with F(P) = %.10e\n',F0);
% fprintf(OUP,'Number of iterations = %d\n',I);
% fprintf(OUP,'Tolerance = %.10e\n',TOL);
OK = FALSE;
% STEP 5
else
I = I+1;
end
end
if OK == TRUE
% STEP 7
% procedure completed unsuccessfully
fprintf(OUP,'\nIteration number %d',NO);
fprintf(OUP,' gave approximation %.10e\n',P0);
fprintf(OUP,'with F(P) = %.10e not within tolerance %.10e\n',F0,TOL);
end
x = P0;

4
Matlab code/strut/default.dat Executable file
View File

@@ -0,0 +1,4 @@
Strut length:
4.0
Strut width:
1.5

48
Matlab code/strut/derppval.m Executable file
View File

@@ -0,0 +1,48 @@
function v=derppval(pp,xx)
%PPVAL Evaluate piecewise polynomial.
% V = PPVAL(PP,XX) returns the value at the points XX of the
% piecewise polynomial contained in PP, as constructed by SPLINE
% (or MKPP).
%
% Revised by B.A. Broughton on 10/01/1999 to calculate the derivative
% for a pre-fitted cubic spline in the points xx
%
% See also SPLINE.
% Carl de Boor 7-2-86
% Revised 10-14-97 CB to speed up locating points in mesh (as in
% PPUAL) and to handle vector-valued functions.
% Copyright (c) 1984-98 by The MathWorks, Inc.
% $Revision: 5.8 $ $Date: 1997/11/21 23:41:00 $
[mx,nx] = size(xx); lx = mx*nx; xs = reshape(xx,1,lx);
% if necessary, sort xx
tosort=0;
if any(diff(xs)<0)
tosort=1;[xs,ix]=sort(xs);
end
% take apart pp
[x,c,l,k,d]=unmkpp(pp);
% for each data point, compute its breakpoint interval
[ignored,index] = sort([x(1:l) xs]);
index = max([find(index>l)-(1:lx);ones(1,lx)]);
% now go to local coordinates ...
xs = xs-x(index);
if d>1 % ... replicate xs and index in case pp is vector-valued ...
xs = reshape(xs(ones(d,1),:),1,d*lx);
index = d*index; temp = [-d:-1].';
index = reshape(1+index(ones(d,1),:)+temp(:,ones(1,lx)), d*lx, 1 );
end
% ... and apply nested multiplication to get derivative:
v = 3*c(index,1).';
for i=2:k-1
v = xs.*v + (4-i)*c(index,i).';
end
v = reshape(v,d,lx);
if tosort>0, v(:,ix) = v; end
v = reshape(v,d*mx,nx);

61
Matlab code/strut/e169.dat Executable file
View File

@@ -0,0 +1,61 @@
1.00000 0.00000
0.99640 0.00022
0.98598 0.00115
0.96948 0.00290
0.94737 0.00514
0.91970 0.00771
0.88673 0.01081
0.84899 0.01458
0.80708 0.01904
0.76168 0.02416
0.71346 0.02985
0.66316 0.03596
0.61148 0.04231
0.55912 0.04866
0.50675 0.05477
0.45499 0.06036
0.40442 0.06516
0.35555 0.06889
0.30884 0.07127
0.26456 0.07202
0.22289 0.07110
0.18408 0.06858
0.14839 0.06450
0.11605 0.05896
0.08721 0.05212
0.06206 0.04427
0.04085 0.03567
0.02379 0.02657
0.01106 0.01729
0.00290 0.00819
0.00000 0.00000
0.00290 -0.00819
0.01106 -0.01729
0.02379 -0.02657
0.04085 -0.03567
0.06206 -0.04427
0.08721 -0.05212
0.11605 -0.05896
0.14839 -0.06450
0.18408 -0.06858
0.22289 -0.07110
0.26456 -0.07202
0.30884 -0.07127
0.35555 -0.06889
0.40442 -0.06516
0.45499 -0.06036
0.50675 -0.05477
0.55912 -0.04866
0.61148 -0.04231
0.66316 -0.03596
0.71346 -0.02985
0.76168 -0.02416
0.80708 -0.01904
0.84899 -0.01458
0.88673 -0.01081
0.91970 -0.00771
0.94737 -0.00514
0.96948 -0.00290
0.98598 -0.00115
0.99640 -0.00022
1.00000 0.00000

73
Matlab code/strut/n0011sc.dat Executable file
View File

@@ -0,0 +1,73 @@
1.0000000 0.0000000
0.9750000 0.0063610
0.9500000 0.0120340
0.9250000 0.0170990
0.9000000 0.0216250
0.8750000 0.0256760
0.8500000 0.0293060
0.8250000 0.0325640
0.8000000 0.0354920
0.7750000 0.0381270
0.7500000 0.0404990
0.7250000 0.0426350
0.7000000 0.0445560
0.6750000 0.0462810
0.6500000 0.0478240
0.6250000 0.0491980
0.6000000 0.0504100
0.5500000 0.0523760
0.5000000 0.0537580
0.4500000 0.0545710
0.4000000 0.0547830
0.3500000 0.0544670
0.3000000 0.0535880
0.2500000 0.0521250
0.2000000 0.0499050
0.1750000 0.0484210
0.1500000 0.0466150
0.1250000 0.0444000
0.1000000 0.0416430
0.0750000 0.0381170
0.0500000 0.0333730
0.0375000 0.0302420
0.0250000 0.0262080
0.0125000 0.0203230
0.0065243 0.0157510
0.0020000 0.0092250
0.0000000 0.0000000
0.0020000 -.0092250
0.0065243 -.0157510
0.0125000 -.0203230
0.0250000 -.0262080
0.0375000 -.0302420
0.0500000 -.0333730
0.0750000 -.0381170
0.1000000 -.0416430
0.1250000 -.0444000
0.1500000 -.0466150
0.1750000 -.0484210
0.2000000 -.0499050
0.2500000 -.0521250
0.3000000 -.0535880
0.3500000 -.0544670
0.4000000 -.0547830
0.4500000 -.0545710
0.5000000 -.0537580
0.5500000 -.0523760
0.6000000 -.0504100
0.6250000 -.0491980
0.6500000 -.0478240
0.6750000 -.0462810
0.7000000 -.0445560
0.7250000 -.0426350
0.7500000 -.0404990
0.7750000 -.0381270
0.8000000 -.0354920
0.8250000 -.0325640
0.8500000 -.0293060
0.8750000 -.0256760
0.9000000 -.0216250
0.9250000 -.0170990
0.9500000 -.0120340
0.9750000 -.0063610
1.0000000 0.0000000

121
Matlab code/strut/profoil.xy Executable file
View File

@@ -0,0 +1,121 @@
1.000000000000000000 .000000000000000000
.998777486086680500 .000039128734319942
.995149957201797900 .000299711123091620
.989223412000951500 .000970050932764146
.981145670975447400 .002191944459643063
.971086173541115400 .004058131322947883
.959218271065854100 .006616851929127301
.945706851119262500 .009881834306856888
.930700273461090700 .013843493660014540
.914325006657736200 .018490106396244770
.896712202983196000 .023831183551336430
.878031579617458700 .029870359503535860
.858469985253515600 .036571096694192990
.838207410107304000 .043866397021870910
.817417182035262800 .051666396180680990
.796262725420542100 .059858757685190970
.774895277507216700 .068310658901039420
.753451484645534000 .076868732703536020
.732051524265323200 .085358173538330990
.710796631329745400 .093576839857823130
.689766787023759400 .101284440285054700
.669021789514310700 .108004130409690200
.647984505083075700 .113517558583694500
.626209753346901800 .118160978748600900
.603906937326857100 .122183989186028700
.581174458182988900 .125643551228927200
.558085325789258000 .128571298857894900
.534708385904846900 .130995982227475800
.511125153673589700 .132936634797773900
.487414917632911500 .134395393258587100
.463636942159360800 .135372544946359500
.439849646582566200 .135880924872991600
.416129229529416800 .135932324935261500
.392551604725222700 .135523839972135600
.369169924983092400 .134652210372689700
.346035451945036500 .133331029810853700
.323220217914391800 .131575843856679300
.300797046657626900 .129386347101403700
.278812453307359000 .126760721548801400
.257309179976361900 .123717036224272600
.236353559973413300 .120277956367501000
.216014161654179800 .116448525272583100
.196329554560218300 .112229851320313100
.177332029646007900 .107645700117241500
.159080386059838400 .102727725529926800
.141637945695737200 .097488150841075400
.125034496189223100 .091931510154726490
.109290253339481500 .086087704486253860
.094454976917392910 .079999204540625310
.080586667085654870 .073687741829588080
.067707008469758520 .067161789240575750
.055823753574367530 .060457858461761200
.044977281751047430 .053632340809673470
.035222563429941790 .046721462576666080
.026578369204382610 .039740223071008730
.019044521471932470 .032734528562300090
.012657486477428590 .025783468434054890
.007479235811376661 .018955265852321320
.003562052994489084 .012298802928596600
.000960867432208801 .005899665413544174
.000000000000000000 -.000000000000782577
.000960867432658108 -.005899665415042383
.003562052995440102 -.012298802929920450
.007479235812865470 -.018955265853393500
.012657486479490610 -.025783468434806120
.019044521474602230 -.032734528562669890
.026578369207690860 -.039740223070943440
.035222563433915280 -.046721462576115150
.044977281755714470 -.053632340808588400
.055823753579757880 -.060457858460098970
.067707008475899390 -.067161789238299510
.080586667092570670 -.073687741826664210
.094454976925108960 -.079999204537022460
.109290253348024500 -.086087704481945620
.125034496198618000 -.091931510149692600
.141637945706006300 -.097488150835299620
.159080386071004300 -.102727725523395900
.177332029658094500 -.107645700109947200
.196329554573247400 -.112229851312253600
.216014161668171400 -.116448525263761400
.236353559988387900 -.120277956357923900
.257309179992340000 -.123717036213952500
.278812453324360100 -.126760721537757600
.300797046675668400 -.129386347089661000
.323220217933491400 -.131575843844267600
.346035451965212900 -.133331029797809100
.369169925004362300 -.134652210359056000
.392551604747601900 -.135523839957963200
.416129229552922000 -.135932324920607600
.439849646607214700 -.135880924857921400
.463636942185169900 -.135372544930947900
.487414917659898500 -.134395393242918100
.511125153701774000 -.132936634781941800
.534708385934251100 -.130995982211587800
.558085325819907400 -.128571298842073600
.581174458214914100 -.125643551213313200
.603906937360098000 -.122183989170786900
.626209753381513200 -.118160978733930500
.647984505119135800 -.113517558569847300
.669021789552016100 -.108004130397079200
.689766787063014900 -.101284440274386000
.710796631370007800 -.093576839849761590
.732051524305964800 -.085358173533257910
.753451484685878400 -.076868732701677340
.774895277546564200 -.068310658902473520
.796262725458194400 -.059858757689853240
.817417182070549100 -.051666396188368860
.838207410139606300 -.043866397032250560
.858469985282292200 -.036571096706810770
.878031579642266200 -.029870359517829740
.896712203003706900 -.023831183566654460
.914325006673737600 -.018490106411837240
.930700273472570900 -.013843493674984400
.945706851126577300 -.009881834320268800
.959218271069722000 -.006616851940244741
.971086173542466100 -.004058131331368275
.981145670975267700 -.002191944465334945
.989223412000137400 -.000970050936046449
.995149957201033200 -.000299711124549478
.998777486086403700 -.000039128734678850
.999999999999999800 .000000000000000049

69
Matlab code/strut/readme.txt Executable file
View File

@@ -0,0 +1,69 @@
**********************************************************************
STRUT
**********************************************************************
Using the strut fitting program
-------------------------------
Make sure that all the .m files are in the same directory. Your
airfoil coordinate files do not have to be in the same directory.
Make sure that the first line in the airfoil coordinate file is not
the name of the airfoil, i.e. only numbers are allowed in the file.
Also make sure the coordinates are sorted TE-LE-TE and that the
leading edge point (usually 0,0) is not repeated. This is important,
since it is easy to forget to remove the extra point if you sorted the
coordinates with a spreadsheet such as MS Excel.
Start Matlab.
Change the directory to the directory with the .m files. Use the "cd"
command in Matlab to do this.
Run the GUI by typing "strut".
Now you can load an airfoil by clicking on the "load" button. Simply
choose the file. After loading the filename of the current airfoil,
the name of the filename will appear in the box below the "load"
button.
The size of the strut can be changed by changing the values for
"length" and "width". "Length" is the distance in the chordwise
direction. Units do not matter. You can also change the default
values by editing the "default.dat" text file.
Click on "calculate", wait a couple of seconds and the information for
the fitted airfoil should appear in the three remaining boxes. The
values are:
scale - How much you must enlarge the airfoil to fit over the box.
xLE% - Chord percentage where the leading edge of the strut is located.
xLE - Actual distance from the LE of the airfoil to the LE of the
strut.
Notes:
------
The program will not converge for low aspect ratio struts in very thin
airfoils. It should however work for all practical cases for the AE
416 homework assignment.
**********************************************************************
Development Notes
**********************************************************************
1) Matlab program for sizing airfoils to fit over a rectangular
strut written Sept 1999 by
B.A. Broughton
Graduate Student
Applied Aerodynamics Group
Dept. of Aerospace Engineering
University of Illinois at Urbana-Champaign
2) Minor fixes/updates/changes by Selig 090925
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

7
Matlab code/strut/reversefit.m Executable file
View File

@@ -0,0 +1,7 @@
function theta=reversefit(P,y,theta0);
TOL=1e-8;
F='Func1(x,P,y)';
FP='FFunc1(x,P)';
theta=Newton(F,FP,theta0,y,P,TOL);

194
Matlab code/strut/strut.m Executable file
View File

@@ -0,0 +1,194 @@
function fig = strut()
% This is the machine-generated representation of a Handle Graphics object
% and its children. Note that handle values may change when these objects
% are re-created. This may cause problems with any callbacks written to
% depend on the value of the handle at the time the object was saved.
% This problem is solved by saving the output as a FIG-file.
%
% To reopen this object, just type the name of the M-file at the MATLAB
% prompt. The M-file and its associated MAT-file must be on your path.
%
% NOTE: certain newer features in MATLAB may not have been saved in this
% M-file due to limitations of this format, which has been superseded by
% FIG-files. Figures which have been annotated using the plot editor tools
% are incompatible with the M-file/MAT-file format, and should be saved as
% FIG-files.
load strut
h0 = figure('Color',[0.8 0.8 0.8], ...
'Colormap',mat0, ...
'FileName','strut.m', ...
'PaperPosition',[18 180 576 432], ...
'PaperUnits','points', ...
'Position',[392 219 560 420], ...
'Tag','Fig1', ...
'ToolBar','none');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'Callback','strutcall load', ...
'ListboxTop',0, ...
'Position',[356.25 289.5 50.25 15.75], ...
'String','Load Airfoil', ...
'Tag','Pushbutton1');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[341.25 248.25 40 11], ...
'String','Strut Size:', ...
'Style','text', ...
'Tag','StaticText1');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[341.25 228.75 30 11.25], ...
'String','Width', ...
'Style','text', ...
'Tag','StaticText1');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[341.25 208.625 30 11], ...
'String','Length', ...
'Style','text', ...
'Tag','StaticText1');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[377.25 226.5 39.75 15.75], ...
'String','0', ...
'Style','edit', ...
'Tag','width');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[377.25 206.25 39.75 15.75], ...
'String','0', ...
'Style','edit', ...
'Tag','length');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'Callback','strutcall calculate', ...
'ListboxTop',0, ...
'Position',[356.25 177 50.25 15.75], ...
'String','Calculate', ...
'Tag','Pushbutton1');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'ListboxTop',0, ...
'Position',[347.25 133.5 30 11.25], ...
'String','Scale', ...
'Style','text', ...
'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[347.25 88.875 30 11.25], ...
'String','Xle (%)', ...
'Style','text', ...
'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[347.25 44.25 30 11.25], ...
'String','Xle', ...
'Style','text', ...
'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'Enable','off', ...
'ListboxTop',0, ...
'Position',[354.75 114 50.25 15.75], ...
'String','0', ...
'Style','edit', ...
'Tag','scale');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'Enable','off', ...
'ListboxTop',0, ...
'Position',[354.75 69.375 50.25 15.75], ...
'String','0', ...
'Style','edit', ...
'Tag','xlepers');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'Enable','off', ...
'ListboxTop',0, ...
'Position',[354.75 24.75 50.25 15.75], ...
'String','0', ...
'Style','edit', ...
'Tag','xle');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[341.25 152.25 40 12], ...
'String','Results:', ...
'Style','text', ...
'Tag','StaticText3');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'Enable','off', ...
'ListboxTop',0, ...
'Position',[347.25 264.75 66 15.75], ...
'String','None Selected', ...
'Style','edit', ...
'Tag','airfoilname');
h1 = axes('Parent',h0, ...
'Units','pixels', ...
'CameraUpVector',[0 1 0], ...
'CameraUpVectorMode','manual', ...
'Color',[1 1 1], ...
'ColorOrder',mat1, ...
'Position',[34 27 418 386], ...
'Tag','Axes1', ...
'XColor',[0 0 0], ...
'YColor',[0 0 0], ...
'ZColor',[0 0 0]);
h2 = text('Parent',h1, ...
'Color',[0 0 0], ...
'HandleVisibility','off', ...
'HorizontalAlignment','center', ...
'Position',[0.4988009592326139 -0.06233766233766236 9.160254037844386], ...
'Tag','Axes1Text4', ...
'VerticalAlignment','cap');
set(get(h2,'Parent'),'XLabel',h2);
h2 = text('Parent',h1, ...
'Color',[0 0 0], ...
'HandleVisibility','off', ...
'HorizontalAlignment','center', ...
'Position',[-0.06954436450839328 0.4961038961038962 9.160254037844386], ...
'Rotation',90, ...
'Tag','Axes1Text3', ...
'VerticalAlignment','baseline');
set(get(h2,'Parent'),'YLabel',h2);
h2 = text('Parent',h1, ...
'Color',[0 0 0], ...
'HandleVisibility','off', ...
'HorizontalAlignment','right', ...
'Position',[-0.0815347721822542 1.018181818181818 9.160254037844386], ...
'Tag','Axes1Text2', ...
'Visible','off');
set(get(h2,'Parent'),'ZLabel',h2);
h2 = text('Parent',h1, ...
'Color',[0 0 0], ...
'HandleVisibility','off', ...
'HorizontalAlignment','center', ...
'Position',[0.4988009592326139 1.018181818181818 9.160254037844386], ...
'Tag','Axes1Text1', ...
'VerticalAlignment','bottom');
set(get(h2,'Parent'),'Title',h2);
if nargout > 0, fig = h0; end

BIN
Matlab code/strut/strut.mat Executable file

Binary file not shown.

BIN
Matlab code/strut/strutWindow.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

110
Matlab code/strut/strutcall.m Executable file
View File

@@ -0,0 +1,110 @@
function strutcall(action)
global x y tmax
% Remove
global P
switch(action)
case 'load'
% Read Input Data
[fname,pname] = uigetfile('*.*','File containing airfoil co-ordinates');
if fname == 0
return;
end
dot=find(fname=='.');
oldpath = pwd;
eval(['cd ' pname]);
data = load(fname);
eval(['cd ' oldpath]);
x = data(:,1);
y = data(:,2);
txtHndl=findobj(gcbf,'Tag','airfoilname');
set(txtHndl,'String',fname(1:dot-1));
plot(x,y); axis([0 1 -.5 .5]);
% Load default strut size
fid=fopen('default.dat','r');
fgetl(fid);
lstrut=eval(fgetl(fid));
fgetl(fid);
wstrut=eval(fgetl(fid));
fclose(fid);
txtHndl=findobj(gcbf,'Tag','length');
set(txtHndl,'String',num2str(lstrut));
txtHndl=findobj(gcbf,'Tag','width');
set(txtHndl,'String',num2str(wstrut));
case 'calculate'
global x y
delt=1e-7; % Used for calculating dF/dt
TOL=1e-6; % Tolerance for N-R iteration
N = length(x);
c = max(x)-min(x);
x1 = x-c/2;
r = sqrt(x1.^2+y.^2);
theta = acos(x1./r);
% Use a continues theta
theta((N+1)/2:N)=2*pi-theta((N+1)/2:N);
P = spline(theta,r); % Fit cubic spline in polar coords
txtHndl=findobj(gcbf,'Tag','length');
lstrut=eval(get(txtHndl,'String'));
txtHndl=findobj(gcbf,'Tag','width');
tstrut=eval(get(txtHndl,'String'));
ARrqd=lstrut/tstrut; % AR of strut
[tmax,I]=max(y); % Approx. max thickness
tmax=tmax*2;
t0=tmax/2; % Start with tmax/2
F='ARfit(P,x)-y'; % For sol. F=AR(t)-ARrqd=0
FP=['(ARfit(P,x+' num2str(delt) ')-(ARfit(P,x)))/' num2str(delt)];
% Derivative: F'=(F(t+dt)-F(t))/dt
tnew=Newton(F,FP,t0,ARrqd,P,TOL);
% Find size of strut that will fit in norm. airfoil
[AR,xLEnew]=ARfit(P,tnew);
% Scale
scale = tstrut/tnew;
chord=scale*c;
xLEnewnorm = xLEnew+c/2;
xLEnew = xLEnewnorm*scale;
x1=x*scale;
y1=y*scale;
% Plotit
c1x=xLEnew; cy=tstrut/2;
c2x=xLEnew+lstrut;
strx=[c1x c2x c2x c1x c1x];
stry=[cy cy -cy -cy cy];
plot(x1,y1,'b',strx,stry,'r');
axis([0 chord -chord/2 chord/2]);
txtHndl=findobj(gcbf,'Tag','scale');
set(txtHndl,'String',num2str(scale));
txtHndl=findobj(gcbf,'Tag','xlepers');
set(txtHndl,'String',num2str(xLEnewnorm*100));
txtHndl=findobj(gcbf,'Tag','xle');
set(txtHndl,'String',num2str(xLEnew));
end;

View File

@@ -0,0 +1,110 @@
function strutcall(action)
global x y tmax
% Remove
global P
switch(action)
case 'load'
% Read Input Data
[fname,pname] = uigetfile('*.dat','File containing airfoil co-ordinates');
if fname == 0
return;
end
dot=find(fname=='.');
oldpath = pwd;
eval(['cd ' pname]);
data = load(fname);
eval(['cd ' pwd]);
x = data(:,1);
y = data(:,2);
txtHndl=findobj(gcbf,'Tag','airfoilname');
set(txtHndl,'String',fname(1:dot-1));
plot(x,y); axis([0 1 -.5 .5]);
% Load default strut size
fid=fopen('default.dat','r');
fgetl(fid);
lstrut=eval(fgetl(fid));
fgetl(fid);
wstrut=eval(fgetl(fid));
fclose(fid);
txtHndl=findobj(gcbf,'Tag','length');
set(txtHndl,'String',num2str(lstrut));
txtHndl=findobj(gcbf,'Tag','width');
set(txtHndl,'String',num2str(wstrut));
case 'calculate'
global x y
delt=1e-7; % Used for calculating dF/dt
TOL=1e-6; % Tolerance for N-R iteration
N = length(x);
c = max(x)-min(x);
x1 = x-c/2;
r = sqrt(x1.^2+y.^2);
theta = acos(x1./r);
% Use a continues theta
theta((N+1)/2:N)=2*pi-theta((N+1)/2:N);
P = spline(theta,r); % Fit cubic spline in polar coords
txtHndl=findobj(gcbf,'Tag','length');
lstrut=eval(get(txtHndl,'String'));
txtHndl=findobj(gcbf,'Tag','width');
tstrut=eval(get(txtHndl,'String'));
ARrqd=lstrut/tstrut; % AR of strut
[tmax,I]=max(y); % Approx. max thickness
tmax=tmax*2;
t0=tmax/2; % Start with tmax/2
F='ARfit(P,x)-y'; % For sol. F=AR(t)-ARrqd=0
FP=['(ARfit(P,x+' num2str(delt) ')-(ARfit(P,x)))/' num2str(delt)];
% Derivative: F'=(F(t+dt)-F(t))/dt
tnew=Newton(F,FP,t0,ARrqd,P,TOL);
% Find size of strut that will fit in norm. airfoil
[AR,xLEnew]=ARfit(P,tnew);
% Scale
scale = tstrut/tnew;
chord=scale*c;
xLEnewnorm = xLEnew+c/2;
xLEnew = xLEnewnorm*scale;
x1=x*scale;
y1=y*scale;
% Plotit
c1x=xLEnew; cy=tstrut/2;
c2x=xLEnew+lstrut;
strx=[c1x c2x c2x c1x c1x];
stry=[cy cy -cy -cy cy];
plot(x1,y1,'b',strx,stry,'r');
axis([0 chord -chord/2 chord/2]);
txtHndl=findobj(gcbf,'Tag','scale');
set(txtHndl,'String',num2str(scale));
txtHndl=findobj(gcbf,'Tag','xlepers');
set(txtHndl,'String',num2str(xLEnewnorm*100));
txtHndl=findobj(gcbf,'Tag','xle');
set(txtHndl,'String',num2str(xLEnew));
end;

208
Matlab code/strut/strutfit.m Executable file
View File

@@ -0,0 +1,208 @@
function fig = strut()
% This is the machine-generated representation of a Handle Graphics object
% and its children. Note that handle values may change when these objects
% are re-created. This may cause problems with any callbacks written to
% depend on the value of the handle at the time the object was saved.
% This problem is solved by saving the output as a FIG-file.
%
% To reopen this object, just type the name of the M-file at the MATLAB
% prompt. The M-file and its associated MAT-file must be on your path.
%
% NOTE: certain newer features in MATLAB may not have been saved in this
% M-file due to limitations of this format, which has been superseded by
% FIG-files. Figures which have been annotated using the plot editor tools
% are incompatible with the M-file/MAT-file format, and should be saved as
% FIG-files.
load strut
h0 = figure('Color',[0.8 0.8 0.8], ...
'Colormap',mat0, ...
'FileName','strutfit.m', ...
'MenuBar','none', ...
'PaperPosition',[18 180 576 432], ...
'PaperUnits','points', ...
'Position',[392 219 560 420], ...
'Tag','Fig1', ...
'ToolBar','none', ...
'NumberTitle','off', ...
'Name','Strutfit');
h1 = uimenu('Parent',h0, ...
'Label','Help', ...
'Tag','uimenu1');
h2 = uimenu('Parent',h1, ...
'Callback','edit readme.txt', ...
'Label','Readme', ...
'Tag','Helpuimenu1');
h2 = uimenu('Parent',h1, ...
'Callback','edit about.txt', ...
'Label','About Strutfit', ...
'Tag','Aboutuimenu1');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'Callback','strutcall load', ...
'ListboxTop',0, ...
'Position',[356.25 289.5 50.25 15.75], ...
'String','Load Airfoil', ...
'Tag','Pushbutton1');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[341.25 248.25 40 11], ...
'String','Strut Size:', ...
'Style','text', ...
'Tag','StaticText1');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[341.25 228.75 30 11.25], ...
'String','Width', ...
'Style','text', ...
'Tag','StaticText1');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[341.25 208.625 30 11], ...
'String','Length', ...
'Style','text', ...
'Tag','StaticText1');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[377.25 226.5 39.75 15.75], ...
'String','0', ...
'Style','edit', ...
'Tag','width');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[377.25 206.25 39.75 15.75], ...
'String','0', ...
'Style','edit', ...
'Tag','length');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'Callback','strutcall calculate', ...
'ListboxTop',0, ...
'Position',[356.25 177 50.25 15.75], ...
'String','Calculate', ...
'Tag','Pushbutton1');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'ListboxTop',0, ...
'Position',[347.25 133.5 30 11.25], ...
'String','Scale', ...
'Style','text', ...
'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[347.25 88.875 30 11.25], ...
'String','Xle (%)', ...
'Style','text', ...
'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[347.25 44.25 30 11.25], ...
'String','Xle', ...
'Style','text', ...
'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'Enable','off', ...
'ListboxTop',0, ...
'Position',[354.75 114 50.25 15.75], ...
'String','0', ...
'Style','edit', ...
'Tag','scale');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'Enable','off', ...
'ListboxTop',0, ...
'Position',[354.75 69.375 50.25 15.75], ...
'String','0', ...
'Style','edit', ...
'Tag','xlepers');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'Enable','off', ...
'ListboxTop',0, ...
'Position',[354.75 24.75 50.25 15.75], ...
'String','0', ...
'Style','edit', ...
'Tag','xle');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[341.25 152.25 40 12], ...
'String','Results:', ...
'Style','text', ...
'Tag','StaticText3');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'Enable','off', ...
'ListboxTop',0, ...
'Position',[347.25 264.75 66 15.75], ...
'String','None Selected', ...
'Style','edit', ...
'Tag','airfoilname');
h1 = axes('Parent',h0, ...
'Units','pixels', ...
'CameraUpVector',[0 1 0], ...
'CameraUpVectorMode','manual', ...
'Color',[1 1 1], ...
'ColorOrder',mat1, ...
'Position',[34 27 418 386], ...
'Tag','Axes1', ...
'XColor',[0 0 0], ...
'YColor',[0 0 0], ...
'ZColor',[0 0 0]);
h2 = text('Parent',h1, ...
'Color',[0 0 0], ...
'HandleVisibility','off', ...
'HorizontalAlignment','center', ...
'Position',[0.4988009592326139 -0.06233766233766236 9.160254037844386], ...
'Tag','Axes1Text4', ...
'VerticalAlignment','cap');
set(get(h2,'Parent'),'XLabel',h2);
h2 = text('Parent',h1, ...
'Color',[0 0 0], ...
'HandleVisibility','off', ...
'HorizontalAlignment','center', ...
'Position',[-0.06954436450839328 0.4961038961038962 9.160254037844386], ...
'Rotation',90, ...
'Tag','Axes1Text3', ...
'VerticalAlignment','baseline');
set(get(h2,'Parent'),'YLabel',h2);
h2 = text('Parent',h1, ...
'Color',[0 0 0], ...
'HandleVisibility','off', ...
'HorizontalAlignment','right', ...
'Position',[-0.0815347721822542 1.018181818181818 9.160254037844386], ...
'Tag','Axes1Text2', ...
'Visible','off');
set(get(h2,'Parent'),'ZLabel',h2);
h2 = text('Parent',h1, ...
'Color',[0 0 0], ...
'HandleVisibility','off', ...
'HorizontalAlignment','center', ...
'Position',[0.4988009592326139 1.018181818181818 9.160254037844386], ...
'Tag','Axes1Text1', ...
'VerticalAlignment','bottom');
set(get(h2,'Parent'),'Title',h2);
if nargout > 0, fig = h0; end

451
Matlab code/superGrimace.m Executable file
View File

@@ -0,0 +1,451 @@
%superGrimace
%all alfas in DEGREES!
%by ascorrea, with help from Jacob Huffman and Omkar Shetty
%"filler" variable just makes it easier to switch between Ronald and Grimace
function superGrimace(paramfile, pranformfile, pranformConstraint)
testrange={'20'};
for testnumber=1:length(testrange)
prefix='FDR0';
name=strcat(prefix, testrange{testnumber});
paramfile=strcat(name, '.param');
pranformfile=strcat(name, '.plan', '');
fprintf('%s \n', name)
%LOCATIONS--------------------------------------------------------------]
rootLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Matlab Code';
airfoilLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Airfoils';
pranformLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Planforms';
pranformConstraintLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Planform Constraints';
paramLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Parameter Files';
outputsLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/superGrimace Outputs';
%-----------------------------------------------------------------------]
spanwiseresolution=50;
chordwiseresolution=100;
cd(paramLOCATION);
[variablenames, variablevalues]=textread(paramfile, '%s %f');
cd(pranformLOCATION)
[spans, chords, offsets, airfoil]=textread(pranformfile, '%f %f %f %s');
cd(pranformConstraintLOCATION)
[spansCONST, chordsCONST, offsetsCONST, heightCONST]=textread(pranformConstraint, '%f %f %f %f');
cd(rootLOCATION)
for k = 1:length(variablenames)
eval([variablenames{k} '= variablevalues(k);']);
end
cd(airfoilLOCATION)
[surfplotY surfplotX thicknessplot]=findthicknessplot(airfoil, chords, spans, offsets, spanwiseresolution, chordwiseresolution);
[wakeplot]=findwakeplot(chords, spans, alt_cruise, M_cruise, laminarflow_cruise, fuse_width, spanwiseresolution, chordwiseresolution);
plotitle=regexprep(pranformfile, '.plan', '');
cd(outputsLOCATION)
% clf
% hold on
% surf(surfplotY, -surfplotX, thicknessplot, 'LineStyle', 'none')
% surf(-surfplotY,-surfplotX, thicknessplot, 'LineStyle', 'none')
% title(plotitle)
% axis off
% axis equal
% colorbar
% view(2)
% filename=regexprep(pranformfile, '.plan', '_surfacev1.tiff');
% print (gcf, '-dtiff', filename)
% clf
% hold on
% surf(surfplotY, surfplotX, thicknessplot, 'LineStyle', 'none')
% surf(-surfplotY, surfplotX, thicknessplot, 'LineStyle', 'none')
% axis equal
% axis off
% colorbar
% view(3)
% title(plotitle)
% filename=regexprep(pranformfile, '.plan', '_surfacev2.tiff');
% print (gcf, '-dtiff', filename)
clf
hold on
surf(surfplotY, -surfplotX, wakeplot, 'LineStyle', 'none')
surf(-surfplotY,-surfplotX, wakeplot, 'LineStyle', 'none')
title(plotitle)
axis off
axis equal
colorbar
view(2)
filename=regexprep(pranformfile, '.plan', '_BLthicknessv1.tiff');
print (gcf, '-dtiff', filename)
clf
hold on
surf(-surfplotY, -surfplotX, wakeplot, 'LineStyle', 'none')
surf(-surfplotY, -surfplotX, wakeplot, 'LineStyle', 'none')
axis off
axis([-80 80 -160 0 0 1])
colorbar
view(3)
title(plotitle)
filename=regexprep(pranformfile, '.plan', '_BLthicknessv2.tiff');
print (gcf, '-dtiff', filename)
axis equal
axis off
hold off
cd(rootLOCATION)
end
clc
fprintf('You are welcome\n')
end
function [plotLE plotTE]=plotpranform(spans, chords, offsets, n)
Chords = findChords(n, chords, spans);
%plot planform
for i = 1:(size(chords)-1)
dist=0;
for j = 1:n
dist = (spans(i+1)-spans(i))./n;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
fitX(1)=spans(i);
fitX(2)=spans(i+1);
fitY(1)=offsets(i);
fitY(2)=offsets(i+1);
a = polyfit(fitX, fitY,1);
yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
end
end
plotLE=zeros(1,2);
plotTE=zeros(1,2);
for i=1:(size(chords)-1)
for j=1:n
plotLE=[plotLE; xplotLE(i,j) -yplotLE(i,j)];
plotTE=[plotTE; xplotLE(i,j) -(yplotLE(i,j)+Chords(i,j))];
end
end
plotTE(1,:)=[];
plotLE(1,:)=[];
end
function [plotLE plotTE]=plotconstraint(spans, chords, offsets, n)
%plot constraint
for i = 1:(size(chords)-1)
for j = 1:n
dist = (spans(i+1)-spans(i))./n;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
yplotLE(i,j) = offsets(i+1);
end
end
plotLE=zeros(1,2);
plotTE=zeros(1,2);
for i=1:(size(chords)-1)
for j=1:n
plotLE=[plotLE; xplotLE(i,j) -yplotLE(i,j)];
plotTE=[plotTE; xplotLE(i,j) (-yplotLE(i,j)-chords(i+1))];
end
end
plotTE(1,:)=[];
plotLE(1,:)=[];
end
function plotThick=plotThick(spans, chords, offsets, airfoil, h, n)
n=n/10;
Chords = findChords(n, chords, spans);
plotThickLE=zeros(1,2);
plotThickTE=zeros(1,2);
for i = 1:(size(chords)-1)
for j = 1:n
Chords(i,j);
dist = (spans(i+1)-spans(i))./n;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
fitX(1)=spans(i);
fitX(2)=spans(i+1);
fitY(1)=offsets(i);
fitY(2)=offsets(i+1);
a = polyfit(fitX, fitY,1);
yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
chordloc=linspace(0, Chords(i,j));
for k=1:length(chordloc)-1
thicknessLE(k)=findthickness(airfoil{i}, Chords(i,j), chordloc(k));
clc
fprintf('%g:%u:%u:%u/%g:%u:%u:%u',h,i,j,k,h,(length(chords)-1),n,(length(chordloc)-1))
if thicknessLE(k)>=h
plotThickLE=[plotThickLE; xplotLE(i,j) -(chordloc(k)+yplotLE(i,j))];
break
end
end
for k=1:length(chordloc)-1
thicknessTE(k)=findthickness(airfoil{i}, Chords(i,j), chordloc(length(chordloc)-k));
if thicknessTE(k)>=h
plotThickTE=[plotThickTE; xplotLE(i,j) -(chordloc(length(chordloc)-k)+yplotLE(i,j))];
break
end
end
end
end
plotLE=zeros(1,2);
plotTE=zeros(1,2);
for i=1:(size(chords)-1)
for j=1:n
plotLE=[plotLE; xplotLE(i,j) -yplotLE(i,j)];
plotTE=[plotTE; xplotLE(i,j) -(yplotLE(i,j)+Chords(i,j))];
end
end
plotTE(1,:)=[];
plotLE(1,:)=[];
plotThickLE(1,:)=[];
plotThickTE(1,:)=[];
plotThick=[plotThickLE; flipud(plotThickTE)];
end
function thickness=findthickness(airfoil, Chord, xLoc)
Airfoil = load(airfoil);
Airfoil = Airfoil*Chord;
% blah....goodnight
AirfoilX=Airfoil(:,1);
[min_diff, k]=min(abs(AirfoilX));
for j=1:k
AirfoilYupper(j)=Airfoil(j,2);
AirfoilXupper(j)=Airfoil(j,1);
end
for j=1:length(Airfoil)-k
AirfoilYlower(j)=Airfoil(length(Airfoil)-(j-1), 2);
AirfoilXlower(j)=Airfoil(length(Airfoil)-(j-1), 1);
end
AirfoilYupper=fliplr(AirfoilYupper);
AirfoilXupper=fliplr(AirfoilXupper);
AirfoilYlower=fliplr(AirfoilYlower);
AirfoilXlower=fliplr(AirfoilXlower);
AirfoilYlower=[0 AirfoilYlower];
AirfoilXlower=[0 AirfoilXlower];
[min_diff, k]=min(abs(AirfoilX));
[min_diff, kU]=min(abs(AirfoilXupper-xLoc));
[min_diff, kL]=min(abs(AirfoilXlower-xLoc));
if xLoc<AirfoilXupper(kU)
xFitU(1)=AirfoilXupper(kU-1);
xFitU(2)=AirfoilXupper(kU);
yFitU(1)=AirfoilYupper(kU-1);
yFitU(2)=AirfoilYupper(kU);
else
xFitU(1)=AirfoilXupper(kU);
xFitU(2)=AirfoilXupper(kU+1);
yFitU(1)=AirfoilYupper(kU);
yFitU(2)=AirfoilYupper(kU+1);
end
if xLoc<AirfoilXlower(kL)
xFitL(1)=AirfoilXlower(kL-1);
xFitL(2)=AirfoilXlower(kL);
yFitL(1)=AirfoilYlower(kL-1);
yFitL(2)=AirfoilYlower(kL);
else
xFitL(1)=AirfoilXlower(kL);
xFitL(2)=AirfoilXlower(kL+1);
yFitL(1)=AirfoilYlower(kL);
yFitL(2)=AirfoilYlower(kL+1);
end
aU = polyfit(xFitU, yFitU,1);
aL = polyfit(xFitL, yFitL,1);
% yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
% thickness = AirfoilYupper(xLoc_indu)-AirfoilYlower(xLoc_indl);
thickness = (aU(1)*xLoc+aU(2))-(aL(1)*xLoc+aL(2));
end
function Chords = findChords( n, Chord, X )
for( i = 1:(length(Chord)-1) )
Xtemp = linspace(X(i),X(i+1),n);
Chords(i,:) = (Chord(i+1)-Chord(i))./(X(i+1)-X(i)).*(Xtemp-X(i))+Chord(i);
end
end
function [plotY plotX thicknessplot]=findthicknessplot(airfoil, chords, spans, offsets, n, reso)
Chords = findChords(n, chords, spans);
thicknessplot=zeros(reso-1,1);
plotX=zeros(reso-1,1);
plotY=zeros(reso-1,1);
jcount=0;
for i=1:(size(chords)-1)
for j = 1:n
% wakecoord(j,:)=linspace(0, Chords(i,j), n);
dist = (spans(i+1)-spans(i))./n;
y(j)=spans(i)+j*dist;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
fitX(1)=spans(i);
fitX(2)=spans(i+1);
fitY(1)=offsets(i);
fitY(2)=offsets(i+1);
a = polyfit(fitX, fitY,1);
yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
x=linspace(0, Chords(i,j),reso);
for k = 1:length(x)-1
%
% thickness(k,j)=findthickness(airfoil{i}, Chords(i,j), x(k));
end
wakeX(k,j)=x(k)+yplotLE(i,j);
wakeY(k,j)=y(j);
for k = 1:length(x)-1
wakeX(k,j)=x(k)+yplotLE(i,j);
wakeY(k,j)=y(j);
end
% thicknessplot=[thicknessplot, thickness];
plotX=[plotX, wakeX];
plotY=[plotY, wakeY];
end
fprintf('Thickness plot: %6.2f percent complete\n', 100*(i+.1*j)/((length(chords)-1)+ n*.1))
end
thicknessplot(:,1)=[ ];
plotX(:,1)=[ ];
plotY(:,1)=[ ];
flipud(thicknessplot);
end
function [q v_fps dynvisc]=findconstants(alt, v_mach)
if alt < 36152
temp=59-.00356*alt;
press=2116*((temp+459.7)/518.6)^5.256;
elseif alt < 82345
temp=-70;
press=473.1*exp(1.73-.000048*alt);
else
print('Program Not Valid for given altitude')
end
%slpcuft: clugs ber cubic foot
density_slpcuft=press/(1718*(temp+459.7));
v_fps=v_mach*sqrt(1.4*1718*(temp+459.7));
q=finddynpress(alt, v_mach);
S = 110.4;
beta = 1.458e-6;
temp_k=[(temp-32) / (1.8)] + 273 ;
viscosity_pascalseconds = (beta*temp_k^(1.5))/(temp_k+S);
%kgpmcu:kilograms per meter cubed
%msqpse:meters squared per second
%sqftpsec:square feet per second
density_kgpmcu=density_slpcuft*515.4;
dynamic_viscosity_msqpsec=viscosity_pascalseconds/density_kgpmcu;
dynamic_viscosity_sqftpsec=dynamic_viscosity_msqpsec*10.76;
dynvisc=dynamic_viscosity_sqftpsec;
density=density_slpcuft;
end
function [wakeplot]=findwakeplot(chords, spans, alt, v_mach, laminarflow, width, n, reso)
[q v_fps dynvisc]=findconstants(alt, v_mach);
Chords = findChords(n, chords, spans);
wakeplot=zeros(reso,1);
width=width/2;
for i=1:1:(size(chords)-1)
dist=(spans(i+1)-spans(i))/n;
for j = 1:n
if (spans(i)+dist*j)>width
lam=laminarflow;
else
lam=laminarflow-.15;
end
x=linspace(0, Chords(i,j),reso);
for k = 1:length(x)
if (k <= 100*lam)
delta_x=( 5.2 * x(k) )*(v_fps*x(k)/dynvisc)^-0.5;
wake(k,j)= delta_x;
else %if turbulent
x_tr=x(100*lam);
Re_xtr = v_fps * x_tr / dynvisc;
delta_xtr=(5.2*x_tr)*(v_fps*x(k)/dynvisc)^-(0.5);
delta_l = ((delta_xtr*((v_fps)^0.2))/(0.37*((dynvisc)^0.2)))^(1/0.8);
lt = x(k) - x_tr + delta_l;
Re_lt = v_fps * lt / dynvisc;
delta = 0.37 * lt /(Re_lt)^0.2;
wake(k,j) = delta;
end
end
wakeplot=[wakeplot, wake];
end
fprintf('Wake plot: %6.2f percent complete\n', 100*(i+.1*j)/((length(chords)-1)+ n*.1))
end
wakeplot(1,:)=[];
wakeplot(:,1)=[ ];
flipud(wakeplot);
end
function q=finddynpress(alt, v_mach)
if alt < 36152
temp=59-.00356*alt;
press=2116*((temp+459.7)/518.6)^5.256;
elseif alt < 82345
temp=-70;
press=473.1*exp(1.73-.000048*alt);
else
print('Program Not Valid for given altitude')
end
%slpcuft: clugs ber cubic foot
density_slpcuft=press/(1718*(temp+459.7));
v_fps=v_mach*sqrt(1.4*1718*(temp+459.7));
q=.5*density_slpcuft*v_fps^2;
end

450
Matlab code/superGrimace.m~ Executable file
View File

@@ -0,0 +1,450 @@
%superGrimace
%all alfas in DEGREES!
%by ascorrea, with help from Jacob Huffman and Omkar Shetty
%"filler" variable just makes it easier to switch between Ronald and Grimace
function superGrimace(paramfile, pranformfile, pranformConstraint)
testrange={'20'};
for testnumber=1:length(testrange)
prefix='FDR0';
name=strcat(prefix, testrange{testnumber});
paramfile=strcat(name, '.param');
pranformfile=strcat(name, '.plan', '');
fprintf('%s \n', name)
%LOCATIONS--------------------------------------------------------------]
rootLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Matlab Code';
airfoilLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Airfoils';
pranformLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Planforms';
pranformConstraintLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Planform Constraints';
paramLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/Parameter Files';
outputsLOCATION='/Users/anthonyscorrea/Documents/MATLAB/AE441 - Home Edition/superGrimace Outputs';
%-----------------------------------------------------------------------]
spanwiseresolution=50;
chordwiseresolution=100;
cd(paramLOCATION);
[variablenames, variablevalues]=textread(paramfile, '%s %f');
cd(pranformLOCATION)
[spans, chords, offsets, airfoil]=textread(pranformfile, '%f %f %f %s');
cd(pranformConstraintLOCATION)
[spansCONST, chordsCONST, offsetsCONST, heightCONST]=textread(pranformConstraint, '%f %f %f %f');
cd(rootLOCATION)
for k = 1:length(variablenames)
eval([variablenames{k} '= variablevalues(k);']);
end
cd(airfoilLOCATION)
[surfplotY surfplotX thicknessplot]=findthicknessplot(airfoil, chords, spans, offsets, spanwiseresolution, chordwiseresolution);
[wakeplot]=findwakeplot(chords, spans, alt_cruise, M_cruise, laminarflow_cruise, fuse_width, spanwiseresolution, chordwiseresolution);
plotitle=regexprep(pranformfile, '.plan', '');
cd(outputsLOCATION)
% clf
% hold on
% surf(surfplotY, -surfplotX, thicknessplot, 'LineStyle', 'none')
% surf(-surfplotY,-surfplotX, thicknessplot, 'LineStyle', 'none')
% title(plotitle)
% axis off
% axis equal
% colorbar
% view(2)
% filename=regexprep(pranformfile, '.plan', '_surfacev1.tiff');
% print (gcf, '-dtiff', filename)
% clf
% hold on
% surf(surfplotY, surfplotX, thicknessplot, 'LineStyle', 'none')
% surf(-surfplotY, surfplotX, thicknessplot, 'LineStyle', 'none')
% axis equal
% axis off
% colorbar
% view(3)
% title(plotitle)
% filename=regexprep(pranformfile, '.plan', '_surfacev2.tiff');
% print (gcf, '-dtiff', filename)
clf
hold on
surf(surfplotY, -surfplotX, wakeplot, 'LineStyle', 'none')
surf(-surfplotY,-surfplotX, wakeplot, 'LineStyle', 'none')
title(plotitle)
axis off
axis equal
colorbar
view(2)
filename=regexprep(pranformfile, '.plan', '_BLthicknessv1.tiff');
print (gcf, '-dtiff', filename)
clf
hold on
surf(-surfplotY, -surfplotX, wakeplot, 'LineStyle', 'none')
surf(-surfplotY, -surfplotX, wakeplot, 'LineStyle', 'none')
axis off
colorbar
view(3)
title(plotitle)
filename=regexprep(pranformfile, '.plan', '_BLthicknessv2.tiff');
print (gcf, '-dtiff', filename)
axis equal
axis off
hold off
cd(rootLOCATION)
end
clc
fprintf('You are welcome\n')
end
function [plotLE plotTE]=plotpranform(spans, chords, offsets, n)
Chords = findChords(n, chords, spans);
%plot planform
for i = 1:(size(chords)-1)
dist=0;
for j = 1:n
dist = (spans(i+1)-spans(i))./n;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
fitX(1)=spans(i);
fitX(2)=spans(i+1);
fitY(1)=offsets(i);
fitY(2)=offsets(i+1);
a = polyfit(fitX, fitY,1);
yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
end
end
plotLE=zeros(1,2);
plotTE=zeros(1,2);
for i=1:(size(chords)-1)
for j=1:n
plotLE=[plotLE; xplotLE(i,j) -yplotLE(i,j)];
plotTE=[plotTE; xplotLE(i,j) -(yplotLE(i,j)+Chords(i,j))];
end
end
plotTE(1,:)=[];
plotLE(1,:)=[];
end
function [plotLE plotTE]=plotconstraint(spans, chords, offsets, n)
%plot constraint
for i = 1:(size(chords)-1)
for j = 1:n
dist = (spans(i+1)-spans(i))./n;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
yplotLE(i,j) = offsets(i+1);
end
end
plotLE=zeros(1,2);
plotTE=zeros(1,2);
for i=1:(size(chords)-1)
for j=1:n
plotLE=[plotLE; xplotLE(i,j) -yplotLE(i,j)];
plotTE=[plotTE; xplotLE(i,j) (-yplotLE(i,j)-chords(i+1))];
end
end
plotTE(1,:)=[];
plotLE(1,:)=[];
end
function plotThick=plotThick(spans, chords, offsets, airfoil, h, n)
n=n/10;
Chords = findChords(n, chords, spans);
plotThickLE=zeros(1,2);
plotThickTE=zeros(1,2);
for i = 1:(size(chords)-1)
for j = 1:n
Chords(i,j);
dist = (spans(i+1)-spans(i))./n;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
fitX(1)=spans(i);
fitX(2)=spans(i+1);
fitY(1)=offsets(i);
fitY(2)=offsets(i+1);
a = polyfit(fitX, fitY,1);
yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
chordloc=linspace(0, Chords(i,j));
for k=1:length(chordloc)-1
thicknessLE(k)=findthickness(airfoil{i}, Chords(i,j), chordloc(k));
clc
fprintf('%g:%u:%u:%u/%g:%u:%u:%u',h,i,j,k,h,(length(chords)-1),n,(length(chordloc)-1))
if thicknessLE(k)>=h
plotThickLE=[plotThickLE; xplotLE(i,j) -(chordloc(k)+yplotLE(i,j))];
break
end
end
for k=1:length(chordloc)-1
thicknessTE(k)=findthickness(airfoil{i}, Chords(i,j), chordloc(length(chordloc)-k));
if thicknessTE(k)>=h
plotThickTE=[plotThickTE; xplotLE(i,j) -(chordloc(length(chordloc)-k)+yplotLE(i,j))];
break
end
end
end
end
plotLE=zeros(1,2);
plotTE=zeros(1,2);
for i=1:(size(chords)-1)
for j=1:n
plotLE=[plotLE; xplotLE(i,j) -yplotLE(i,j)];
plotTE=[plotTE; xplotLE(i,j) -(yplotLE(i,j)+Chords(i,j))];
end
end
plotTE(1,:)=[];
plotLE(1,:)=[];
plotThickLE(1,:)=[];
plotThickTE(1,:)=[];
plotThick=[plotThickLE; flipud(plotThickTE)];
end
function thickness=findthickness(airfoil, Chord, xLoc)
Airfoil = load(airfoil);
Airfoil = Airfoil*Chord;
% blah....goodnight
AirfoilX=Airfoil(:,1);
[min_diff, k]=min(abs(AirfoilX));
for j=1:k
AirfoilYupper(j)=Airfoil(j,2);
AirfoilXupper(j)=Airfoil(j,1);
end
for j=1:length(Airfoil)-k
AirfoilYlower(j)=Airfoil(length(Airfoil)-(j-1), 2);
AirfoilXlower(j)=Airfoil(length(Airfoil)-(j-1), 1);
end
AirfoilYupper=fliplr(AirfoilYupper);
AirfoilXupper=fliplr(AirfoilXupper);
AirfoilYlower=fliplr(AirfoilYlower);
AirfoilXlower=fliplr(AirfoilXlower);
AirfoilYlower=[0 AirfoilYlower];
AirfoilXlower=[0 AirfoilXlower];
[min_diff, k]=min(abs(AirfoilX));
[min_diff, kU]=min(abs(AirfoilXupper-xLoc));
[min_diff, kL]=min(abs(AirfoilXlower-xLoc));
if xLoc<AirfoilXupper(kU)
xFitU(1)=AirfoilXupper(kU-1);
xFitU(2)=AirfoilXupper(kU);
yFitU(1)=AirfoilYupper(kU-1);
yFitU(2)=AirfoilYupper(kU);
else
xFitU(1)=AirfoilXupper(kU);
xFitU(2)=AirfoilXupper(kU+1);
yFitU(1)=AirfoilYupper(kU);
yFitU(2)=AirfoilYupper(kU+1);
end
if xLoc<AirfoilXlower(kL)
xFitL(1)=AirfoilXlower(kL-1);
xFitL(2)=AirfoilXlower(kL);
yFitL(1)=AirfoilYlower(kL-1);
yFitL(2)=AirfoilYlower(kL);
else
xFitL(1)=AirfoilXlower(kL);
xFitL(2)=AirfoilXlower(kL+1);
yFitL(1)=AirfoilYlower(kL);
yFitL(2)=AirfoilYlower(kL+1);
end
aU = polyfit(xFitU, yFitU,1);
aL = polyfit(xFitL, yFitL,1);
% yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
% thickness = AirfoilYupper(xLoc_indu)-AirfoilYlower(xLoc_indl);
thickness = (aU(1)*xLoc+aU(2))-(aL(1)*xLoc+aL(2));
end
function Chords = findChords( n, Chord, X )
for( i = 1:(length(Chord)-1) )
Xtemp = linspace(X(i),X(i+1),n);
Chords(i,:) = (Chord(i+1)-Chord(i))./(X(i+1)-X(i)).*(Xtemp-X(i))+Chord(i);
end
end
function [plotY plotX thicknessplot]=findthicknessplot(airfoil, chords, spans, offsets, n, reso)
Chords = findChords(n, chords, spans);
thicknessplot=zeros(reso-1,1);
plotX=zeros(reso-1,1);
plotY=zeros(reso-1,1);
jcount=0;
for i=1:(size(chords)-1)
for j = 1:n
% wakecoord(j,:)=linspace(0, Chords(i,j), n);
dist = (spans(i+1)-spans(i))./n;
y(j)=spans(i)+j*dist;
if i==1
xplotLE(i,j+1)=spans(1)+dist*(j);
else
xplotLE(i,1)=xplotLE(i-1,end);
xplotLE(i,j+1)=xplotLE(i-1,end)+dist*(j);
end
fitX(1)=spans(i);
fitX(2)=spans(i+1);
fitY(1)=offsets(i);
fitY(2)=offsets(i+1);
a = polyfit(fitX, fitY,1);
yplotLE(i,j) = a(1)*xplotLE(i,j)+a(2);
x=linspace(0, Chords(i,j),reso);
for k = 1:length(x)-1
%
% thickness(k,j)=findthickness(airfoil{i}, Chords(i,j), x(k));
end
wakeX(k,j)=x(k)+yplotLE(i,j);
wakeY(k,j)=y(j);
for k = 1:length(x)-1
wakeX(k,j)=x(k)+yplotLE(i,j);
wakeY(k,j)=y(j);
end
% thicknessplot=[thicknessplot, thickness];
plotX=[plotX, wakeX];
plotY=[plotY, wakeY];
end
fprintf('Thickness plot: %6.2f percent complete\n', 100*(i+.1*j)/((length(chords)-1)+ n*.1))
end
thicknessplot(:,1)=[ ];
plotX(:,1)=[ ];
plotY(:,1)=[ ];
flipud(thicknessplot);
end
function [q v_fps dynvisc]=findconstants(alt, v_mach)
if alt < 36152
temp=59-.00356*alt;
press=2116*((temp+459.7)/518.6)^5.256;
elseif alt < 82345
temp=-70;
press=473.1*exp(1.73-.000048*alt);
else
print('Program Not Valid for given altitude')
end
%slpcuft: clugs ber cubic foot
density_slpcuft=press/(1718*(temp+459.7));
v_fps=v_mach*sqrt(1.4*1718*(temp+459.7));
q=finddynpress(alt, v_mach);
S = 110.4;
beta = 1.458e-6;
temp_k=[(temp-32) / (1.8)] + 273 ;
viscosity_pascalseconds = (beta*temp_k^(1.5))/(temp_k+S);
%kgpmcu:kilograms per meter cubed
%msqpse:meters squared per second
%sqftpsec:square feet per second
density_kgpmcu=density_slpcuft*515.4;
dynamic_viscosity_msqpsec=viscosity_pascalseconds/density_kgpmcu;
dynamic_viscosity_sqftpsec=dynamic_viscosity_msqpsec*10.76;
dynvisc=dynamic_viscosity_sqftpsec;
density=density_slpcuft;
end
function [wakeplot]=findwakeplot(chords, spans, alt, v_mach, laminarflow, width, n, reso)
[q v_fps dynvisc]=findconstants(alt, v_mach);
Chords = findChords(n, chords, spans);
wakeplot=zeros(reso,1);
width=width/2;
for i=1:1:(size(chords)-1)
dist=(spans(i+1)-spans(i))/n;
for j = 1:n
if (spans(i)+dist*j)>width
lam=laminarflow;
else
lam=laminarflow-.15;
end
x=linspace(0, Chords(i,j),reso);
for k = 1:length(x)
if (k <= 100*lam)
delta_x=( 5.2 * x(k) )*(v_fps*x(k)/dynvisc)^-0.5;
wake(k,j)= delta_x;
else %if turbulent
x_tr=x(100*lam);
Re_xtr = v_fps * x_tr / dynvisc;
delta_xtr=(5.2*x_tr)*(v_fps*x(k)/dynvisc)^-(0.5);
delta_l = ((delta_xtr*((v_fps)^0.2))/(0.37*((dynvisc)^0.2)))^(1/0.8);
lt = x(k) - x_tr + delta_l;
Re_lt = v_fps * lt / dynvisc;
delta = 0.37 * lt /(Re_lt)^0.2;
wake(k,j) = delta;
end
end
wakeplot=[wakeplot, wake];
end
fprintf('Wake plot: %6.2f percent complete\n', 100*(i+.1*j)/((length(chords)-1)+ n*.1))
end
wakeplot(1,:)=[];
wakeplot(:,1)=[ ];
flipud(wakeplot);
end
function q=finddynpress(alt, v_mach)
if alt < 36152
temp=59-.00356*alt;
press=2116*((temp+459.7)/518.6)^5.256;
elseif alt < 82345
temp=-70;
press=473.1*exp(1.73-.000048*alt);
else
print('Program Not Valid for given altitude')
end
%slpcuft: clugs ber cubic foot
density_slpcuft=press/(1718*(temp+459.7));
v_fps=v_mach*sqrt(1.4*1718*(temp+459.7));
q=.5*density_slpcuft*v_fps^2;
end

123
Matlab code/tradestudyAR.m Executable file
View File

@@ -0,0 +1,123 @@
%Master 441 Code
%all alfas in DEGREES!
%by ascorrea
function master441()
diary
datafile=input('Input data file: \nNote: You must delete the header before using \n:','s');
[variablenames, variablevalues]=textread(datafile, '%s %f');
for k = 1:length(variablenames)
eval([variablenames{k} '= variablevalues(k);']);
end
i=1;
for AR=1:.1:10
%CRUISE------------------------------------------------------------------]
cd0_cruise=findcd0(c_f, M_cruise, sref, swet);
cLreq_cruise=findcLrequired(alt_cruise, sref, M_cruise, weight_cruise);
alphareq_cruise=findalpharequired(cLalpha_cruise, cL0, cLreq_cruise);
cD_cruise=findcD(AR, efficiency, cd0_cruise, cLreq_cruise, cd_correction);
eloverdee_cruise=cLreq_cruise/cD_cruise;
cM_cruise=cMalpha_cruise*alphareq_cruise+cM0;
plotAR(i)=AR;
plotLD(i)=eloverdee_cruise;
i=i+1;
end
plot(plotAR, plotLD)
fprintf('Max L/D: %f at AR: %f\n',max(plotLD), plotAR(max(plotLD)==plotLD));
end
function q=findcd0(c_f, M, sref, swet)
if M>.7
c_f=c_f*(1-.09*M^2);
end
q=c_f*(swet/sref);
end
function q=findcLalpha(AR, M, clalpha, sweep, sex, sref, doverb)
%ascorrea
betasquared=1-M^2;
beta=sqrt(betasquared);
eta=clalpha/(2*pi/beta);
numer=2*pi*AR;
denom1=(AR^2*beta^2)/eta^2;
denom2=(tand(sweep)^2/betasquared);
denom=2+sqrt(4+denom1*(1+denom2));
F=1.07*(1+doverb)^2;
cLalpha=(numer/denom)*(sex/sref)*F;
q=cLalpha;
end
function finddragpolar(cd0, cl_alfa, cL0, sweep_LE, ar, cd_correction, filename)
alphadeg=[-12:2];
% alpha=(pi/180)*(alphadeg);
alpha=alphadeg;
cL_alfa=cl_alfa*(ar/(ar+(2*(ar+4)/(ar+2))));
for i=1:length(alpha)
C_L(i)=cL_alfa*(alpha(i))+cL0;
e=4.61*(1-.045*ar^.68)*cosd(sweep_LE)^.15-3.1;
cd_i(i)=C_L(i)^2/(pi*ar*e);
C_d(i)=cd0+cd_i(i)+cd_correction;
end
graphname='Drag Polar';
hold on
axisX0=linspace(0,max(cd));
axisY0=zeros(1,length(axisX0));
plot(axisX0, axisY0,'k--');
plot(C_d, C_L);
plot(C_d, C_L, '.');
title(graphname);
xlabel('C_d');
ylabel('C_L');
axis([0, .04, -1, 1.5]);
% for i=1:length(alphadeg)
% alphalabel=num2str(alphadeg(i));
% label=[' \alpha =' alphalabel];
% text(C_d(i), C_L(i), label)
% end
print ('-dtiff', filename)
close(1)
end
function q=findcLrequired(alt, s, v_mach, lift)
if alt < 36152
temp=59-.00356*alt;
press=2116*((temp+459.7)/518.6)^5.256;
elseif alt < 82345
temp=-70;
press=473.1*exp(1.73-.000048*alt);
else
print('Program Not Valid for given altitude')
end
density=press/(1718*(temp+459.7));
v_fps=v_mach*sqrt(1.4*1718*(temp+459.7));
q=.5*density*v_fps^2;
q=lift/(q*s);
end
function q=findalpharequired(cLalpha, cL0, cLrequired)
q=(cLrequired-cL0)/cLalpha;
end
function q=findcD(ar, e, cd0, C_L, cd_correction)
% e=4.61*(1-.045*ar^.68)*cosd(sweep_LE)^.15-3.1;
cd_i=C_L^2/(pi*ar*e);
cd_i=C_L^2/(pi*ar*e);
q=cd0+cd_i+cd_correction;
end

124
Matlab code/tradestudyS.m Executable file
View File

@@ -0,0 +1,124 @@
%Master 441 Code
%all alfas in DEGREES!
%by ascorrea
function master441()
diary
datafile=input('Input data file: \nNote: You must delete the header before using \n:','s');
[variablenames, variablevalues]=textread(datafile, '%s %f');
for k = 1:length(variablenames)
eval([variablenames{k} '= variablevalues(k);']);
end
i=1;
for sref=100:100:6000
AR=wingspan^2/sref;
%CRUISE------------------------------------------------------------------]
cd0_cruise=findcd0(c_f, M_cruise, sref, swet);
cLreq_cruise=findcLrequired(alt_cruise, sref, M_cruise, weight_cruise);
alphareq_cruise=findalpharequired(cLalpha_cruise, cL0, cLreq_cruise);
cD_cruise=findcD(AR, efficiency, cd0_cruise, cLreq_cruise, cd_correction);
eloverdee_cruise=cLreq_cruise/cD_cruise;
cM_cruise=cMalpha_cruise*alphareq_cruise+cM0;
plotS(i)=sref;
plotLD(i)=eloverdee_cruise;
i=i+1;
end
plot(plotS, plotLD)
fprintf('Max L/D: %f at AR: %f\n', max(plotLD), plotS(max(plotLD)==plotLD));
end
function q=findcd0(c_f, M, sref, swet)
if M>.7
c_f=c_f*(1-.09*M^2);
end
q=c_f*(swet/sref);
end
function q=findcLalpha(AR, M, clalpha, sweep, sex, sref, doverb)
%ascorrea
betasquared=1-M^2;
beta=sqrt(betasquared);
eta=clalpha/(2*pi/beta);
numer=2*pi*AR;
denom1=(AR^2*beta^2)/eta^2;
denom2=(tand(sweep)^2/betasquared);
denom=2+sqrt(4+denom1*(1+denom2));
F=1.07*(1+doverb)^2;
cLalpha=(numer/denom)*(sex/sref)*F;
q=cLalpha;
end
function finddragpolar(cd0, cl_alfa, cL0, sweep_LE, ar, cd_correction, filename)
alphadeg=[-12:2];
% alpha=(pi/180)*(alphadeg);
alpha=alphadeg;
cL_alfa=cl_alfa*(ar/(ar+(2*(ar+4)/(ar+2))));
for i=1:length(alpha)
C_L(i)=cL_alfa*(alpha(i))+cL0;
e=4.61*(1-.045*ar^.68)*cosd(sweep_LE)^.15-3.1;
cd_i(i)=C_L(i)^2/(pi*ar*e);
C_d(i)=cd0+cd_i(i)+cd_correction;
end
graphname='Drag Polar';
hold on
axisX0=linspace(0,max(cd));
axisY0=zeros(1,length(axisX0));
plot(axisX0, axisY0,'k--');
plot(C_d, C_L);
plot(C_d, C_L, '.');
title(graphname);
xlabel('C_d');
ylabel('C_L');
axis([0, .04, -1, 1.5]);
% for i=1:length(alphadeg)
% alphalabel=num2str(alphadeg(i));
% label=[' \alpha =' alphalabel];
% text(C_d(i), C_L(i), label)
% end
print ('-dtiff', filename)
close(1)
end
function q=findcLrequired(alt, s, v_mach, lift)
if alt < 36152
temp=59-.00356*alt;
press=2116*((temp+459.7)/518.6)^5.256;
elseif alt < 82345
temp=-70;
press=473.1*exp(1.73-.000048*alt);
else
print('Program Not Valid for given altitude')
end
density=press/(1718*(temp+459.7));
v_fps=v_mach*sqrt(1.4*1718*(temp+459.7));
q=.5*density*v_fps^2;
q=lift/(q*s);
end
function q=findalpharequired(cLalpha, cL0, cLrequired)
q=(cLrequired-cL0)/cLalpha;
end
function q=findcD(ar, e, cd0, C_L, cd_correction)
% e=4.61*(1-.045*ar^.68)*cosd(sweep_LE)^.15-3.1;
cd_i=C_L^2/(pi*ar*e);
cd_i=C_L^2/(pi*ar*e);
q=cd0+cd_i+cd_correction;
end

123
Matlab code/tradestudySwet.m Executable file
View File

@@ -0,0 +1,123 @@
%Swet Study Code
%all alfas in DEGREES!
%by ascorrea
function tradestudySwet(datafile, desiredLD)
% datafile=input('Input data file: \nNote: You must delete the header before using \n:','s');
[variablenames, variablevalues]=textread(datafile, '%s %f');
for k = 1:length(variablenames)
eval([variablenames{k} '= variablevalues(k);']);
end
i=1;
for swet=1000:100:20000
AR=wingspan^2/sref;
%CRUISE------------------------------------------------------------------]
cd0_cruise=findcd0(c_f, M_cruise, sref, swet);
cLreq_cruise=findcLrequired(alt_cruise, sref, M_cruise, weight_cruise);
alphareq_cruise=findalpharequired(cLalpha_cruise, cL0, cLreq_cruise);
cD_cruise=findcD(AR, efficiency, cd0_cruise, cLreq_cruise, cd_correction);
eloverdee_cruise=cLreq_cruise/cD_cruise;
cM_cruise=cMalpha_cruise*alphareq_cruise+cM0;
plotSwet(i)=swet;
plotLD(i)=eloverdee_cruise;
i=i+1;
end
plot(plotSwet, plotLD)
[min_diff, array_pos]=min(abs(plotLD-desiredLD));
fprintf('L/D: %f at AR: %f\n', plotLD(array_pos), plotSwet(array_pos));
end
function q=findcd0(c_f, M, sref, swet)
if M>.7
c_f=c_f*(1-.09*M^2);
end
q=c_f*(swet/sref);
end
function q=findcLalpha(AR, M, clalpha, sweep, sex, sref, doverb)
%ascorrea
betasquared=1-M^2;
beta=sqrt(betasquared);
eta=clalpha/(2*pi/beta);
numer=2*pi*AR;
denom1=(AR^2*beta^2)/eta^2;
denom2=(tand(sweep)^2/betasquared);
denom=2+sqrt(4+denom1*(1+denom2));
F=1.07*(1+doverb)^2;
cLalpha=(numer/denom)*(sex/sref)*F;
q=cLalpha;
end
function finddragpolar(cd0, cl_alfa, cL0, sweep_LE, ar, cd_correction, filename)
alphadeg=[-12:2];
% alpha=(pi/180)*(alphadeg);
alpha=alphadeg;
cL_alfa=cl_alfa*(ar/(ar+(2*(ar+4)/(ar+2))));
for i=1:length(alpha)
C_L(i)=cL_alfa*(alpha(i))+cL0;
e=4.61*(1-.045*ar^.68)*cosd(sweep_LE)^.15-3.1;
cd_i(i)=C_L(i)^2/(pi*ar*e);
C_d(i)=cd0+cd_i(i)+cd_correction;
end
graphname='Drag Polar';
hold on
axisX0=linspace(0,max(cd));
axisY0=zeros(1,length(axisX0));
plot(axisX0, axisY0,'k--');
plot(C_d, C_L);
plot(C_d, C_L, '.');
title(graphname);
xlabel('C_d');
ylabel('C_L');
axis([0, .04, -1, 1.5]);
% for i=1:length(alphadeg)
% alphalabel=num2str(alphadeg(i));
% label=[' \alpha =' alphalabel];
% text(C_d(i), C_L(i), label)
% end
print ('-dtiff', filename)
close(1)
end
function q=findcLrequired(alt, s, v_mach, lift)
if alt < 36152
temp=59-.00356*alt;
press=2116*((temp+459.7)/518.6)^5.256;
elseif alt < 82345
temp=-70;
press=473.1*exp(1.73-.000048*alt);
else
print('Program Not Valid for given altitude')
end
density=press/(1718*(temp+459.7));
v_fps=v_mach*sqrt(1.4*1718*(temp+459.7));
q=.5*density*v_fps^2;
q=lift/(q*s);
end
function q=findalpharequired(cLalpha, cL0, cLrequired)
q=(cLrequired-cL0)/cLalpha;
end
function q=findcD(ar, e, cd0, C_L, cd_correction)
% e=4.61*(1-.045*ar^.68)*cosd(sweep_LE)^.15-3.1;
cd_i=C_L^2/(pi*ar*e);
cd_i=C_L^2/(pi*ar*e);
q=cd0+cd_i+cd_correction;
end