%	Irrotational, solenoidal flow in 2-D in the complex plane
%	w(z)=z^n
%	Domain is between theta = 0 and theta = pi/n for all r, n => 1/2
clear all
n=input('w(z)=z^n, Input value of n: ');
clf reset
[th,r]=meshgrid((0:10:180)*pi/(n*180),0:.05:1);
[x,y]=pol2cart(th,r);
z=x+i*y;
theta=angle(z);
tsize=size(theta);
for j=1:(tsize(1)*tsize(2))
   if theta(j)<0 
      theta(j)=2*pi+theta(j);
   end
end
w=(abs(z).^n).*(cos(theta.*n)+i.*sin(theta.*n));
contour(x,y,real(w),20,'r')
hold on
contour(x,y,imag(w),20,'k')
plot([0 cos(pi/n)],[0 sin(pi/n)],'k',[0 1],[0 0],'k')
axis image
xlabel('x')
ylabel('y')
title(['Potentials and Streamlines for w(z)=z^n, n= '...
      ,num2str(n)])
pause
%	Calculate pressure distribution from square of velocity 
p=-n^2.*r.^(2*(n-1));
pcolor(x,y,p)
colormap(hot)
shading flat