312 HW #8 Solutions

May 6, 2020

1 (60 points)

There are several ways to approach this problem, but it turns out that plotting is simpler if uniform grid is maintained. algorithm used in the code given in appendix goes as follows:

1. step along the curved surface. At each arbitrary angle i, determine the mach number by numerically solving − θi − ν(Mi) + = 0 (1) − where ν(Mi) is the Prandtl-Meyer function evaluated at Mi, and ka is the constant − associated with a characteristic originating in the initial region, i.., ka = 0 + ν(M0).

+ 2. Once Mach number is determined, can determine the functional form of the ci plus characteristic, using the fact that it is linear.

1 3. This collection of Mach lines breaks the domain into several regions. From Method of Characteristics, we know that along each Mach line the Mach number and flow angle is a constant. Pressure can determined by noting that mach lines are isentropic. Therefore all that is left is to discretize the 2D domain into a grid and assign the respective mach, angle, and pressure values to each vertex based on where that vertex lives with respect to the regions determined above.

1.a

2 1.b

3 2 (40 points)

2.a From the notes, we have 2θ Cp = . (2) p 2 M∞ − 1

Lettingx ˜ ≡ x/c andy ˜us ≡ yus/c, we have

dy˜  θ = arctan us − α (3) upper dx˜ and dy˜  θ = − arctan us + α (4) lower dx˜

4 2.c For subsonic flow, we use the Prandtl-Glauert relation to approximate coefficient of lift.

Cl,0 Cl = (5) p 2 1 − M∞ where, from incompressible flow results,

 t  C = 2π 1 + 0.77 sin(α). (6) l,0 c

For supersonic flow, the lift coefficient is found by integrating the flow normal component of the coefficient of pressure, equation (2), along the surface of the airfoil

