Problem 5: Cooling a pipe by external flow
1. Sumary
Initial condition:
Boundary condition:
Data: ; ; ; ; ; ;
a) Analytical solution
The analytical solution is:
b) Numerical solution
The finite different method is applied for solving the PDE.
Discrete the domain
(Up-wind scheme)
Equation (1) at node 1, (node 0 is boundary condition):
At node 2:
At node n:
We can rewrite at matrix form:
1
And
then we can use the ODE solver to solve that equation.
2. Solution
global K1 K2 Tw Tini Tbound A b
% --- declare constant variable
F = 0.001; %[m3/s]
U = 50000; %[W/m2K]
rho = 997; %[kg/m3]
Cp = 4182; %[J/kg]
D = 0.1; %[m]
Tw = 300; %[K]
Tbound = 373; %[K]
Tini = 373; %[K]
% --- compute the coefficient
K1 = 4*F/(pi()*D^2);
K2 = 4*U/(rho*Cp*D);
% --- Domain
L = 1; %[m]
% --- Computation
tstop = 10; %[s]
a) Analytical solution
% Plot
L = 1; % The length of pipe
x = linspace(0,1,50);
t = linspace(0,tstop,20);
Temp=[];
figure;
subplot(1,2,1)
for i = 1:length(t)
Temp = [Temp; asol(x,t(i))];
plot(x,Temp(i,:))
hold on
end
title('Analytical solution'); xlabel('Length (m)'); ylabel('Temperature K');
2
b) Numerical solution
% --- Construct the matrix A and b
N = 100; % Number of node you want to devide the domain
x = linspace(0,L,N+1);
dx = x(2)-x(1);
% --- The right hand side equation : A*T+b
% --- A is Diagonal matrix NxN
% --- B is vector Nx1
A = diag(ones(N-1,1),-1)*(K1/dx)+diag(ones(N,1))*(-K2-K1/dx); %
b = ones(N,1)*(K2*Tw);
b(1) = K2*Tw + K1/dx*Tbound;
% --- solving
T0 = ones(N,1)*Tini; % vector initial value
[t u] = ode15s(@nsol,[0 tstop],T0);
v = [ones(1,length(t))*Tbound; u'];
subplot(1,2,2)
plot(x,v);
title('Numerical solution');xlabel('Length (m)');ylabel('Temperature K');
3
4