Professional Documents
Culture Documents
Author
Lecture Summary
Mathematical prerequisites
Solution of the diffusion equation by separation of variables Taylors Theorem
The implicit -method for the diffusion equation Reaction diffusion systems Other Issues aternative bounday conditions and higher dimensions
Author
Finite Difference methods are the usual entry point and the simplest to understand and code up Finite element methods will be covered in the computational biology course
Author Short Paper Title
Model Problem
We will take as our model problem the diffusion equation in one space dimension u 2u = t x 2 for [x, t] [0, 1] [0, T ]
where u(x, t) is the dependent variable (concentration, for example) dened for, with zero Dirichlet boundary conditions u(0, t) = u(1, t) = 0 for all t, and initial condition u(x, 0) = u 0 (x).
Author
This simple equation can be solved by separation of variables. We assume thaat the solution u(x, T ) can be expressed as u(x, t) = X (x)T (t) Substituting into the pde gives T X X (x)T (t) = TX => = = constant = 2 , T X say.
Author
This now gives us two simple odes to solve for T and X giving T (t) = C exp 2 t X (x) = Aeix + Beix = A sin x + B cos x where A , B , C and are constants which can be determined to satisfy the boundary and initial conditions. From the boundary conditions it is clear that B = 0 and = n for all integers n 1 (exercise).
Author
The general solution is given by the sum of all such solutions i.e.
u(x, t) =
n=1
and
1
Dn = 2
0
u 0 (x) sin(nx) dx
Author
Taylors Theorem
The basis of nite difference methods is Taylors Theorem, which roughly speaking states that any sufciently smooth function can be approximated locally by a polynomial.
Author
Taylors Theorem
Formally, the theorem states that if n 0 is an integer and f is a function which is continuously differentiable n times on the closed interval [a, x] and n + 1 times differentiable on the open interval (a, x), then f (x) = f (a) + (x a)f (a) + (x a)2 f +(x where Rn (x) =
f (n+1) () (x (n+1)!
(n) (a) a)n f n!
(a) 2!
+ ...
+ Rn (x)
Author
Taylors Theorem
This is more useful to us if we write it as f (x + x) f (x) + xf (x) + x 2 f
(x) 2!
+ . . . + x n f
(n) (x)
n!
We can straightforwardly extend this to two dimensions f (x + x, y + y ) = f (x, y ) + [xfx (x, y ) + yfy (x, y )] + 1 x 2 fxx (x, y ) + 2xyfxy (x, y ) + y 2 fyy (x, y ) + 2! 1 x 3 fxxx (x, y ) + 3x 2 yfxxy (x, y )+ 3! 3xy 2 fxyy (x, y ) + y 3 fyyy + . . .
which we will need in analysing the truncation errors in our nite difference schemes.
Author
Space discretisation
and for the space derivatives we consider u(t, x + x), u(x, t), and u(t, x x) u(x + x, t) = u(x, t) + xux (x, t) + x 2 u(x, t) = u(x, t) u(x x, t) = u(x, t) xux (x, t) + x 2 uxx (x, t) + ... 2! uxx (x, t) + ... 2!
If we now add the rst and third equations above, subtract twice the second, and divide by x 2 , we obtain u(x + x, t) 2u(x, t) + u(x x, t) uxxxx (x, t) = uxx (x, t) + 2x 2 + ... x 2 4!
Author
This is the simple explicit nite difference approximation to the model problem.
Author
Truncation error
The truncation error, T (x, t), of a nite difference scheme is dened as the difference between the two sides of the above equation when the approximation Ujn is replaced by the exact solution u(xj , tn ), that is T (x, t) = so that 1 1 T (x, t) = (ut uxx ) + ( utt t uxxxx (x)2 + . . . 2 12 1 1 = utt t uxxxx (x)2 + . . . 2 12 That is, it is rst order in time and second order in space. u(x, t + t) u(x, t) u(x + x, t) 2u(x, t) + u(x x, t) t (x)2
Author
Author
where =
t x 2
we can substitute into the difference equation to obtain = (k ) = 1 + (eik x 2 + eik x ) = 1 2(1 cos k x) 1 = 1 4 sin2 k x 2
Author
As for the analytic solution of the pde, we can satisfy the bounday conditions by taking k = m and obtain the general solution of the difference equations. We can also substitute this into our equation for (k ) above and expand as a Talyor series to obtain an alternative approach to establishing the order of convergence. See p20 of Morton and Mayers for details.
Author
Method of Lines
This is a very useful technique when solving 1-D problems if you have a very good ODE solver available (as in Matlab). In this method we discretise only the spatial component (i.e. the x-direction) of the pde to obtain a system of ordinary diffetential equations for each x-"line". [See diagram.] i.e. we solve continuously in imie for each mesh line Uj (t) with Uj (0) = u 0 (jx).
Author
Author
The restriction on the timetep imposed by stability considerations when using the explicit nite difference method can be overcome and we can obtain a more stable nite difference scheme by using the "current" time level in approximating the spacial derivatives in the PDE. This results in an "implicit" nite difference scheme The penalty is that we now have to solve a linear system of equations.
Author
x 2
Author
Author
The -Method
Replacing the spatial derivatives in the pde by a weighted average of the nite difference approximations at time levels n and n + 1 gives the method Ujn+1 Ujn t =
n+1 n+1 Uj+1 2Ujn+1 + Uj1
x 2
n n Uj+1 2Ujn + Uj1 x 2
Author
So far we have considered numerical methods for the heat/diffusion equation only. It is straightforward to extend this treatment to reaction-diffusion equations of the type seen very frequently in Mathematical Biology. This is typically done by treating any reaction terms explicitly regardless of how the diffusion term is treated (explicitly or implicitly)
Author
Author
Other Issues
Non-zero Dirichlet can be incorporated directly into the nite difference stencil and transferred to the right hand side of the equation. Zero-ux easiest to introduce a "ctitious mesh line" just outside the boundary. Higher Dimensions all of the above extends quite straightforwardly into higher spatial dimensions.
Author