CFD
Assignment # 1
Name : Yousef Saad Yousef Mohamed
Section : 6
A) By using the FTCS method using a total simulation time of 1.08 seconds and a time step
size of 0.0021 second.
clc
clear
%defining variables
nu = 0.000217;
h = 0.04;
Uo = 40;
dh = 0.001;
tf = 1.08;
dt = 0.0021;
ny = round ((h/dh)+1);
nt = round ((tf/dt)+1);
nd = (nu*dt)/(dh^2);
u = zeros(nt,ny);
ut = zeros(nt,ny);
c = zeros(nt,ny);
c(:,ny)=0.0;
c(:,1)=0.0;
ue = zeros(1,ny);
y = linspace(0,h,ny);
ue = Uo*(1-y./h);
u(:,ny)=0.0;
u(:,1)=Uo;
ut(:,ny)=0.0;
ut(:,1)=Uo;
for n = 1:nt-1
for j = 2:ny-1
u(n+1,j)= u(n,j) + nd * (u(n,j+1) - 2.0 * u(n,j) + u(n,j-1));
t = n*dt;
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));
c(n+1,j)=(ut(n+1,j)-u(n+1,j))/ut(n+1,j);
end
end
plot(ue,y,u(nt,:),y,ut(nt,:),y,c(nt,:),y)
legend('Exact','FTCS','Trans','error')
grid
xlabel('Velocity (m/s)');
ylabel('y (m)');
txt = ['nd= ' num2str(nd) ',tf= ' num2str(tf) 'sec'];
text(5,0.005,txt,'Fontsize',16);
2
Case 1
B) With a time step size of 0.0025 sec.
3
4
• In This case, The solution is Unconditionally Stable. because, The Diffusion
number bigger than 0.5
∝ (∆𝑡)
𝑑= > 0.5
(∆𝑥)2
• For stable solution
∝ (∆𝑡)
𝑑= ≤ 0.5
(∆𝑥)2
5
(c) Calculate and plot the velocity profile using a time step size of 0.0005 sec
6
(D) Compare the transient solutions obtained in (a) &(c) to the Analytical Transient
Solution at t =1.08 sec.
AT (A) , (C)
-A same result has been calculated.
7
- In FTCS's method, accuracy doesn't change with the Time step change with the
change of Diffusion number.
- The curve of FTCS is Applicable to the curve of Analytical Transient Solution.
𝑎𝑛𝑎𝑙𝑦𝑡𝑖𝑐𝑎𝑙 𝑣𝑎𝑙𝑢𝑒 − 𝑐𝑜𝑚𝑝𝑢𝑡𝑒𝑑 𝑣𝑎𝑙𝑢𝑒
𝐸𝑅 = ( ) ∗ 100
𝑎𝑛𝑎𝑙𝑦𝑡𝑖𝑐𝑎𝑙 𝑣𝑎𝑙𝑢𝑒
ER = 0 %
# The Accuracy of FTCS (CFD) method is excellent .
8
(e)
No, the time t = 1.08 sec not sufficient to reach the steady state solution.
AT ( t = 2 sec )
AT ( t = 3 sec )
9
AT ( t = 4 sec )
-This time is sufficient to reach steady state solution.
10