You are on page 1of 11

KTH ROYAL INSTITUTE OF TECHNOLOGY

School of Engineering Sciences

Course: Applied Numerical Methods


Course code: SF2520

Authors: 1) Andreas Angelou


2) Vasileios Papadimitriou
3) Dionysios Zelios

Lab name: Model of a Heat Exchanger

Date of submission: 13/01/2014

CONTENTS

Part A ..3
Part B4
Part C5
Part D..6
Part E...8

Appendix..10

References.11

Model of a Heat Exchanger


In this exercise a hyperbolic partial differential equation modeling a heat exchanger is
studied. A fluid of temperature T(x,t) is flowing with constant speed u in a pipe. Outside the
pipe there is a cooling medium that keeps a constant low temperature Tcool. The
temperature of the fluid in the pipe is initially cool, i.e., T=Tcool but within a short time
period hot fluid enters the pipe. The task is to study how the temperature T(x,t) of the fluid
in the pipe depends on x and t.
The following PDE model is given:

T 1 T

k (T Tcool ) 0
x u t

0 x L

with the initial condition T ( x, 0) Tcool and the boundary condition

Tcool (Thot Tcool )sin( t ) , 0 t 0.5

T (0, t ) hot
, 0.5 t 4
Thot Tcool sin( (t 4))
,t 4

The length of the heat exchanger is L=3. The heat exchanger parameter is k=0.1, the velocity
u=1, the cooling temperature Tcool=5 and the hot temperature is Thot=100.

Part A
We want to show that our problem can be scaled to

u u

(u ) 0 , 0 1 .

Starting from our initial differential equation and using the following change of variables
T 5u , x L 3 , 3t , we have:

(5u ) (5u )
1 u 1 u

0.1(5u 5) 0

0.1(u 1) 0
(3 ) (3 )
3 3
u u

0.3(u 1) 0 , with 0 1

The initial condition is then transformed: u ( , 0) 1 , 0 and the boundary condition

100 5

1 ( 5 )sin( )
, 0 0.5

becomes: u (0, ) 100 / 5


, 0.5 4

Thot Tcool sin( ( 4)) , 4

, 0 0.5
1 19sin( )

u (0, ) 20
, 0.5 4
20 sin( ( 4) , 4

Part B
We discretize the scaled version of the problem initially with the method of lines (MoL). We
introduce grid points i=ih, i=0,1,n, n=1. We approximate

u i

ui

u i 1
dx

0.3 (u i 1)

u i

u
at the point i with u i u i1 .

dx

1
(1 0.3dx) u i u i1] 0.3
dx

The initial condition is u(0)=1 and the boundary condition is

1 19sin(3 ) , 0 0.5

