# chapter 8 diffusion equation - university of alaska .chapter 8. diffusion equation 147 split into

Post on 19-Jul-2018

217 views

Embed Size (px)

TRANSCRIPT

Chapter 8

Diffusion Equation

This chapter describes different methods to discretize the diffusion equation

f t

( 2 fx2

+ 2 fy2

+ 2 f z2

)= 0

which represents a combined boundary and initial value problem, i.e., requires to prescribe bound-ary fboundary(t) and initial conditions f (x,y,z, t = 0).

8.1 Explicit methods

8.1.1 Forward time centered space scheme

In one dimension and using finite difference the FTCS scheme is

f n+1j = fnj + sx

2Lxx f njs = t/x2

The truncation error is given by

Enj = x2

2

(s 1

6

) 4 fx4

nj+O

(x4)

The amplification factor is

g = 14ssin2(

kx2

)which yields s < 1/2 for stability.

145

CHAPTER 8. DIFFUSION EQUATION 146t xi-1 i i+1nn+1n-1 i+2i-2 Schematic: FTCSFigure 8.1: Representation of the FTCS scheme.

In two dimensions the same approach can be used to yield

f n+1jk = fnjk + sxx

2Lxx f njk + syy2Lyy f njk

with sx = xt/x2, sy = yt/y2

Stability requires sx + sy 1/2. An improved nine point scheme can be found if x = y = andx = y which for

f n+1jkt

= Lxx f njk +Lyy fnjk +

2t2LxxLyy f njk

yields stability for s 1/2. This scheme can efficiently be implemented with

f jk = (1+tLyy) fnjk

f n+1jk = (1+tLxx) fjk

8.1.2 Richardson and DuFort-Frankel schemes

One could have the idea that is is more accurate to employ a centered difference for the temporalderivative which give the Richardson scheme

f n+1j fn1j

2t= Lxx f nj =

x2

(f nj12 f nj + f nj+1

)and is second order accurate for the time derivative. However the stability analysis shows that thisscheme is unconditionally unstable. A small modification of this scheme where the term 2 f nj is

CHAPTER 8. DIFFUSION EQUATION 147

split into two time levels according to 2 f nj = fn1j + f

n+1j leads to the so-called Dufort-Frankel

scheme:

f n+1j fn1j

2t= Lxx f nj =

x2

(f nj1 f n1j f

n+1j + f

nj+1

)Although it appears as if this were implicit it is straightfor-ward to re-arrange terms to yield

f n+1j =2s

1+2s(

f nj1 + fnj+1)+

12s1+2s

f n1j

This scheme is actually unconditionally stable. However,carrying out the consistency test, i.e., expanding terms inthe corresponding Taylor series yields

[ f t

2 fx2

+(

tx

)2 2 f t2

]nj

+O(t2,x2

)= 0

Symbolic representation of theDuFort-Frankel scheme.

Thus it is not sufficient to conduct the limit of t,x 0 to achieve consistency as long as t/xremains finite. Using the relation

(

tx

)2= st

demonstrates that consistency can be achieved if s is kept constant and t 0 because t x2for constant s.

The amplification factor for the DuFort-Frankel scheme is

g =2scosk

1+2s 1

1+2s

14s2 +4s2 cosk

8.1.3 Three-level scheme

The general method suggest an approach such as

a f n+1j +b fnj + c f

n1j

(dLxx f nj + eLxx f

n1j

)= 0

CHAPTER 8. DIFFUSION EQUATION 148

Using this method and applying consistency yields theequation

1t

(1+ )(

f n+1j fnj

) 1

t(

f nj f n1j)

= [(1 )Lxx f nj +Lxx f n1j

]The error resulting from this scheme is

Enj = sx2(

12

+ + 112s

) 4 fx4

nj+O

(x4) Symbolic representation of thethe-level scheme.

such that this scheme becomes 4th order accurate for =0.5 +1/12s. The equation for theamplification factor is

(1+ )g2 [1+2 +2s(1 )(cosk1)]+ [2 s(cosk1)] = 0

The discussion of the parameter space is somewhat complicated but the general result is that thereis a stability limit with values of s increasing from about 0.35 to 5 if is raised from 0 to about 6.

s

0.5

0.4

0.3

2.0 4.0 6.0

stable

unstable

Figure 8.2: Illustration of the stability space for the three level scheme.

The truncation error for the previous methods for different grid resolution is shown in the followingtable. It illustrates that for specific values of s the simple FTCS and DuFort-Frankel methods canachieve 4th order accuracy.

8.1.4 Hopscotch method

This is a fairly original method which uses a two stage FTCS algorithm. Here we describe thetwo-dimensional variant.

In the first stage which is carried out for j + k +n = even the usual FTCS scheme is applied

CHAPTER 8. DIFFUSION EQUATION 149

Table 8.1: RMS errors for different explicit schemes and varying parameters as a function of gridresolution.

Case s RMS RMS RMS approx.x = 0.2 x = 0.1 x = 0.05 conv. rate

