Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

CFD

Assignment # 2

Name : Yousef Saad Yousef Mohamed

Section : 6
A) By using the Laasonen Implicit method using a total simulation time of 1.08 seconds and a
time step size of 0.002 second.

clc
clear all
close all

nu = 0.000217;
Uo = 40;
h = 0.04;
dt = 0.002;
dh = 0.001;
t = 1.08;
Bu = [0 40];
Iu = [0 40];

%% Solution
d = nu*dt/dh^2; % Diffusion Factor
nt = round(t/dt+1);
ny = round(h/dh+1);
ut = zeros(nt,ny);

nd = (nu*dt)/(dh^2);

ue = zeros(1,ny);
y = linspace(0,h,ny);
ue = Uo*(1-y./h);

ut(:,ny)=0.0;
ut(:,1)=Uo;

for n = 1:nt
for j = 1:ny
if n==1
B = zeros(ny,1);
B(end) = Bu(2);
else
B = U{n-1};
end
A = zeros(ny,ny);
for k = 1:ny
if k == 1
A(k,k)=1;
elseif k == ny
A(k,k)=1;
else
A(k,k-1) = -d;
A(k,k) = 1+2*d;
A(k,k+1) = -d;
end

end
U{n} = inv(A)*B;

t = n*dt;

2
e = y(j)/(2*sqrt(nu*t));
e1 = h/(2*sqrt(nu*t));

ut(n+1,j) = Uo*(erfc(e)-erfc(2*e1-e)+erfc(2*e1+e)-erfc(4*e1 e)+erfc(4*e1+e));

end
end

%% Plots
figure
hold on
grid on

for k = 1:nt
plot(U{k},0:dh:dh*(ny-1))

end
plot(ue,y,ut(nt,:),y)

xlabel('Velocity "U" (m)')


ylabel('Hight "Y" (m)')

_____________________________________________________________________
_____________________________________________________________________
**** I assumed that the upper plate moving with u=40m/s instead of the ****
**** Lower plate so, the chart is inversed. ****
_____________________________________________________________________
____________________________________________________________________

3
(Case 1)

T = 1.08
With a time step size of dt = 0.002

# I can't repair the axis of Exact and trans with the cfd solution !!

4
B)
(1) With a time step size of 0.01 sec.

(2) With a time step size of 0.1 sec.

5
(2) With a time step size of 0.2 sec.

COMMEMT:
• All results and plots are stable with changing of the time step.
• Also, with very small time step, Which proves that Laasonen Implicit is
unconditionally stable.

6
(c) Calculate and plot the velocity profile using a time step size of 0.0001sec.

-Solution by inverse matrix method by take a very small time step takes a lot of
time compared to the Thomas algorithm method.

7
My attempt to solve the equations by Thomas algorithm method:
clc
clear
nu = .000217;
h=.04;
Ic=0;
dh=.001;
t=1.08;
dt=.002;
B_Top=0;
B_B=40;

ny=round((h/dh+1));
nt=round((t/dt+1));
dn=((nu*dt)/(dh^2));
y=linspace(0,h,ny);
u=zeros(ny,nt);

%intial condtion
u(:,1)=Ic;
%boundy condtion
u(1,:)=B_Top;
u(ny+1,:)=B_B;
c=zeros(1,40);
c(1,:)=dn;
c(1,40)=0;
%SOLUTION
for n =1:length(nt)
for j =3:ny
x=j-1;
a(x)= dn;
b(x)=-(1+2*dn);
d(x)=-u(j,n);

if x==1
a(x)=0;
d(x)=d(x)-dn*u(j-1,n+1);

end

end

for j=2:ny
x=j-1;

if x==1
Cd=0;
Dd=0;
Cd=(c/b);
Dd= (d/b);
else
Cd(x) = c(x)/b(x)-a(x)*c(x-1);
Dd(x) =d(x)-a(x)*d(x-1)/b(x)-a(x)*Cd(x-1);
end
end

s=linspace(ny,2,j-1);
for k=1:ny-1
j=s(k);
x=j-1;
if j==2
u(j,n+1)=Dd(x);
else
u(j,n+1)=Dd(x) - Cd(x)*u(j+1,n+1);
end
end

end

8
9

You might also like