CODE:
clcclear alllh=input('Enter the value of L/H ');n2=input('Enter the value of N2 ');re=input('Enter the value of Re ');dt=input('Enter the value of dt ');dx=input('Enter the value of dx ');dy=input('Enter the value of dy ');hd=input('Enter the value of H/d ');e=input('Enter the stopping criteria ');m=((lh*hd)/dx)+1;n=(hd/dy)+1;n1=n-n2;v0=zeros(m,n);v=zeros(m,n);s0=zeros(m,n);s=zeros(m,n);v_v=zeros(m,n);v_u=zeros(m,n);it=1;count=0;e1=ones(m,n);e2=ones(m,n);e3=10;while any(e1(:) > e) | any(e2(:) > e) count=count+1; dt1=it*dt; it=it+1; c1=1/((1/dt1)+((2/re)*((1/(dx*dx))+(1/(dy*dy)))));c2=1/(2*((1/(dx*dx))+(1/(dy*dy))));for j=2:n1 s(1,j) = -1;endfor j=n1+1:n v(1,j) = 0; s(1,j) = ((j-1)*dy)-(hd);endfor i=2:m-1 s(i,1) = -1;endfor j=2:n2 s(m,j) = ((j-1)*dy)-1; v(m,j) = 0;endfor j=n2+1:n s(m,j) = 0;endfor i=2:m-1 s(i,n) = 0;end for i=2:m-1 for j=2:n-1 v(i,j) = c1*((v0(i,j)/dt1)-(v0(i,j+1)/(dy*dy))-(v0(i,j-1)/(dy*dy))+(v0(i+1,j)/(re*dx*dx))+(v0(i-1,j)/(re*dx*dx))); s(i,j) = c2*(((s0(i+1,j)+s0(i-1,j))/(dx*dx))+((s0(i,j+1)+s0(i,j-1))/(dy*dy))+v0(i,j)); end end for j=2:n1 v(1,j) = -2*((s0(2,j)-s0(1,j))/(dx*dx)); end for i=2:m-1 v(i,1) = 2*((s0(i,1)-s0(i,2))/(dy*dy)); end for j=n2+1:n v(m,j) = -2*((s0(m-1,j)-s0(m,j))/(dx*dx)); end for i=2:m-1 v(i,n) = 2*((s0(i,n)-s0(i,n-1))/(dy*dy)); end for i=1:m for j=1:n e1(i,j)=abs(v(i,j)-v0(i,j)); e2(i,j)=abs(s(i,j)-s0(i,j)); v0(i,j)=v(i,j); s0(i,j)=s(i,j); end end end fprintf ('\n Iterations = %d \n \n',count)disp (v)disp (s)for j=1:n1 v_v(1,j) = 0; v_u(1,j) = 0;endfor j=n1:n v_v(1,j) = 0; v_u(1,j) = 1;endfor i=2:m-1 v_v(i,1) = 0; v_u(i,1) = 0;endfor j=1:n2 v_v(m,j) = 0; v_u(m,j) = 1;endfor j=n2:n v_v(m,j) = 0; v_u(m,j) = 0;endfor i=2:m-1 v_v(i,n) = 0; v_u(i,n) = 0;endfor i=2:m-1 for j=2:n-1 v_u(i,j) = (s(i,j+1)-s(i,j-1))/(2*dy); v_v(i,j) = (s(i-1,j)-s(i+1,j))/(2*dx); endenddisp (v_u)disp (v_v)figure (1);plot (v_u);figure (2);plot (v_v);startx=[1:1:m];starty=[1:1:n];figure (3);quiver(v_u,v_v);streamline(v_u,v_v,startx,starty);
I'm using streamline in this code and I'm getting this figure. I'm getting the streamlines only in that area and not in the upper left area.
lh=1, n2=5 re=1 dt=0.1 dx=0.5 dy=0.5 hd=10 e=0.000001
Also, in some cases, I have to use lh=0.5 and 2. Then I'm getting this error:
Error using stream2 (line 49)STARTX,STARTY must all be the same size.Error in streamline (line 60)verts = stream2(u,v,sx,sy,options);Error in Copy_of_final (line 153)streamline(v_u,v_v,startx,starty);
Best Answer