u (0, ) 20
, 0.5 4
20 sin( ( 4) , 4

The PDE problem it then approximated by a system of ODEs:

du
Au b( ) ,
d

0
0
(1 0.3dx)

(1 0.3dx)
0
1
1
(1 0.3dx)
1 0
where A is A
*
0
1
dx 0

0
0

0
0

00

00

00

00

1 (1 0.3dx)

0.3 ( )
1


0.3

1
and u is u (0) 1
b is b( ) 0.3


0.3

We already know that the theoretical stability result based on eigenvalue analysis as
presented for ODE systems in chapter 3 of the book is not correct for the hyperbolic PDE
model problem. The reason for this is that the eigenvalues of A are all equal, which implies
an initial polynomial growth of the solution of the difference equation.
We therefore use von Neumann analysis based on Fourier analysis to decide if our ODE is
stable or not.
We conclude that the time-stepsize should be approximately 0.2 times the space-stepsize in
order to have a stable system.

Part C
We solve the ODE system in part B with the explicit Euler method, constant time step t.
We investigate numerically how the largest constant time step tmax, preserving the stability
of the numerical solution, depends on the stepsize h defined in part B.
We find tmax for N=10,20 and 40.
N
10
20
40

tmax
0.002
0.0008
0.0004

Solving the PDE system in part B, we expect to have a hyperbolic graph which shows that the
temperature is always increasing, since there is no boundary condition at the end of the pipe
that affects it.
We also show graphically the unstable numerical solution for the case N=20, when
tmax< t=0.05.

Part D
We work out a difference formula of Lax-Wendroff type that solves the PDE problem in part
A.
Our initial scaled differential equation is

d
d

u u

0.3(u 1) 0 (1)

u
u

0.3(u 1) (2)

2
2u
d 2u
du
u
u d u

0.3

0.6
0.09(u 1) (3)


2
2
d
dt
d
d

The Taylor expansion at the point (i,k):

uik 1 uik ht

uik ht 2 2uik

O(ht3 )
2
d
2

By developing our PDE (1) in terms of Taylor expansion and using (2) and (3) equations, we
have:

uik 1 uik ht (

uik
h 2 2uik
u k
0.3[uik 1]) t [
0.6 i 0.09(uik 1)] (4)

Using the central difference approximations:

uik uik1 uik1

(6)

2hx

2uik uik1 2uik uik1


(5)

2
hx2
We have:
uik 1 uik (1 0.3ht

ht 2 0.09ht 2
ht
ht 2 0.6ht 2
ht
ht 2 0.6ht 2
0.09ht 2
k
k

u
(

u
(

0.3
h

i 1
i 1
t
hx2
2
2hx 2hx2
4hx
2hx 2hx2
4hx
2

Hence:

ht ht 2 0.6ht 2
c1

2hx 2hx2 4hx


ht 2 0.09ht 2
c2 1 0.3ht 2
hx
2
ht ht 2 0.6ht 2
c3

2hx 2hx2 4hx


0.09ht 2
c4 0.3ht
2

Part E
We program the Lax-Wendroff formula in part D as a Matlab program and we run it for
h=0.1 and t=0.002 and we present the result in a 3D plot.

Appendix
% Matlab code, Lab 6
% Andreas Angelou, Vasileios Papadimitriou, Dionysios Zelios
clear
clc
close all
N = 10;
%total spacesteps
dx = 1/N;
%space stepsize
T=10;
%total time (seconds)
dt = 0.01; %time stepsize
A = zeros(T/dt,N);
%setting up matrix A
A(1,1) = -(1/dx)-0.3;
for i = 2:N
A(i,i) = -(1/dx)-0.3;
A(i,i-1) = (1/dx);
end
for k=1:N
u0(k)=1;
end
U=zeros(T/dt,N);
%setting the solution matrix
U(1,:)=u0;
b = zeros(T/dt,1);
%setting the boundary matrix
a =1;
b(1) =0.3+a;
%initiating the boundary matrix
for t = 2:(T/dt)
b(t) = 0.3;
end
for t = 1:(T/dt)
%working on the inner points
for i = 1:N
if t*dt < (0.5/3) && t*dt > 0
a = 1+ 19*sin(3*pi*t);
else if t*dt >(4/3)
a = 20 + sin(pi*(3*t-4));
else
a=20;
end
end
b(1) = 0.3+a;
U(t+1,i) = U(t,i)+dt*(A(t,i)*U(t,i)+b(t));
end
end
mesh(U)
xlabel('Space(scaled)')
ylabel('Time(scaled)')
zlabel('Temperature(scaled)')
title('Unstable solution')

% Lax Wendroff
clear
clc
close all
N = 10;
%total spacesteps
dx = 1/N;
%space stepsize
T=10;
%total time (seconds)
dt = 0.002; %time stepsize
for k=1:N

u0(k)=1;
end
U=zeros(T/dt,N);
%setting the solution matrix
U(1,:)=u0;
b = zeros(T/dt,1);
%setting the boundary matrix
a =1;
b(1) =a;
%initiating the boundary matrix
for t = 1:(T/dt)
%working on the inner points
for i=2:N-1
if t*dt < (0.5/3) && t*dt > 0
a = 1+ 19*sin(3*pi*t);
else if t*dt >(4/3)
a = 20 + sin(pi*(3*t-4));
else
a=20;
end
end
b(1) = a;
U(t+1,i) = U(t,i-1)*((dt/(2*dx))-((dt^2)/(2*(dx)^2))(0.6*(dt)^2/(4*dx)))+U(t,i)*(1(0.3*dt)+((dt)^2/(dx)^2)+(0.09*(dt)^2/2))+U(t,i+1)*(-dt/(2*dx)((dt)^2/(2*(dx)^2))+(0.6*(dt)^2/(4*dx)))+0.3*dt-(0.09*(dt)^2)/2;
end
% U(t+1,N) = 2*U(t,N-1)*((dt/(2*dx))-((dt^2)/(2*(dx)^2))(0.6*(dt)^2/(4*dx)))+U(t,N-2)*(1(0.3*dt)+((dt)^2/(dx)^2)+(0.09*(dt)^2/2))+0.3*dt-(0.09*(dt)^2)/2;
U(t,N) = 2*U(t,N-1)-U(t,N-2);
end
mesh(U)
xlabel('Spacesteps')
ylabel('Timesteps')
zlabel('Temperature(/5)')

References
Introduction to computation and modeling for differential equations,
Lennart Edsberg

You might also like