• Nenhum resultado encontrado

Even vs. odd order derivatives

Note that odd order derivatives ∂x, ∂x3, . . . (as in the advection equation or the dispersive equation (11.10)) have pure imaginary eigenvaluesiξ, −iξ3, . . ., which results in Fourier components that prop-agate with their magnitude preserved. Even order derivatives, such as the∂2xin the heat equation, have real eigenvalues (−ξ2for the heat equation) which results in exponential decay of the eigencomponents.

Another such equation is

ut=−uxxxx,

in which case ˆu(ξ, t) =eξ4tη(ξ). Solutions to this equation behave much like solutions to the heatˆ equation, but with even more rapid damping of oscillatory data.

Chapter 12

Diffusion Equations

We now begin to study finite difference methods for time-dependent partial differential equations, where variations in space are related to variations in time. We begin with the heat equation (or diffusion equation) introduced in Chapter 10,

ut=κuxx. (12.1)

This is the classical example of a parabolic equation, and many of the general properties seen here carry over to the design of numerical methods for other parabolic equations. We will assume κ= 1 for simplicity but some comments will be made about how the results scale to other values of κ > 0. (If κ <0 then (12.1) would be a “backward heat equation”, which is an ill-posed problem.)

Along with this equation we need initial conditions at some timet0, which we typically take to be t0= 0,

u(x,0) =η(x) (12.2)

and also boundary conditions if we are working on a bounded domain,e.g., the Dirichlet conditions u(0, t) =g0(t) for t >0

u(1, t) =g1(t) for t >0 (12.3) if 0≤x≤1.

We have already studied the steady state version of this equation and spatial discretizations ofuxx

(Chapter 2). We have also studied discretizations of the time derivatives and some of the stability issues that arise with these discretizations in Chapters 6 through 9. Next we will put these two types of discretizations together.

In practice we generally apply a set of finite difference equations on a discrete grid with grid points (xi, tn) where

xi =ih, tn=nk.

Here h = ∆x is the mesh spacing on the x-axis and k = ∆t is the time step. Let Uin ≈ u(xi, tn) represent the numerical approximation at grid point (xi, tn).

Since the heat equation is an evolution equation that can be solved forward in time, we set up our difference equations in a form where we can march forward in time, determining the values Uin+1 for all ifrom the values Uin at the previous time level, or perhaps using also values at earlier time levels with a multistep formula.

As an example, one natural discretization of (12.1) would be Uin+1−Uin

k = 1

h2(Uin1−2Uin+Ui+1n ). (12.4) This uses our standard centered difference in space and a forward difference in time. This is anexplicit method since we can compute each Uin+1 explicitly in terms of the previous data:

Uin+1=Uin+ k

h2(Uin1−2Uin+Ui+1n ). (12.5) 153

PSfrag replacements

xj−1 xj xj+1

tn

tn+1

(a) (b)

Figure 12.1: Stencils for the methods (12.5) and (12.7).

Figure 12.1(a) shows thestencilof this method. This is a one-step method in time, which is also called a two-level method in the context of PDE’s since it involves the solution at two different time levels.

Another one-step method, which is much more useful in practice as we will see below, is the Crank-Nicolsonmethod,

Uin+1−Uin

k = 1

2(D2Uin+D2Uin+1) (12.6)

= 1

2h2(Uin1−2Uin+Ui+1n +Uin+11 −2Uin+1+Ui+1n+1), which can be rewritten as

Uin+1=Uin+ k

2h2(Uin1−2Uin+Ui+1n +Uin+11 −2Uin+1+Ui+1n+1) (12.7) or

−rUin+11 + (1 + 2r)Uin+1−rUi+1n+1=rUin1+ (1−2r)Uin+rUi+1n (12.8) where r=k/2h2. This is an implicit method and gives a tridiagonal system of equations to solve for all the valuesUin+1 simultaneously. In matrix form this is

(1 + 2r) −r

−r (1 + 2r) −r

−r (1 + 2r) −r . .. . .. . ..

−r (1 + 2r) −r

−r (1 + 2r)

 U1n+1 U2n+1 U3n+1

... Umn+11 Umn+1

=

r(g0(tn) +g0(tn+1)) + (1−2r)U1n+rU2n rU1n+ (1−2r)U2n+rU3n

rU2n+ (1−2r)U3n+rU4n ...

rUmn2+ (1−2r)Umn1+rUmn rUmn1+ (1−2r)Umn +r(g1(tn) +g1(tn+1))

 .

(12.9)

Note how the boundary conditionsu(0, t) =g0(t) andu(1, t) =g1(t) come into these equations.

Since a tridiagonal system ofmequations can be solved withO(m) work, this method is essentially as efficient per time step as an explicit method. We will see in Section 12.4 that the heat equation is “stiff”, and hence this implicit method, which allows much larger time steps to be taken than an explicit method, is a very efficient method for the heat equation.

Solving a parabolic equation with an implicit method requires solving a system of equations with the same structure as the 2-point boundary value problem we studied in Chapter 2. Similarly, a multidimensional parabolic equation requires solving a problem with the structure of a multidimensional elliptic equation in each time step. See Section 12.7.

Solving a parabolic equation with an implicit method requires solving a system of equations with the same structure as the 2-point boundary value problem we studied in Chapter 2. Similarly, a multidimensional parabolic equation requires solving a problem with the structure of a multidimensional elliptic equation in each time step.

12.1 Local truncation errors and order of accuracy

We can define the local truncation error as usual — we insert the exact solutionu(x, t) of the PDE into the finite difference equation and determine by how much it fails to satisfy the discrete equation.

Example 12.1. The local truncation error of the method (12.5) is based on the form (12.4):

τin=τ(xi, tn), where

τ(x, t) = u(x, t+k)−u(x, t)

k − 1

h2(u(x−h, t)−2u(x, t) +u(x+h, t)).

Again we should be careful to use the form that directly models the differential equation in order to get powers of k and hthat agree with what we hope to see in the global error. Although we don’t know u(x, t) in general, if we assume it is smooth and use Taylor series expansions aboutu(x, t), we find that

τ(x, t) =

ut+1

2kutt+1

6k2uttt+· · ·

uxx+ 1

12h2uxxxx+· · ·

.

Since ut=uxx, theO(1) terms drop out. By differentiating ut=uxx we find thatutt=utxx=uxxxx

and so

τ(x, t) = 1

2k− 1 12h2

uxxxx+O(k2+h4).

This method is said to be second order accurate in space and first order accurate in time since the truncation error isO(h2+k).

The Crank-Nicolson method is centered in both space and time, and an analysis of its local truncation error (Exercise 12.1) shows that it is second order accurate in both space and time,

τ(x, t) =O(k2+h2).

A method is said to be consistentif τ(x, t)→0 as k, h →0. Just as in the other cases we have studied (boundary value problems and initial value problems for ODE’s), we expect that consistency, plus some form of stability, will be enough to prove that the method converges at each fixed point (X, T) as we refine the grid in both space and time. Moreover we expect that for a stable method the global order of accuracy will agree with the order of the local truncation error,e.g., for Crank-Nicolson we expect that

Uin−u(X, T) =O(k2+h2) as k, h→0 when ih≡X andnk≡T are fixed.

For linear PDE’s, the fact that consistency plus stability is equivalent to convergence is known as theLax Equivalence Theorem, and is discussed in Section 12.5 after introducing the proper concept of stability. As usual, it is the definition and study of stability that is the hard (and interesting) part of this theory.