% % code08.m -- (djm: 11 feb 2002) % % initialize workspace clear; close all L = 3.0; ds = 2*L/301; % set x & y-vectors & grid matrices ("help meshgrid") x = -L:ds:+L; y = -L:ds:+L; [xx,yy] = meshgrid(x,y); zz = xx + i*yy; [tt rr] = cart2pol(xx,yy); r2 = rr.^2; % complex potential flo = 2; switch(flo) % flow around a cylinder (circ = -2*pi) case{1} Psi = zz + 1./zz + (i*2*pi/2/pi)*log(zz); uu = (1 - 1./r2) + (2*yy.*yy)./(r2.^2) + (2*yy./r2); vv = - (2*xx.*yy)./(r2.^2) - (2*xx./r2); ftitle = ['\bf flow around a cylinder (vel pot = green, strmfn' ... ' = blue)']; case{2} cU = exp(-i*pi/6); cUc = conj(cU); cL = -2*pi*imag(cUc); Psi = (cU /2) * (zz + sqrt(zz-1).*sqrt(zz+1)) ... + (cUc/2) * (zz - sqrt(zz-1).*sqrt(zz+1)) ... - (i*cL/2/pi) * log(zz + sqrt(zz-1).*sqrt(zz+1)); ftitle = ['\bf flat airfoil (vel pot = green, strmfn = blue)']; end % plot level curves of Psi clf contour(x,y,real(Psi),-5:0.4:5,'g--') hold on contour(x,y,imag(Psi),-5:.25:5,'b-') contour(x,y,imag(Psi),[0 0],'k-') % label plot title(ftitle) xlabel('\bf x-axis') ylabel('\bf y-axis') plot([-1 1],[0 0],'color','k','linewidth',4) axis equal; axis([-L L -L L]) text(-2.8,0.2,'\bf branch problem here!') text(-0.5,0.5,'\bf fast & lo','color','r') text(-0.5,-0.5,'\bf slow & hi','color','r')