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

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