4 An explicit numerical method for the heat equation
The approximations used above for approximating partial derivatives can now be applied in order to derive a numerical method for solving the heat conduction problem
In order to specify the numerical method we choose values for and and use these in approximations of the two derivatives in the partial differential equation. It is convenient to divide the interval into equally spaced subintervals so, in effect, we choose a whole number so that .
Key Point 15
In order to specify the numerical procedure for solving the heat conduction equation
Figure 3
The diagram above shows the independent variables and at which we seek the function . The numerical solution we shall find is a sequence of numbers which approximate at a sequence of points.
Key Point 16
The numerical approximations to that we will find will be approximations to at values where the horizontal and vertical lines cross in the above diagram (Figure 3).
The notation we use is that
The idea is that the subscript counts how many “steps" to the right we have taken from the origin and the superscript counts how many time-steps (up, on the diagram) we have taken. To say this another way
For example, consider the point on Figure 3 which is highlighted with a small square. This point is two steps to the right of the origin (so that ) and five steps up (so that ). The exact solution evaluated at this point is and our numerical approximation to that value is .
Combining this new notation with the familiar idea for approximating derivatives we obtain the following approximation to the PDE
Key Point 17
The exact solution satisfies the partial differential equation
The approximate (numerical) solution satisfies the difference equation
The difference between the unknown exact solution and the numerical solution will be governed by how well the one-sided and central differences approximate the partial derivatives in the PDE.
To simplify (the appearance of) the numerical method we define a new quantity so that our numerical procedure can be written
This equation defines a numerical “stencil" which allows us to find one of the values at the time level in terms of values at the previous level, . In Figure 4 we envisage terms on the right-hand side of the above equation leading towards a result equal to the left-hand side, and the arrows therefore point towards the point at which approximates .
Figure 4
At the stage of the process depicted above, the solid circles represent points in the plane where we have already found our numerical approximation. The unfilled circle is the point for which the new approximation is being found.
4.1 Implementation
The initial condition gives at , and this information can be used to find
that is, the numerical solution at all the selected values and at . In general
where is a shorthand notation for .
Then we use the boundary conditions and numerical method
(with ) to work out for . (This completes the first time-step.)
The time-stepping procedure is then used repeatedly to find in terms of the , which are known either from the last time-step or (at the beginning) from the initial condition.
The time-stepping procedure is summarised in the following Key Point.
Key Point 18
Here the step-by-step process used to implement the numerical procedure is presented.
-
The initial condition
implies that
(the boundary conditions could be used to find and , but our supposition is that this is consistent with taking and ).
-
The first time-step
Here we find for .- The boundary condition at is . It follows that .
- The boundary condition at is . It follows that .
-
Now we work from left to right finding
at the interior points. This is achieved by repeatedly applying the general numerical scheme:
This completes the first time-step. We have taken the initial data and used our approximation to the PDE to obtain an approximate solution at time .
-
The second time-step
Here we find for .- The boundary condition at is . It follows that .
- The boundary condition at is . It follows that .
-
Now we work from left to right finding
at the interior points. This is achieved by repeatedly applying the general numerical scheme:
This completes the second time-step. We now have an approximation to at time .
- And so on ....
The following is a concrete example of the time-stepping procedure.
Example 15
The temperature of a metal bar of length at a distance from one end and at time is modelled by the partial differential equation
It is given that the metal has diffusivity , that the two ends of the bar are kept at temperature and that the initial temperature distribution is
Use the explicit difference scheme with and to approximate at and .
Solution
In this case so that the numerical method can be written
We now find
The first time-step will find , but first we note that from the two boundary conditions. Now
The second time-step will find , but first we note that from the two boundary conditions. Now
(Quantities have been rounded to three decimal places here.)
Figure 5 plots the numerical solutions found in the example above. The initial condition is shown as circles. Results of the first time-step appear as squares and the second time-step is shown as stars. The line joining the values we found are not part of the numerical solution and are included only as an aid to clarity.
Figure 5
Notice how the numerical results are behaving as they should. The temperature decreases slightly at each time-step.
Task!
The temperature of a metal bar of length at a distance from one end and at time is modelled by the partial differential equation
It is given that the metal has diffusivity , that the two ends of the bar are kept at temperature and that the initial temperature distribution is
Use the explicit difference scheme with and to approximate at and .
In this case so that the numerical scheme can be written
The first stage is to use the given data to find
The first time-step will find . First we note that the boundary condition implies that .
The second time-step will find . First we note that the boundary condition implies that . Now