FTCS 1/6 0.007266 0.00049 0.000033 3.9FTCS 0.3 0.6437 0.1634 0.0413 2.9FTCS 0.41 1.2440 0.3023 0.0755 2.0DuF-F 0.289 0.0498 0.00233 0.00012 4.3DuF-F 0.3 0.0244 0.0136 0.00395 1.8DuF-F 0.41 0.8481 0.2085 0.0525 2.03L-4th 0.3 0.0 0.0711 0.00416 0.00022 4.23L-4th 0.3 0.5 0.1372 0.00665 0.00029 4.53L-4th 0.3 1.0 0.2332 0.00916 0.00054 4.13L-4th 0.41 1.0 0.7347 0.0229 0.00140 4.0

f n+1jkt

= Lxx f njk +Lyy fnjk j + k +n = even

In the second stage the same scheme is applied but (a)now on all grid points with j+k+n = odd and (b) thesecond order derivative is using the newly computedtime level n + 1. This is possible now in an explicitmethod because all grid points adjacent to the one tobe updated have been updated in the first stage.

f n+1jkt

= Lxx f n+1jk +Lyy fn+1jk , j + k +n = odd

1. Stage schematic:

2. stage schematic:

The Figure above shows a schematic of the time update. The grid topology is shown in the follow-ing figure. Here the first stage updates for instance all grid points indicated in blue. The 2nd stagethen uses the spatial derivative from those grid points to update the orange points. The resultingpattern looks like a chess board.

Note that this method is not only very efficient and simple but also unconditionally stable (in 2dimensions?). The error associated with the scheme is O

(t,x2,y2

).

8.2 Implicit methods

8.2.1 Fully implicit scheme

This method is equivalent to the FCTS method, however, with the 2nd derivative operator evaluatedat the new time level.

CHAPTER 8. DIFFUSION EQUATION 150xyFigure 8.3: Representation of the grid topology used for the Hopscotch method.

f n+1jt

= Lxx f n+1j

Consistency yields

Enj =t2

(1+

16s

) 4 fx4

nj+O

(x4)

and the amplification factor is

g =(

1+4ssin2(

kx2

))1 Schematic of the fully implicitscheme.

which demonstrates that the scheme is unconditionally stable. The solution to this method can befound by solving

1+2s s 0 0 0s 1+2s s 0 00 s 1+2s s 00 0 s 1+2s s0 0 0 s 1+2s

f n+11f n+12f n+13f n+14f n+15

=

d1d2d3d4d5

of rank N corresponding to the number of grid points. The tridiagonal system is easily solved usingthe Thomas algorithm.

8.2.2 Crank-Nicholson scheme

This method uses a mixture of spatial derivative using time levels n and n+1.

CHAPTER 8. DIFFUSION EQUATION 151

f n+1jt

=2

Lxx(

f nj + fn+1j

)which generates an error of order Enj = O

(t2,x2

). Note

that the scaling of t2 in the error is caused by the centeredtime derivative. The equation for the amplification factor is

g1+2sgsin2 k2

+2ssin2k2

= 0 Schematic of the finite differ-ence Crank-Nicholson scheme

or

g =12ssin2 k21+2ssin2 k2

which implies unconditional stability.

Finite element Crank-Nicholson

Note that this is easily expanded to the finite elementCrank-Nicholson scheme by applying the correspondingmass operators to the time derivative term

1t

Mx f n+1j = (

12

Lxx f nj +12

Lxx f n+1j

)Schematic of the finite elementCrank-Nicholson scheme

The Crank-Nicholson scheme can also be generalized in substituting the factors of 1/2 by a vari-able parameter in the following manner

f n+1jt

= [(1 )Lxx f nj +Lxx f n+1j

]In this case the method is unconditionally stable for

0 12

and has the restriction

s 12(12 )

if > 0.5.

CHAPTER 8. DIFFUSION EQUATION 152

8.2.3 Generalized three level schemes

Another generalization is to consider a weighted time differencing over three time levels:

(1+ ) f n+1jt

f nj

t=

[(1 )Lxx f nj +Lxx f n+1j

]where the particular choice

=12

= 1

yields an error E = O(t2,x2

)with unconditional stability.

Finally we can apply a generalized mass operator Mx = ( ,12 , ) which yields

(1+ )Mx f n+1j

t Mx

f njt

= [(1 )Lxx f nj +Lxx f n+1j

]Note that the Crank-Nicholson schemes are recovered us-ing = 0, = 1/2. The FEM Crank-Nicholson scheme isrecovered in this case with = 1/6.The error for this scheme is

Enj = sx2(

12

+ + 1/12s

) 4 fx4

nj+O

(x4)

Schematic of the general threelevel schemes

such that the scheme becomes fourth order accurate for

=12

+ + 1/12

sThe algebraic equations for this scheme are

a j f n+1j1 +b j fn+1j + c j f

n+1j+1 = (1+2)Mx f

nj Mx f n1j +(1 )sLxx f

nj

ai = ci = (1+ ) sb j = (1+ )(12 )+2s

Lxx f nj = fnj12 f nj + f nj+1

The specific choice of = 1/12 yields fourth order accuracy for = 12 + .A summary on the methods implemented in the program Diffim.f of implicit schemes is given inthe next table.

The following table is a summary of the RMS error obtained for implicit methods with the programDiffim.f. All results use s = 1.0