CFD Applications
CFD Applications
CFD Applications
HEAT TRANSFER
MIA 502E
SPRING 2017
Homework 1
RK-4 method is not suitable for time steps given, Divergent results for 100 of dynamic viscosity :
Problem is explained below with free body diagram and force equlibrium equation for x
direction:
For Re <<1:
Cd=24/Re
For 1<Re<<400:
Cd=24/(Re^0.646)
Re=0.5
Results are given below:
For h=0.1:
%% Explanation of Code
%% Problem Data
m1 = 100; %Dynamic viscosity [kg/ms]
m2 = 100; %Dynamic viscosity [kg/ms]
m3 = 100; %Dynamic viscosity [kg/ms]
x1=zeros(1,length(t1));
x1(1)=2 ;
x2=zeros(1,length(t2));
x2(1)=2 ;
x3=zeros(1,length(t3));
x3(1)=2 ;
y1=zeros(1,length(t1));
y1(1)=0 ;
y2=zeros(1,length(t2));
y2(1)=0 ;
y3=zeros(1,length(t3));
y3(1)=0 ;
%% Numerical Solution
%% For h=0.0001
for i=1:1:(length(t1)-1)
g1 = y1(i) ;
g2 = y1(i)+ (h1*g1/2) ;
g3 = y1(i)+ (h1*g2/2) ;
g4 = y1(i)+ (h1*g3) ;
%% For h=0.001
for i=1:1:(length(t2)-1)
g1 = y2(i) ;
g2 = y2(i)+ (h2*g1/2) ;
g3 = y2(i)+ (h2*g2/2) ;
g4 = y2(i)+ (h2*g3) ;
%% For h=0.005
for i=1:1:(length(t3)-1)
g1 = y3(i) ;
g2 = y3(i)+ (h3*g1/2) ;
g3 = y3(i)+ (h3*g2/2) ;
g4 = y3(i)+ (h3*g3) ;
subplot(3,2,1)
plot(t1,x1)
axis([0 500 -2.5 +2.5])
title('h=0.0001s')
xlabel('t [s]')
ylabel('x [m]')
subplot(3,2,2)
plot(x1,y1)
axis([-2.5 2.5 -150 +150])
title('h=0.0001s')
xlabel('x [m]')
ylabel('y [m]')
subplot(3,2,3)
plot(t2,x2)
axis([0 500 -2.5 +2.5])
title('h=0.001s')
xlabel('t [s]')
ylabel('x [m]')
subplot(3,2,4)
plot(x2,y2)
axis([-2.5 2.5 -150 +150])
title('h=0.001s')
xlabel('x [m]')
ylabel('y [m]')
subplot(3,2,5)
plot(t3,x3)
axis([0 500 -2.5 +2.5])
title('h=0.005s')
xlabel('t [s]')
ylabel('x [m]')
subplot(3,2,6)
plot(x3,y3)
axis([-2.5 2.5 -150 +150])
title('h=0.005s')
xlabel('x [m]')
ylabel('y [m]')
Question 2:
clc
clear
%% Explanation of Code
%% Problem Data
rho_fluid = 1.29 ; % Density of fluid [kg/m^3]
rho_steel = 8000 ; % Density of steel [kg/m^3]
nu = 1.49*(10^-5) ; % Kinematic viscosity [m^2/s]
g = 9.81 ; % Gravitational accelaration [kg/m^3]
x=zeros(1,length(t));
v=zeros(1,length(t));
%% Numerical Solution
A=m_steel+(m_fluid/2);
B=g*(m_steel-m_fluid);
for i=1:1:(length(t)-1)
Re(i)=rho_fluid*v(i)*d/nu;
Cd2(i)=24/Re(i);
Cd3(i)=24/(Re(i)^0.646);
Cd4(i)=0.5;
if Re < 1
Cd(i)=24/Re(i);
elseif Re < 400
Cd(i)=24/(Re(i)^0.646);
else
Cd(i)=0.5 ;
end
C=0.5*rho_fluid*Area ; %(v(i)^2)
g1 = v(i) ;
g2 = v(i)+ (h*g1/2) ;
g3 = v(i)+ (h*g2/2) ;
g4 = v(i)+ (h*g3) ;
figure(1)
subplot(1,2,1)
plot(t,x)
subplot(1,2,2)
plot(t,v)
title('Velocity of Sphere for diameter of d d=0.001m')
xlabel('t [s]')
ylabel('v [m]')
for i=length(Re)
end
figure(2)
hold on
semilogy(Re,Cd, 'LineWidth',1)
semilogy(Re,Cd2,'x')
semilogy(Re,Cd3,'+')
semilogy(Re,Cd4,'g')
legend('Cd','24/Re','(24/(Re^0.646))','0.5')
figure(3)
hold on
semilogy(Re,Cd, 'LineWidth',1)
xlabel('Re')
ylabel('Cd')
legend('Cd')
Question 4:
clc
clear
%% Explanation of Code
%% Problem Data
T=zeros(1,m);
T(1)=473;
Teta=zeros(1,m);
Teta(1)=T(1)-293;
%% Numerical Solution
dAs(i) = (2*L)-(2*((tt-tb)/(l))*y(i)) ;
dAc(i) = (-1*L*(tb-tt))/(l);
end
%Matrix Coefficients
for i=1:1:m-2
a(i) = -2 - (h^2)*(hc*dAs(i)/(k*Ac(i)));
b(i) = 1 + (h*dAc(i)/(2*Ac(i)));
c(i) = 1 - (h*dAc(i)/(2*Ac(i)));
d(i)=0 ;
Domiance_Control(i)=abs(a(i))-abs(b(i)+c(i)) ;
end
d(1)=-c(1)*(Teta(1));
a(m-2)=a(m-2)+(b(m-2)/(1+(h*hc/k)));
alfa(1)=a(1);
gama(1)=d(1);
for i=2:1:m-2
alfa(i)= a(i)-b(i-1)*c(i)/alfa(i-1);
gama(i)=d(i)-gama(i-1)*c(i)/alfa(i-1);
end
Teta(10)=gama(9)/alfa(9);
Teta(11)=Teta(10)/(1+(h*hc/k));
for i=m-2:-1:2
Teta(i)=(gama(i-1)-b(i-1)*Teta(i+1))/alfa(i-1);
end
for i=1:1:m
T(i)=Teta(i)+293;
end
figure(1)
plot(Domiance_Control)
ylabel('|a|-|b+c|')
title('Diagonal Domiance Control')
Refferences: