UCES
Course: Methods and Analysis in UCES
Applied Area: diffusion in 2D, partial differential equation
Model: finite differences, block tridiagonal matrix
Method: block tridiagonal, block SOR and point SORalgorithms
Assessment: derivative boundary conditions, existence
Prerequisites:
Objectives:
General Information: This is the first model for diffusion in two directions. In the next section we will present similar models which are related to fluid flow.
Contact Person: R. E. White, NCSU, white@math.ncsu.edu
Revision Date: 8-3-94
Copyright ©1994, R. E. White. All rights reserved.
This section contains an introduction to heat transfer models with diffusion in two directions. Such models generate block tridiagonal algebraic systems. We present several algorithms for solving such problems.
![]() |
| Figure: Diffusion in Two Directions |
In order to model the temperature, we will first assume
temperature is given along the 2D boundary and that the thickness T is small.
Consequently, there will be diffusion in just the x and y directions. Consider
a small mass within the above plate whose volume is
| change in heat of (dx dy T) = 0 |
f(x,y) (dx dy T) dt |
| + (2 dx dy) dt c(usur - u) | |
| + (dx T) dt (Kuy(x,y + dy) - Kuy(x,y)) | |
| + (dy T) dt (Kux(x + dx,y) - Kux(x,y)). |
This approximation gets more accurate as dx and dy go to zero. So, divide by (dx dy T) dt and let dx and dy go to zero. This gives a differential equation with partial derivatives, and (1) is an example of a partial differential equation.
Steady State 2D Diffusion.
| 0 = f(x,y) + (2c/T)(usur - u) + (Kux(x,y))x + (Kuy(x,y))y | (1) |
The above partial differential equation is usually associated with boundary
conditions which may or may not have derivatives of the solution. For the
present we will assume the temperature is given as a constant on the boundary
of
| -uxx - uyy + cu = cusur . | (2) |
Let uij be the approximation of
Finite Difference Model of (2)
i,j
n - 1.
There are (n - 1)2 equations for (n - 1)2 unknowns
uij . This can be put into matrix form by multiplying the equations
by h2 and listing the unknowns starting with the smallest y values
and moving from the smallest to the the largest x values. The first grid row
of unknowns is denoted by
![]() |
| Figure: Grid for 2D Diffusion |
Hence, the block form of the above system is
The above block tridiagonal system is a special
case of the following block tridiagonal system where all entries are
.
We present three alternatives to the Gaussian elimination algorithm. The first method is a block version of the tridiagonal algorithm. It requires only order 3N4 operations and less storage than the full version of the Gaussian elimination algorithm. The other two algorithms are variations on the SOR method and can require, for proper choice of SOR parameter, fewer operations and less storage.
In the block tridiagonal algorithm all entries are matrices. The "divisions" for the point form must be replaced by matrix solves, and one must be careful to preserve the proper order of matrix multiplication. The derivation of the following is similar to the derivation of the point form.
(1) = A(1)
solve
(1)*
(1) = C(1)
solve
(1)*Y(1) = D(1)
for i = 2, n
(i) = A(i)- B(i)*
(i-1)
solve
(i)*
(i) = C(i)
solve
(i)*Y(i) = D(i) - B(i)*Y(i-1)
endloop
X(n) = Y(n)
for i = n - 1,1
X(i) = Y(i) -
(i)*X(i+1)
endloop.
The block or line version of the SOR algorithm also requires a matrix solve step in place of a "division." Note the matrix solve has a point tridiagonal matrix for the problem in (2).
for m = 1,maxit
for i = 1,n
solve A(i) Xtemp = D(i) - B(i)*X(i-1) - C(i)*X(i+1)
X(i) = (1-w)*Xtemp + w*X(i)
endloop
test for convergence
endloop.
The point version of SOR for the problem in (2) can be very effectively implemented because we know exactly where and what the nonzero components are in each row of the coefficient matrix. In the following note how the test for convergence is done and how the storage is kept to a minimum.
Point SOR Algorithm for
-(uxx + uyy ) + cu = f(x,y) on
= (0,1)×(0,1)
.
define w, n, eps
h = 1/n
tol = eps*h*h
for m = 1,maxit
numi = 0
for j = 1,n-1
for i = 1,n-1
utemp = (h*h*f(i*h,i*h) + u(i,j-1) + u(i-1,j) +
u(i+1,j) + u(i,j+1))/(4 + h*h*c)
utemp = (1 - w)*u(i,j) + w*utemp
error = abs(utemp - u(i,j))
u(i,j) = utemp
if error < tol then
numi = numi + 1
endif
endloop
endloop
if numi = (n-1)*(n-1) go to end
endloop
end.
Maple is used to code the point SOR algorithm for a cooling plate which has a
fixed temperature at its boundary. Two sets of outputs are graphed. The
first one is with the cooling constant
Maple Code for a Cooled Plate and Point SOR.
3.4.5. Implementation.
Input Data:
> with(linalg):
> with(plots):
> c:=.4:
> usur:= 70:
> eps:=.1:
> n:= 8:
> w:=1.4:
> f:=(x,y)->c*usur:
Procedure BVP2D and SOR is Defined:
> BVP2D:=proc(f,c,n,w,eps):
> u:=matrix(n+1,n+1,200):
> h:=1/n:
> maxit:=400:
> tol:=eps*h*h:
> for m from 1 to maxit do
> numi:=0:
> for j from 2 to n do
> for i from 2 to n do
> utemp:= evalf((h*h*f(i*h,j*h) + u[i,j-1] + u[i-1,j]
+ u[i+1,j] + u[i,j+1])/(4 + h*h*c)):
> utemp:= (1-w)*u[i,j] + w*utemp:
> error:= abs(utemp - u[i,j]):
> u[i,j]:= utemp:
> if error < tol then
numi:=numi + 1
fi:
> od:
> od:
> if numi = (n-1)*(n-1) then break fi:
> od:
> end:
Output Data:
> BVP2D(f,1.,8,1.4,.1):
> matrixplot(u,style=wireframe,axes=boxed);
![]() |
| Figure: Temperature of Cooled Plate, c = 1.0 and x and y Trace Curves |
> numi;
49
> m;
19
> BVP2D(f,10.,8,1.4,.1):
> matrixplot(u,style=wireframe,axes=boxed);
![]() |
| Figure: Temperature of Cooled Plate, c = 10.0 and Contour Curves |
The following Matlab code for the numerical solution of
sin(
x)
sin(
y) on
illustrates the SOR algorithm and how it depends on the choice of the
SOR parameter,
.
function [w,soriter] = sor2d(n,w)
h = 1./n;
tol =.1*h*h;
maxit = 500;
u = zeros(n+1);
f = zeros(n-1);
for i=2:n
for j=2:n
f(i,j) = h*h*pi*pi*sin(pi*(i-1)*h)*sin(pi*(j-1)*h);
end
end
for iter =1:maxit
numi = 0;
for j = 2:n
for i = 2:n
utemp = (f(i,j) + u(i,j-1) + u(i-1,j) + u(i+1,j) + u(i,j+1))*.25;
utemp = (1. - w)*u(i,j) + w*utemp;
error = abs(utemp- u(i,j));
u(i,j) = utemp;
if error<tol
numi = numi + 1;
end
end
end
if numi==(n-1)*(n-1)
break;
end
end
w;
soriter = iter;
Output in Graphical Form:
>>for i = 1:20
[x(i),y(i)] = sor(20,1. + (i-1)*.05);
end
>>plot(x,y)
![]() |
Figure: Iterations for Convergence versus
![]() |
In the above first 2D heat diffusion model we kept the boundary conditions
simple. However, in the 2D model of the cooling fin
one should consider the heat that passes through the edge portion of the fin.
This is similar to what was done for the cooling fin with diffusion in just the
x direction. There the heat flux at the tip was given by the boundary
condition
3.4.6. Assessment.
![]() |
| Figure: Cooling Fin with Boundary Conditions |
The finite difference model must have additional equations for the cells near
the edge of the fin. So, in the above figure there are 10 equations for the
The other portions of the boundary are similar.
Another question is related to the existence of solutions. Note the diagonal components of the coefficient matrix are much larger than the off-diagonal components. For each row the diagonal component is strictly larger than the sum of the absolute value of the off-diagonal components. In the finite difference model for (2) the diagonal component is 4/h2 + c and the four off-diagonal components are -1/h2.
Definition. Let A = [aij ]. A is called strictly diagonally dominant if and only if for all i
Examples. The one and two dimensional models of heat diffusion give strictly diagonally dominant matrices.
Existence Theorem. Consider Ax = d and assume A is strictly diagonally dominant. If there is a solution, it is unique. Moreover, there is a solution.
Proof. Let x and y be two solutions. Then A(x - y) = 0. If x - y is
not zero, then we can choose i so that
Divide by (xi - yi ) and use the triangle inequality to contradict the strict diagonal dominance.
The existence follows from the uniqueness. Since the matrix is square, we can
find elementary matrices such that