Вы находитесь на странице: 1из 11

# Paper ENCN304 – Deterministic Mathematical Methods

## Module 5 – Numerical Solution of PDEs

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

## At the conclusion of this module you should:

1. Understand the philosophy behind the finite difference method for solving
PDEs.

## 2. Be able to construct and solve a system of linear equations that approximate

Laplace’s equation in a rectangular domain for both temperature and flux
boundary conditions.

## 3. Be able to construct stable numerical solutions to the diffusion equation using

both the explicit and implicit finite difference schemes.

4. Understand the error associated with the various finite difference techniques for
solving Laplace’s equation and the diffusion equation.

References

## ENCN304 PDEs – Module 5 Summary 1 Copyright © Dr Roger Nokes 2013

Key Points

1. Laplace’s Equation

## Laplace’s equation is solved numerically in a rectangular domain with the following

steps:

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.

## 3. Equation 1 is constructed for each node at which u is unknown. For boundaries

where u is specified by the boundary conditions this will include all internal nodes in
the domain. On a boundary where a normal derivative is specified this will include the
boundary nodes as well.

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.

## ENCN304 PDEs – Module 5 Summary 2 Copyright © Dr Roger Nokes 2013

2. Normal Derivative Boundary Conditions

## To handle boundary conditions where the normal derivative of u is specified nodes

must be created outside, and adjacent to, the boundary. These are referred to as
shadow nodes. The normal derivative boundary condition is then used to relate the
unknown u at the shadow node with that at the node just inside the boundary. For
example consider the boundary illustrated in figure 5.2.

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

## u−1, j = u1, j − 2hα (4)

Thus when equation 1 is written for the boundary node equation 4 can be used to
eliminate the shadow node from the equation.

## 3. The Diffusion 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:

## ENCN304 PDEs – Module 5 Summary 3 Copyright © Dr Roger Nokes 2013

1. A rectangular computational mesh is overlaid on the problem domain. The mesh
has a spacing of h in the x direction and k in the t direction.

## 2. A forward or backward finite difference is used to approximate the time

derivative and a central difference the spatial derivative. The forward difference leads
to the explicit scheme and the backward difference to the implicit scheme. The
computational molecules for these two schemes are given in figure 5.3 and 5.4 and the
algebraic approximations to the PDE are given in equations 5 and 6.

## Figure 5.4. The implicit method computational molecule.

(
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

## 3. The explicit scheme is stable only if r < 12 . The implicit scheme is

unconditionally stable. The error for both schemes is second order in h and first order
in k.

## 4. The solution is constructed at nodal values by marching the solution forward in

time from the initial condition. Thus if j = 0 corresponds to t = 0, setting j = 0 in
equation 5 or 6 enables the nodal values at j = 1 to be computed and so on. For the

## ENCN304 PDEs – Module 5 Summary 4 Copyright © Dr Roger Nokes 2013

explicit scheme these values are computed explicitly one at a time. For the implicit
scheme all nodal values at the new time are related through equation 6 and a system
of linear equations must be solved in order to find the nodal values at the new time.

5. When gradient boundary conditions are specified shadow nodes are used as
described above.

Worked Examples

Question 1

## The steady flow of groundwater in a confined aquifer is governed by Laplace’s

equation

∂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.

## Figure. Problem domain, computational mesh and boundary conditions.

(b) Given that all boundary conditions are in terms of the head within the aquifer
only three nodal values need to be determined.

## To construct the governing algebraic equations the computational molecule is laid on

each of the unknown nodes in turn. This yields the following three equations:

## ENCN304 PDEs – Module 5 Summary 6 Copyright © Dr Roger Nokes 2013

h1,2 + h2,1 − 4h1,1 + h0,1 + h1,0 = 0
h2,2 + h3,1 − 4h2,1 + h1,1 + h2,0 = 0
h3,2 + h4,1 − 4h3,1 + h2,1 + h3,0 = 0

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 ⎠

## The solution to this system of equations, using MATLAB, is

⎛ 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⎠

## ENCN304 PDEs – Module 5 Summary 7 Copyright © Dr Roger Nokes 2013

You should choose a spatial node spacing of 0.5m and a suitable temporal node
spacing that ensures that the method is stable. Perform 5 iterations of the technique.

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

## We will choose k = 0.25s and thus

κ k 0.25 × 0.2
r= = = 0.2
h2 0.52

The computational mesh and the problem domain are shown in the figure.

## Figure. The computational mesh.

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.

## ENCN304 PDEs – Module 5 Summary 8 Copyright © Dr Roger Nokes 2013

Table. Solution using the explicit method.

## t (s) j u0,j u1,j u2,j u3,j u4,j

0 0 0 0.1875 0.25 0.1875 0
0.25 1 0 0.163 0.225 0.163 0
0.50 2 0 0.143 0.200 0.143 0
0.75 3 0 0.126 0.177 0.126 0
1.00 4 0 0.111 0.156 0.111 0
1.25 5 0 0.098 0.138 0.098 0

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

## with boundary conditions

∂u
u(0,t) = 0 ( 0.8,t ) = 0.125
∂x

## κ k 2.3× 10−5 × 200

r= = = 0.115
h2 0.22

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

## ENCN304 PDEs – Module 5 Summary 9 Copyright © Dr Roger Nokes 2013

u5, j = u3, j + 2hα

## Figure. The computational mesh.

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.23u1, j+1 − 0.115u2, j+1 = u1, j

( )
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

## 1.23u4, j+1 − 0.23u3, j+1 = u4, j + 0.00575

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

## ⎛ u1, j+1 ⎞ ⎛ u1, j ⎞

⎛ 1.23 −0.115 0 0 ⎞⎜ ⎟ ⎜ ⎟
⎜ ⎟⎜ u2, j+1 ⎟ ⎜ u2, j ⎟
⎜ −0.115 1.23 −0.115 0 ⎟⎜ ⎟ =⎜ ⎟
⎜ 0 −0.115 1.23 −0.115 ⎟ ⎜ u3, j+1 ⎟ ⎜ u3, j ⎟
⎜⎝ 0 0 −0.23 1.23 ⎟⎠ ⎜⎜ ⎟ ⎜ ⎟
⎝ u4, j+1 ⎟⎠ ⎜⎝ u4, j + 0.00575 ⎟⎠

## ENCN304 PDEs – Module 5 Summary 10 Copyright © Dr Roger Nokes 2013

Thus the solution process involves

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.

## t (s) j u0,j u1,j u2,j u3,j u4,j

0 0 0 0 0 0 0
200 1 0 0.0000 0.0000 0.0004 0.0048
400 2 0 0.0000 0.0001 0.0012 0.0088
600 3 0 0.0000 0.0003 0.0021 0.0122

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.

## Нижнее меню

### Получите наши бесплатные приложения

Авторское право © 2021 Scribd Inc.