Sei sulla pagina 1di 4

COMPUTATIONAL FLUID

DYNAMICS
ASSIGNMENT # 04

SUSHANT MISHRA
D13124068

MATLAB PROGRAM
clear all
clc
%For Couette flow, using Crank-Nicolson Method
N=20;
n=N+1;
% Number of nodes
del_y=0.05; % Grid spacing
E=16;
% Value of del_t/[(del_y)^2*Re_h]
y_max=1;
A = (-E)/2;
b = A;
a = A;
B = 1+E;
d = B;
u(21,1000) = zeros;
% Inital values given in the problem
y = 0;
for i = 1:(n)
if y<1.0
u(i,1) = 0;
else
u(i,1) = 1;
end
Y(i,1)=y;
y=y+del_y;
end
c(21,1000)= zeros;
for t= 2:1000
u(21,t)=1;
u(1,t)=0;
for i=3:19
c(i,t) = ((1-E)*u(i,t-1))+ (0.5*E*(u(i+1,t-1)+u(i-1,t-1)));
end
for i=20
c(i,t) = ((1-E)*u(i,t-1))+(0.5*E*(u(i+1,t-1)+u(i-1,t-1)))-A;
end
d_k(3,t)= d-((b*a)/d);
c_k(3,t) = c(3,t)-((b*c(2,t))/ d);
for i = 4:(n-1)
d_k(i,t) = d- ((b*a)/d_k(i-1,t));
c_k(i,t) = c(i,t) - ((b*c_k(i-1,t))/ d_k(i-1,t));

end
u(n-1,t)=c_k(n-1,t)/d_k(n-1,t);
for i =(N-1):-1:3
u(i,t) = (c_k(i,t) - (a * u(i+1,t)))/d_k(i,t);
end
u(2,t)=((c(2,t)-a*u(3,t))/d);
end
%for the convergence
for s=2:1000
z=0;
for e=1:21
n=u(e,s)-u(e,s-1);
if n<10^-7
z=z+1;
end
end
if z>20
break
end
end
s;
plot(u(:,100),Y(:,1),u(:,200),Y(:,1),u(:,300),Y(:,1),u(:,400),Y(:,1),u(:,500)
,Y(:,1),u(:,600),Y(:,1),u(:,700),Y(:,1),u(:,800),Y(:,1),u(:,900),Y(:,1),u(:,1
000),Y(:,1))
title('Couette flow using Crank Nicolson method')
xlabel('u(x,t)')
ylabel('y')
legend ('100','200','300','400','500','600','700','800','900','1000')

Couette flow using Crank Nicolson method


1.4
100
200
300
400
1.2
500
600
700
800
1
900
1000

0.8

0.6

0.4

0.2

0.1

0.2

0.3

0.4

0.5
u(x,t)

0.6

0.7

0.8

0.9

Potrebbero piacerti anche