Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Summary
This module introduces the finite difference method for solving the diffusion and
Laplace’s equations numerically.
Prerequisites
You should have completed the Introduction to Diffusion material in Module 4 and
have a sound grasp of the methods for the numerical solution of ODEs and systems of
linear equations.
Objectives
1. Understand the philosophy behind the finite difference method for solving
PDEs.
4. Understand the error associated with the various finite difference techniques for
solving Laplace’s equation and the diffusion equation.
References
1. Laplace’s Equation
1. The domain is overlaid with a square grid of nodes, with spacing h. The unknown u
is only calculated at the nodal positions. These nodes are designated with indices (i,j)
and the unknown at a node is referred to as ui,j.
2. The derivatives in Laplace’s equation are approximated with second order central
finite difference approximations leading to the algebraic relationship between the
nodes surrounding node (i,j) give in equation 1.
4. The resulting system of sparse linear equations is solved for the unknown nodal
values using standard techniques.
5. The error associated with this approximation Laplace’s equation is second order
in the mesh spacing.
Figure 5.2. Illustration of the shadow node used to handle the gradient boundary
condition.
∂u
=α (2)
∂x
u1, j − u−1, j
=α (3)
2h
or
Thus when equation 1 is written for the boundary node equation 4 can be used to
eliminate the shadow node from the equation.
The approach taken to solve the diffusion equation differs from that applied to
Laplace’s equation because the time variable is semi-infinite and a finite
computational mesh that covers all time cannot be constructed. In this case the
solution is marched forward in time starting with the initial condition. The solution
process has the following steps:
(
ui, j+1 = (1− 2r)ui, j + r ui+1, j + ui−1, j ) (5)
( )
(1+ 2r)ui, j+1 − r ui+1, j+1 + ui−1, j+1 = ui, j (6)
where
κk
r= (7)
h2
5. When gradient boundary conditions are specified shadow nodes are used as
described above.
Question 1
∂2 h ∂2 h
+ =0
∂x 2 ∂y 2
where h is the piezometric head. The confined aquifer lying between the Rakaia and
Ashburton rivers in South Canterbury is modelled as a rectangle of width 50km (the
distance between the rivers) and 100km long. The head on the river and sea
boundaries is approximately 0m while that on the inland boundary it is 40m.
(a) Draw the aquifer, indicate the boundary conditions and overlay a computational
mesh with a spacing of 25km.
(b) Calculate the head distribution in the aquifer using the finite difference method.
Solution
(a) The flow domain is a rectangle of width 50km and length 100km. Let’s choose
the rectangle to lie between x = 0 and x = 100, and y = 0 and y = 50. So the
Ashburton river is the y = 50 boundary, the Rakaia river is the y = 0 boundary, the sea
is the x = 0 boundary and the inland boundary is at x = 100. This is shown in the
figure with the computational mesh overlaid.
(b) Given that all boundary conditions are in terms of the head within the aquifer
only three nodal values need to be determined.
All nodal values except the three unknowns are given by the boundary conditions thus
the equations become
0 + h2,1 − 4h1,1 + 0 + 0 = 0
0 + h3,1 − 4h2,1 + h1,1 + 0 = 0
0 + 40 − 4h3,1 + h2,1 + 0 = 0
or in matrix form
⎛ −4 1 0 ⎞ ⎛ h1,1 ⎞ ⎛ ⎞
⎜ 1 −4 1 ⎟ ⎜⎜ h2,1 ⎟ ⎜ 0 ⎟
⎜ ⎟⎜ ⎟ =⎜ 0 ⎟
⎝ 0 1 −4 ⎠ ⎝ h3,1 ⎟ ⎝ −40 ⎠
⎠
⎛ h1,1 ⎞ ⎛ ⎞
⎜ ⎟ ⎜ 0.71 ⎟
⎜ h2,1 ⎟ = ⎜ 2.86 ⎟
⎜ h ⎟ ⎝ 10.71 ⎠
⎝ 3,1 ⎠
Note: This problem is solved using separation of variables in the Module 7 summary
and the solutions can be compared if you wish.
Question 2
Using the explicit finite difference method find the temperature distribution in a 2m
long rod, which has a thermal diffusivity of 0.2 m2/s, given the following boundary
and initial conditions
u(0,t) = 0 u(2,t) = 0
x⎛ x⎞
u(x,0) = ⎜ 1− ⎟
2 ⎝ 2⎠
Solution
Firstly we must choose the time step to ensure stability. The requirement is
κk 1 h2 0.52
r= < ⇒ k < = = 0.625
h2 2 2κ 2 × 0.2
κ k 0.25 × 0.2
r= = = 0.2
h2 0.52
The computational mesh and the problem domain are shown in the figure.
Using the explicit method we use the computational molecule in figure 5.3 and the
following algebraic equation.
(
ui, j+1 = 0.6ui, j + 0.2 ui+1, j + ui−1, j )
This method is easily implemented in a spreadsheet and the results are in the table
below. Note that nodal values known from the initial or boundary conditions are given
in bold.
Note: This problem is solved in the Module Summary for Module 6 using separation
of variables. The two solutions can be compared if you wish.
Question 3
Use the implicit finite difference scheme to find the temperature distribution in an
iron bar of length 0.8m, with thermal diffusivity of 2.3x10-5 m2/s and thermal
conductivity of 80 J/Kms, which has one end held at 0 degrees and the other end has
an imposed heat flux of 10 J/m2-s into the bar. Initially the bar is at 0 degrees.
Choose a spatial nodal spacing of 0.2m and time step of 200s. Perform 3 iterations.
Solution
We must solve
∂u ∂2 u
= 2.3 × 10 −5 2
∂t ∂x
∂u
u(0,t) = 0 ( 0.8,t ) = 0.125
∂x
To solve this using the implicit method each set of new temperatures must be solved
simultaneously where the system of linear equations is constructed using
( )
(1+ 2r)ui, j+1 − r ui+1, j+1 + ui−1, j+1 = ui, j
at each unknown node. Because the right hand boundary is a flux boundary it is
necessary to solve for the right hand boundary values as well as the values at the
internal nodes. We will use equation 4 to relate the shadow nodal value to that inside
the domain. It gives
Thus at each time step there are 4 nodal values, corresponding to i = 1, 2, 3 and 4, that
must be computed. We can write down the equation for each of these nodes. They are
( )
1.23u2, j+1 − 0.115 u3, j+1 + u1, j+1 = u2, j
1.23u3, j+1 − 0.115( u4, j+1 )=u
+ u2, j+1 3, j
where the flux boundary condition has been incorporated into the last equation. These
equations can be written as a matrix equation where only the right hand side changes
as the solution is marched forward in time. The equation is
1. Set j = 0. The right hand side is then given by the initial condition of zero
temperature. The matrix equation is solved for the j = 1 temperatures.
2. For two more iterations j is incremented and the matrix equation is resolved.
The solutions at the last time step as used in the right hand side for the next
time step.
Note: This problem is solved in the Module Summary for Module 6 using separation
of variables. The two solutions can be compared if you wish.