solution of the diffusion equation by finite differences
TRANSCRIPT
-
7/31/2019 Solution of the Diffusion Equation by Finite Differences
1/5
nextup
previous
Next:Numerical Solution of theUp:APC591 Tutorial 5: NumericalPrevious:The Diffusion Equation
Solution of the Diffusion Equation by Finite
DifferencesThe basic idea of the finite differences method of solving PDEs is to replace spatial and time derivatives by
suitable approximations, then to numerically solve the resulting difference equations. Specifically, instead of
solving for with and continuous, we solve for , where
define the grid shown in Figure 1.
4/14/2011 Solution of the Diffusion Equation by Fi
www.me.ucsb.edu//node3.html 1
-
7/31/2019 Solution of the Diffusion Equation by Finite Differences
2/5
Figure 1: Grid for our finite difference approximations. The point labelled corresponds
to , etc.
Derivatives of are approximated in terms of the values of at grid points. For example, we know that
This derivative evaluated at the grid point can be approximated in many different ways, the
simplest being the following:
Forward Difference:
4/14/2011 Solution of the Diffusion Equation by Fi
www.me.ucsb.edu//node3.html 2
-
7/31/2019 Solution of the Diffusion Equation by Finite Differences
3/5
Backward Difference:
Central Difference:
The second derivative at the grid point may be approximated by using
Instead of using approximations for in terms of the values of at as for the forward difference,
or at the points as for the backward difference, let's imagine instead that we evaluate it at the
(fictitious) points , defined in the obvious way. Then, using central difference approximations for the
spatial derivatives evaluated at these points,
Then
4/14/2011 Solution of the Diffusion Equation by Fi
www.me.ucsb.edu//node3.html 3
-
7/31/2019 Solution of the Diffusion Equation by Finite Differences
4/5
(3)
We can approximate derivatives with respect to time in the same way. For example, the forward difference
approximation for at the grid point is
(4)
It should be noted that these finite difference approximations are only valid to some order in or . The
error in the approximations is called the truncation error. It is possible to get approximations which are valid to
higher order by using more grid points in the approximations. This is all quite important, but for our purposes the
approximations given above will be sufficient.
Using the approximations (3) and (4) in (2), and rearranging, we get the following difference equation which can
be iterated to find the approximate solution to equation (2):
(5)
This is called an explicitnumerical scheme because the computation of at is completely determined by
our computation of at . This scheme is also called consistentbecause the finite difference approximations
have a truncation error that approaches zero in the limit that , .
Although this is a consistent method, we are still not guaranteed that iterating equation (5) will give a good
approximation to the true solution of the diffusion equation (2). A numerical scheme is called convergentif the
solution of the discretized equations (here, the solution of (5)) approaches the exact solution (here, the solution of
(2)) in the limit that , .
For linear equations such as the diffusion equation, the issue ofconvergence is intimately related to the issue of
stability of the numerical scheme (a scheme is called stable if it does not magnify errors that arise in the course
of the calculation). Indeed, the Lax Equivalence Theorem says that for a properly posed initial value problem for
a linear PDE, and a consistent finite difference approximation, stability is the necessary and sufficient condition fo
4/14/2011 Solution of the Diffusion Equation by Fi
www.me.ucsb.edu//node3.html 4
-
7/31/2019 Solution of the Diffusion Equation by Finite Differences
5/5
convergence. Moreover, it can be shown that the scheme given by (5) is only convergent when
(6)
These issues are also quite important, but this is not the appropriate place to go into them in more detail. All of
the details are described, for example, inA First Course in Numerical Analysis of Differential Equations byArieh Iserles, Cambridge University Press, 1996.
However, before moving on, let me emphasize that as the sizes and are made smaller, the truncation
error of approximating the partial derivatives by finite differences decreases. However, for smaller sizes, more
computations need to be done to get solutions for the same domain and total time, which leads to increased
roundoff error. The total error as a function of these sizes is sketched in Figure 2.
Figure 2: Sketch of errors as functions of the grid size for a finite
difference calculation. Here it is assumed that the solution is
calculated on the same domain and for the same total time.
nextup
previous
Next:Numerical Solution of theUp:APC591 Tutorial 5: NumericalPrevious:The Diffusion Equation
Jeffrey M. Moehlis 2001-10-24
4/14/2011 Solution of the Diffusion Equation by Fi
www.me.ucsb.edu//node3.html 5