C` = (Cp,uppernupper + Cp,lowernlower) · yˆ dS ˛S 2 (7) = (θuppernupper + θlowernlower) · yˆ dS p 2 M∞ − 1 ˛S

5 where the inward facing unit normal vectors are defined as

 0  1 y˜us(˜x) nupper = Rα p(˜y0 (˜x))2 + 1 −1 us (8)  0  1 y˜us(˜x) nlower = Rα p 0 2 1 (˜yus(˜x)) + 1 at any pointx ˜ along the chordlength for Rα being a rotation matrix for α degrees. At exactly the sonic point, both equation (5) and equation (7) are undefined, and therefore a discontinuity exists at M = 1.

6 Appendix I 5/13/20 7:07 PM /Users/noahosman/Desktop/AE312/home.../Q1_star.m 1 of 3

clc, clear all, close all

%======Input ======th = -16*pi/180; % Turning angle Pinit = 101325; % Initial pressure Minit = 1.775; % Initial Mach # nmach = 50; % number of mach lines gam = 1.4;

% Plotting/ grid parameters: xmin = -0.25; xmax = 0.5; ymax = 0.1; dx = 0.001; %======

% ------Generate Grid ------% x and y position on the circle as a function of theta x_circ = @(theta) -sin(theta);% y_circ = @(theta) cos(theta)-1;%

% x,y point at right end of curve xn = x_circ(th); = y_circ(th);

% x-domain x = xmin:dx:xmax; xnum = length(x);

% Generate y value on surface at each x-point y_surf = 0 .* (x<0) +... % linear face 1 (sqrt(1-x.^2)-1) .* (x>0 & xxn); % linear face 2

% y-domain y = y_surf(end):dx:ymax; ynum = length(y);

% Generate grid for full rectangular domain [Xt, Yt] = meshgrid(x,y);

% Alter that domain to give NaN for values inside the surface insurf = ones(ynum,xnum); y_surf_rep = repmat(y_surf-dx,ynum, 1);

insurf(Yt<=y_surf_rep) = NaN; X = insurf .* Xt; Y = insurf .* Yt; % ------

gamm = (gam-1)/2; gamp = (gam+1)/2; P0init = Pinit*(1+gamm*Minit^2)^(-gam/(gam-1));

% intialize mach and pressure P = insurf; M = insurf; T = insurf;

% Define prandtl-meyer functn nu = @(Min) sqrt(gamp/gamm) .* atan( sqrt(gamm/gamp.*(Min.^2 - 1)) )... - atan( sqrt(Min.^2 - 1) );

kam = 0 + nu(Minit);

% Make mach lines th_array = linspace(0,-16,nmach).*pi/180; line_mb = zeros(nmach,2);

7 5/13/20 7:07 PM /Users/noahosman/Desktop/AE312/home.../Q1_star.m 2 of 3 for i = 1:nmach thi = th_array(i); % numerically solve for Mach number funi = @(Min) -thi - nu(Min) + kam; if i == 1 Mguess = [Minit, 2*Minit]; else Mguess = [M(i-1), 2*M(i-1)]; end M(i) = fzero(funi, Mguess ); % slope line_mb(i,1) = tan(thi+asin(1/M(i))); % y-int line_mb(i,2) = y_circ(thi) - line_mb(i,1)*x_circ(thi); % kam for the next Mach line kam = thi + nu(M(i)); end

% fill regions between mach lines

% Intial region y_machi = line_mb(1,1).*x + line_mb(1,2); y_machi_rep_old = repmat(y_machi,ynum, 1); region = Yt>y_surf_rep & Yt>=y_machi_rep_old; P( region ) = Pinit; M( region ) = Minit; T( region ) = 0;

% in-between regions for i = 2:nmach-1 y_machi = line_mb(i,1).*x + line_mb(i,2); y_machi_rep = repmat(y_machi,ynum, 1); region = Yt>y_surf_rep & Yt>=y_machi_rep & Yt<=y_machi_rep_old; P( region ) = P0init*(1+gamm*M(i)^2)^(gam/(gam-1)); M( region ) = M(i); T( region ) = th_array(i);

y_machi_rep_old = y_machi_rep; end

% final constant region y_machi = line_mb(nmach,1).*x + line_mb(nmach,2); y_machi_rep = repmat(y_machi,ynum, 1); region = Yt>y_surf_rep & Yt<=y_machi_rep_old; P( region ) = P0init*(1+gamm*M(nmach)^2)^(gam/(gam-1)); M( region ) = M(nmach); T( region ) = th_array(i);

% % % % % % % % % % % % % % % % % % % % % % %

5/13/20 7:07 PM /Users/noahosman/Desktop/AE312/home.../Q1_star.m 3 of 3

% Plot Things: %% Pressure contour fill_col = [0.45,0.45,0.45]; figure() contourf(X,Y,P,unique(P(~isnan(P)))); hold on fill([xmin,x,xmax],[-1,y_surf,-1], fill_col,'LineStyle','none'); axis([xmin,xmax,y_surf(end),y(end)]) colorbar ax = gca; set(ax,'TickLabelInterpreter','latex'); set(ax,'Fontsize',18); xlabel('$x$','interpreter','latex','FontSize',24) ylabel('$y$','interpreter','latex','FontSize',24) title('Pressure $(\textnormal{Pa})$','interpreter','latex','FontSize',24)

%% Mach # contour fill_col = [0.45,0.45,0.45]; figure() contourf(X,Y,M,unique(M(~isnan(M)))); hold on fill([xmin,x,xmax],[-1,y_surf,-1], fill_col,'LineStyle','none'); axis([xmin,xmax,y_surf(end),y(end)]) colorbar ax = gca; set(ax,'TickLabelInterpreter','latex'); set(ax,'Fontsize',18); xlabel('$x$','interpreter','latex','FontSize',24) ylabel('$y$','interpreter','latex','FontSize',24) title('Mach number','interpreter','latex','FontSize',24)

%% Streamlines nth = 12; fill_col = [0.45,0.45,0.45]; starty = Y(end/2+1:nth:end,1); startx = xmin.*ones(1,length(starty)); figure() quiver(Xt(1:nth:end,1:2*nth:end),Yt(1:nth:end,1:2*nth:end),... cos(T(1:nth:end,1:2*nth:end)),sin(T(1:nth:end,1:2*nth:end))... ,0.5,'k'); hold on hlines = streamline(Xt,Yt,cos(T),sin(T), startx,starty); set(hlines,'LineWidth',2) fill([xmin,x,xmax],[-1,y_surf,-1], fill_col,'LineStyle','none'); axis([xmin,xmax,y_surf(end),y(end)]) ax = gca; set(ax,'TickLabelInterpreter','latex'); set(ax,'Fontsize',18); xlabel('$x$','interpreter','latex','FontSize',24) ylabel('$y$','interpreter','latex','FontSize',24) title('Velocity','interpreter','latex','FontSize',24)

Appendix II 5/15/20 12:30 PM /Users/noahosman/Desktop/untitled3.m 1 of 1

% ------2a ------al = 4*pi/180; M0 = 2.0; tc = 0.05; h = @(x) 0.385*tc.*(1-2.*x).*sqrt(1-(2.*x).^2); hp = @(x) tc.*( x.*(6.16.*x-1.54)-0.77) ./ sqrt(1-4.*x.^2);

nb = 100; X = linspace(-0.5+10^-16,0.5-10^-16,nb);%linspace(-0.5,0.5,nb); th = atan(hp(X));

cpu = 2.*(th-al)./sqrt(M0^2-1); cpl = 2.*(-th+al)./sqrt(M0^2-1);

% Plot figure() plot((X+0.5)*100, cpu, '-k','linewidth',2); hold on plot((X+0.5)*100, cpl, '-r','linewidth',2) plot([-1,101],[0,0],'-k','linewidth',0.5) axis([0, 100, -1,1]) ax = gca; set(ax,'TickLabelInterpreter','latex'); set(ax,'Fontsize',18); xlabel('Percent Chordlength','interpreter','latex','FontSize',24) ylabel('Coefficient of Pressure','interpreter','latex','FontSize',24) legend({'$C_p$ Upper Surface','$C_p$ Lower Surface'},... 'interpreter','latex','FontSize',24)

% ------2b ------

cpu_num = cpu * sqrt(M0^2-1); cpl_num = cpl * sqrt(M0^2-1);

sc = (hp(X').^2 + 1).^(-1/2); nu = sc.*[hp(X'), -ones(nb,1) ]; nl = sc.*[hp(X'), ones(nb,1) ]; R = [cos(al), sin(al); sin(al), cos(al) ];

M_sup = 1.01:0.01:2; cp_int = 0; for i = 1:nb if i ==1 ds = sqrt( (X(2) - X(1))^2 + (h(X(2)) - h(X(1)))^2 ); else ds = sqrt( (X(i) - X(i-1))^2 + (h(X(i)) - h(X(i-1)))^2 ); end cp_int = cp_int + ... ds*(cpu_num(i)*nu(i,:) + cpl_num(i)*nl(i,:))*R*[0;1]; end cl_sup = cp_int./sqrt(M_sup.^2-1);

M_sub = 0:0.01:0.99; cl_sub = 2*pi*(1+0.77*tc)*sin(al)./sqrt(1-M_sub.^2);

% Plot figure() plot([M_sub, M_sup], [cl_sub, cl_sup],'-k','linewidth',2); hold on plot([1,1],[-10,10],'--k','linewidth',0.5) axis([0, 2, 0,2]) ax = gca; set(ax,'TickLabelInterpreter','latex'); set(ax,'Fontsize',18); xlabel('Mach Number','interpreter','latex','FontSize',24) ylabel('Coefficient of Lift','interpreter','latex','FontSize',24)

10