function []=panel() %Smith-Hess Panel Method for single %element lifting airfoil in 2-d %incompressible flow. %This takes user input on the number of nodes to use on the %upper and lower surface and the 4 digit NACA number. clf writetofile=0; hold off NUpper=input('\nEnter the number of upper points.\n?'); NLower=input('\nEnter the number of lower points.\n?'); Naca=input('\nType in NACA airfoil number.\n?'); if input('\nWould you like to print the information to a file?(y,n)\n?','s')=='y' filename=input('Enter a file name.\n?','s'); filename=strcat(filename,'.dat'); fid=fopen(filename,'w'); writetofile=1; end [x,y]=Body(NUpper,NLower,Naca); disp(' Shape of body.'); disp(' x y'); disp([x,y]) subplot(2,2,1),plot(x,y,'b-',x,y,'ro'); subplot(2,2,1),axis([-.5,1.5,-.5,.5]); subplot(2,2,1),title('Shape of Airfoil'); subplot(2,2,1),xlabel('x/c'); subplot(2,2,1),ylabel('y/c'); subplot(2,2,4),hold on if writetofile fprintf(fid,' Shape of body\n'); fprintf(fid,' x y\n'); fprintf(fid,' --------- --------\n'); for i=1:length(x) fprintf(fid,'%9.5f %9.5f\n',x(i),y(i)); end end alpha=input('\nEnter an angle of attack between -90 and 90 degrees.\n?'); while alpha<=90 & alpha>=-90 [xmid,Cp,Cl,Cm,Cd]=FindPandC(x,y,alpha*pi/180); disp(' Pressure Distribution'); disp(' x Cp'); disp([xmid Cp]); disp([' Cl =',num2str(Cl)]); disp([' Cd =',num2str(Cd)]); disp([' Cm =',num2str(Cm)]); if writetofile fprintf(fid,'\n\nAngle of Attack = %9.3f\n',alpha); fprintf(fid,'\nPressure Distribution\n'); fprintf(fid,' x Cp\n'); fprintf(fid,' --------- --------\n'); for i=1:length(xmid) fprintf(fid,'%9.5f %9.5f\n',xmid(i),Cp(i)); end fprintf(fid,'Cl = %9.5f\n',Cl); fprintf(fid,'Cd = %9.5f\n',Cd); fprintf(fid,'Cm = %9.5f\n',Cm); end subplot(2,2,3),plot([xmid;xmid(1)],-[Cp;Cp(1)],'b-',[xmid;xmid(1)],-[Cp;Cp(1)],'ro'); subplot(2,2,3),title('Pressures'); subplot(2,2,3),xlabel('x/c'); subplot(2,2,3),ylabel('-Cp'); subplot(2,2,4),plot(alpha,Cl,'bd'); subplot(2,2,4),plot(alpha,Cd,'rx'); subplot(2,2,4),plot(alpha,Cm,'g*'); subplot(2,2,4),title('Force and Moment Coefficients'); subplot(2,2,4),xlabel('Angle of Attack(degrees)'); subplot(2,2,4),ylabel('Cl,Cd,Cm'); alpha=input('\nEnter another angle of attack.\nIf you are done type in 91.\n?'); end if writetofile fclose(fid); disp(['Created filename',blanks(1),filename]); end %********************************************************** function [x,y]=Body(NumU,NumL,Naca) %Initialize variables Series=4; XUpper=zeros(NumU,1); CamberUpper=XUpper; dCamdxUpper=XUpper; BetaUpper=XUpper; XLower=zeros(NumL,1); CamberLower=XLower; dCamdxLower=XLower; BetaLower=XLower; %Convert NACA 4 digit to fraction of chord values. MaxCamber=floor(Naca/1000); PtMaxCamber=floor(Naca/100)-MaxCamber*10; MaxThickness=Naca-MaxCamber*1000-PtMaxCamber*100; MaxCamber=MaxCamber*.01; PtMaxCamber=PtMaxCamber*.1; MaxThickness=MaxThickness*.01; if MaxCamber>=10 PtMaxCamber=0.2025; MaxCamber=2.6595*PtMaxCamber^3; Series=5; end %Find the x and y coordinates of the airfoil. for i=1:NumU XUpper(i)=.5*(1-cos(pi*(i-1)/NumU)); end for i=1:NumL XLower(i)=.5*(1+cos(pi*(i-1)/NumL)); end %Evaluate thickness and camber %for naca 4- or 5-digit airfoil ThickUpper=5*MaxThickness*(.2969*sqrt(XUpper)-XUpper.*(.126+XUpper.*(.35372-XUpper.*(.2843-XUpper*.1015)))); ThickLower=5*MaxThickness*(.2969*sqrt(XLower)-XLower.*(.126+XLower.*(.35372-XLower.*(.2843-XLower*.1015)))); if Series==4 for i=1:NumU if XUpper(i)