257 lines
7.8 KiB
Matlab
Executable File
257 lines
7.8 KiB
Matlab
Executable File
%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 |