%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 xLocwidth 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