You are on page 1of 9

Finite Difference Methods in 2d Heat Transfer

V.Vuorinen
Aalto University School of Engineering
Heat and Mass Transfer Course, Autumn 2016

November 2nd 2016, Otaniemi


ville.vuorinen@aalto.fi
Overview
• Previously you learned about 0d and 1d heat transfer problems and their numerical
solution
• Here we extend things into 2d (3d) cases which is straightforward
• We consider the simple case of a square domain but the idea can be extended and
generalized to arbitrary domains using standard CFD methods like finite volume methods
or finite element methods
Discretization by Finite Difference
Method
General form of heat equation Terms opened in 2d
∂T ∂T ∂ ∂ T ∂ ∂T
=∇⋅α ∇ T = α + α
∂t ∂t ∂x ∂ x ∂ y ∂ y
Time derivative in cell (i, j) at timestep n Second space derivatives at at cell (i,j)
n n+1 n 2 n n n n
T i , j −T i , j T i +1, j−2 T i , j +T i−1, j
∂T
( )
∂ t i, j

Δt
X:
( )
∂ T
∂ x2 i, j

Δ x2
2 n n n n
T i , j +1−2 T i , j +T i , j−1
Y:
( )
∂ T
∂y
2
i, j

Δy
2
Discretization by Finite Difference
Method
αΔ t
CFL=
Explicit Euler timestepping for 2d heat equation: Δ x2
n n n n n n
n+1 n T i +1, j −2 T i , j +T i −1, j T i , j+1 −2 T i , j +T i , j−1
T i,j =T + Δ t α
i, j 2
+Δ t α
Δx Δ y2
Which is equal to the “delta” form:
n n n n n n
n T i +1, j −2 T +T
i, j i−1, j T i , j+ 1 −2 T + T
i, j i , j −1
Δ T =Δ t α
i, j 2
+Δ t α 2
Δx Δy
Where:

Δ T ni , j=T ni ,+1j −T ni , j
Visualization of 2d Cartesian Grid
x=0 x=Lx This corner
cell would be
Ghost cells “idle”/useless
where
y=Ly
boundary
conditions Ghost cells
given. For example: T ni , j +1 where
Zero gradient:
boundary
n n n n n n conditions
T ghost =Ti−1, j T ghost T i−1, j T i,j T i+1, j given
Fixed temperature:
T nghost =2 T target −T ni−1, j T ni , j −1
y=0

Δy
Cell face center Cell center
Δx
Summary of the Numerical Solution
Scheme for 2d Heat Equation
(Known and
1) Set boundary conditions (BC's) to the ghost cells T ni , j hence BC
using T from step n. update possible)

2) Update new temperature at timestep n+1 in the T


n+1 n
=T +Δ t α
T ni +1, j −2 T ni , j +T in−1, j
+Δ t α
T ni , j+1 −2 T ni , j +T ni , j−1
internal cells i,j i, j
Δ x2 Δ y2

T n+1
i,j
3) Update time according to t = t + dt
t n+1 =t n +Δ t

4) Go back to 1)
Also This Scheme is Extremely Short
to Program in Matlab
Program: /Examples2d/HeatDiffusion2d.m
Execution: >> HeatDiffusion2d
What it does: Solves 2d heat equation in Cartesian grid, various BC's possible.
It is also possible to simulate materials with variable heat diffusivity to simulate
conduction in e.g. “layered” materials.
The “heart” of this 2d code is the computation of dT in the .m file computedT.m
dT=dt*DivDiv(T,nu,east,west,north,south,inx,iny,dx,dy);

- In short the “cryptic” function DivDiv.m is needed to evaluate


divergence of the diffusive flux (conservatively) i.e. ∇⋅α ∇ T
- The contents of the function DivDiv.m looks lengthy but it is
so only to account for the fact that the code assumes diffusivity (x,y) - dependent.
The function solveTemperature.m applies the 4th order Runge-Kutta method
(for better stability than Euler) to evaluate dT several times and finally
accumulates them together to end up in essentially the same outcome as Euler
method. 
T new =T old + Δ T
Tleft =500K Tright=293K Tleft = Ttop = 500K

Tright =
293K

Bottom and top walls are zero gradient Bottom wall is zero gradient i.e. isolated
keeping solution 1d
Tleft =500K Tright=293K
Top & Bottom zero gradient
Conducting

Isolated area
In the Non-
domain conducting
Thank you for your attention!

You might also like