Finite difference methods for the diffusion equation

Similar documents
PDEs, part 3: Hyperbolic PDEs

Numerical Analysis of Differential Equations Numerical Solution of Parabolic Equations

Introduction to numerical schemes

Tutorial 2. Introduction to numerical schemes

Numerical Solutions to Partial Differential Equations

7 Hyperbolic Differential Equations

FDM for parabolic equations

Finite Differences: Consistency, Stability and Convergence

Design of optimal Runge-Kutta methods

Part 1. The diffusion equation

Applied Mathematics 205. Unit III: Numerical Calculus. Lecturer: Dr. David Knezevic

Chapter Two: Numerical Methods for Elliptic PDEs. 1 Finite Difference Methods for Elliptic PDEs

Numerical Solutions to Partial Differential Equations

Finite Differences for Differential Equations 28 PART II. Finite Difference Methods for Differential Equations

Lecture Notes on Numerical Schemes for Flow and Transport Problems

Lecture Notes on Numerical Schemes for Flow and Transport Problems

Chapter 3. Finite Difference Methods for Hyperbolic Equations Introduction Linear convection 1-D wave equation

12 The Heat equation in one spatial dimension: Simple explicit method and Stability analysis

Time stepping methods

Numerical Solutions to PDE s

Diffusion / Parabolic Equations. PHY 688: Numerical Methods for (Astro)Physics

Finite difference method for heat equation

Numerical Methods for PDEs

Index. higher order methods, 52 nonlinear, 36 with variable coefficients, 34 Burgers equation, 234 BVP, see boundary value problems

Lecture 17: Initial value problems

2.29 Numerical Fluid Mechanics Spring 2015 Lecture 13

Partial differential equations

The method of lines (MOL) for the diffusion equation

Finite Difference Methods for Boundary Value Problems

MIT (Spring 2014)

Last time: Diffusion - Numerical scheme (FD) Heat equation is dissipative, so why not try Forward Euler:

Numerical Algorithms for Visual Computing II 2010/11 Example Solutions for Assignment 6

Time-dependent variational forms

Approximations of diffusions. Mathématiques appliquées (MATH0504-1) B. Dewals, Ch. Geuzaine

Math 660 Lecture 4: FDM for evolutionary equations: ODE solvers

Chapter 10 Exercises

Finite Difference Method for PDE. Y V S S Sanyasiraju Professor, Department of Mathematics IIT Madras, Chennai 36

Scientific Computing: An Introductory Survey

Numerical Solutions to Partial Differential Equations

Multi-Factor Finite Differences

Introduction to multiscale modeling and simulation. Explicit methods for ODEs : forward Euler. y n+1 = y n + tf(y n ) dy dt = f(y), y(0) = y 0

Finite Difference and Finite Element Methods

Lecture 4: Numerical solution of ordinary differential equations

Partial Differential Equations

Finite Difference Methods for

PDE Solvers for Fluid Flow

difference operators.

Introduction to PDEs and Numerical Methods: Exam 1

Block-Structured Adaptive Mesh Refinement

AMS527: Numerical Analysis II

Lecture 42 Determining Internal Node Values

Introduction LECTURE 1

Computation Fluid Dynamics

Chapter 5. Formulation of FEM for Unsteady Problems

Relevant self-assessment exercises: [LIST SELF-ASSESSMENT EXERCISES HERE]

Basics of Discretization Methods

Lecture Introduction

FUNDAMENTALS OF FINITE DIFFERENCE METHODS

Outline. 1 Partial Differential Equations. 2 Numerical Methods for PDEs. 3 Sparse Linear Systems

ENO and WENO schemes. Further topics and time Integration

Numerical Solutions to Partial Differential Equations

MASSACHUSETTS INSTITUTE OF TECHNOLOGY DEPARTMENT OF MECHANICAL ENGINEERING CAMBRIDGE, MASSACHUSETTS NUMERICAL FLUID MECHANICS FALL 2011

Qualifying Examination

Krylov single-step implicit integration factor WENO methods for advection-diffusion-reaction equations

Numerical methods Revised March 2001

Third part: finite difference schemes and numerical dispersion

STABILITY FOR PARABOLIC SOLVERS

Basic Aspects of Discretization

FDM for wave equations

PDEs, part 1: Introduction and elliptic PDEs

Marching on the BL equations

Selected HW Solutions

First, Second, and Third Order Finite-Volume Schemes for Diffusion

n 1 f n 1 c 1 n+1 = c 1 n $ c 1 n 1. After taking logs, this becomes

2.2. Methods for Obtaining FD Expressions. There are several methods, and we will look at a few:

256 Summary. D n f(x j ) = f j+n f j n 2n x. j n=1. α m n = 2( 1) n (m!) 2 (m n)!(m + n)!. PPW = 2π k x 2 N + 1. i=0?d i,j. N/2} N + 1-dim.

ECE539 - Advanced Theory of Semiconductors and Semiconductor Devices. Numerical Methods and Simulation / Umberto Ravaioli

Advection / Hyperbolic PDEs. PHY 604: Computational Methods in Physics and Astrophysics II

Evolution equations with spectral methods: the case of the wave equation

q t = F q x. (1) is a flux of q due to diffusion. Although very complex parameterizations for F q

Math 7824 Spring 2010 Numerical solution of partial differential equations Classroom notes and homework

Multiscale timestepping technique for MD RAJIBUL ISLAM

Partial Differential Equations

AM 205: lecture 14. Last time: Boundary value problems Today: Numerical solution of PDEs

The Heat Equation John K. Hunter February 15, The heat equation on a circle

Lecture 4.5 Schemes for Parabolic Type Equations

Butcher tableau Can summarize an s + 1 stage Runge Kutta method using a triangular grid of coefficients

Class Meeting # 2: The Diffusion (aka Heat) Equation

[2] (a) Develop and describe the piecewise linear Galerkin finite element approximation of,

Numerical Methods for Partial Differential Equations CAAM 452. Spring 2005

Introduction to PDEs and Numerical Methods Tutorial 4. Finite difference methods stability, concsistency, convergence

Numerical Solutions to Partial Differential Equations

Chapter 4. MAC Scheme. The MAC scheme is a numerical method used to solve the incompressible Navier-Stokes. u = 0

Numerical Solutions to Partial Differential Equations

Stability of Finite Difference Schemes on the Diffusion Equation with Discontinuous Coefficients

Numerical Integration of Linear and Nonlinear Wave Equations

A CCD-ADI method for unsteady convection-diffusion equations

Chapter 10: Partial Differential Equations

Finite Difference Methods (FDMs) 2

Partial Differential Equations

Transcription:

Finite difference methods for the diffusion equation D150, Tillämpade numeriska metoder II Olof Runborg May 0, 003 These notes summarize a part of the material in Chapter 13 of Iserles. They are based on the lectures (F5 and F6. 1 Diffusion equation We consider here the model parabolic equation with Dirichlet boundary conditions, u t = u xx, t > 0, x (0, 1, u(0,x = g(x, (1 u(t, 0 = u(t, 1 = 0. The simplest way of deriving and understanding numerical methods for this equation is through semi-discrete approximations. 1.1 Semi-discretizations (SD Semi-discretization means that we only discretize in space, x, and let time, t, remain continuous. Introduce the space grid, x j = j x, x = 1, j =0,...,N +1, N +1 and let u j (t u(t, x j. Approximate the second derivative xx by, for instance, central differences u xx (t, x j u j 1(t u j (t+u j+1 (t ( x, j =1,...,N. This gives the semi-discrete form of (1, du j dt = u j 1 u j + u j+1 ( x, j =1,...,N, u j (0 = g(x j, u 0 (t = u N+1 (t =0. Setting ū(t =(u 1 (t,...,u N (t T we can write this in matrix form as g(x 1 dū = Aū, ū(0 = dt.. ( g(x N 1

where 1 A = 1 ( x 1 1......... 1 1 1 R N N, is a discrete approximation of xx. We have thus transformed a PDE into a large system of ODEs, which is often a useful way of looking at evolutionary PDEs in general. We would get a similar form if xx was approximated with other methods than central differences, for instance FEM. The problem ( can now be solved with standard ODE methods such as forward Euler, ū n+1 =ū n + taū n. The whole approach is often called method of lines, since the PDE problem is eventually solved along a number of lines x = const and t>0. A necessary condition for the approach to work is that the ODE solver is linearly stable, i.e. that tλ n D, n =1,...,N, (3 where {λ n } are the eigenvalues of A and D is the linear stability domain of the ODE method. This implies a restriction on t. A typical example for explicit methods is given by the central difference approximation together with forward Euler. In this case we can write down the eigenvalues in closed form, λ n = 4 ( x sin ( nπ x. (4 It follows that 4/( x <λ n < 0 and since the linear stability restriction of forward Euler and real eigenvalues is tλ n 0, we get 4 t/( x, and then µ := t ( x 1. (5 Note that this is a severe restriction. The timestep must be very much smaller than the spacestep. We will see below that this necessary condition is in fact also sufficient for the Euler scheme to converge when x 0andµ =const. Some remarks: The number µ is often called the Courant number. For explicit methods like Euler, the condition (5 is a very typical restriction on the possible choices of space- and timesteps. In other situations, the natural relationship to consider between t and x is t/ x (without the square, and, beware, sometimes this is also called the Courant number. CFL number is another name often used instead of Courant number. The linear stability depends both on t and x. One should keep in mind that we consider in fact a whole family of ODE-systems indexed by x: When x decreases, the size of A increases and we get a different ODE system, with different eigenvalues, and therefore with different stability properties.

Semi-discretizations of the diffusion equation lead to stiff ODE systems. In the example above, the stiffness ratio is max n λ n min n λ n 1 ( x 1, when x 1. This is the typical situation for all parabolic equations and reflects the fact that many vastly different timescales are present in the solution; low spatial frequencies decay slowly, while high spatial frequencies decay very rapidly. Therefore, implicit methods are preferred for parabolic problems. Hence, the forward Euler method, although good for illustrating the properties of semi-discretizations, is not very practical for actually solving (1. Crank Nicolson (see below is a better choice. 1. Convergence The pure semi-discrete approach is not quite sufficient for analyzing the convergence of numerical schemes for the diffusion equation. Even if we know that the ODE method that we apply to ( is convergent, we cannot conclude that the full method converges. The reasons is that ODE theory only considers convergence as t 0 with a fixed x >0. The method is then only shown to converge to the solution of the semi-discrete approximation. We need to check convergence when t 0 and x 0 at the same time. Usually one maintains a fixed relation between the time- and space step, e.g. t = µ( x or t = λ x, and let x 0. The numbers µ or λ are chosen such that the method remains stable and that the errors incurred by the time- and space discretizations are balanced. In order to analyze this convergence we must start from a full discretization (FD of (1 in time and space. We therefore introduce the space-time grid x j = j x, t n = n t, x = 1, j =0,...,N +1, n =0, 1,..., N +1 and approximate u n j u(t n,x j. Example 1: Forward Euler + central differences = the Euler method, j = u n j + t ( x (un j+1 u n j + u n j 1. Example : Trapezoidal rule + central differences = the Crank Nicolson method, j 1 t ( x (un+1 j+1 un+1 j + j 1 =un j + 1 t ( x (un j+1 u n j + u n j 1. Note that this is an implicit method. We will analyze the following general one-step discretization, b k (µ j+k = k= α c k (µu n j+k. (6 The coefficients b k and c k depend on µ. Close to the boundaries the scheme will have to be modified to accomodate the boundary conditions, but we disregard this complication here. Our goal is loosely speaking to show that u n j u(t n,x j when t, x 0. Let us first introduce some notation and then state this in a more precise way. Set ũ n j = u(t n,x j 3

(the exact solution. Define the vectors ū n =(u n 1,...,u n N T,ũ n =(ũ n 1,...,ũ n N T and the discrete L norm, N g x := x gj, g =(g 1,...,g N T. j=1 Then we say that the method in (6 is convergent if ( lim max ū n ũ n x x 0 0 n N t when t = λ( x r for some positive constants λ, r and with N t t = T fixed. Convergence is given by the important Theorem 13.3 in Iserles (the Lax equivalence theorem which applies not only to the diffusion equation, but to general (well-posed, linear evolutionary PDEs (e.g. also the advection and wave equation in Chapter 14. This theorem says that the method is convergent if it is consistent and stable. We now turn to defining those concepts and to showing how they can be checked for (6. For both of them the method s characteristic function, a(z,µ := =0, β k= α c k(µz k δ b k(µz k, (7 is a helpful tool. It is sometimes also called the amplification factor. 1..1 Consistency We begin to define the local truncation error of the method in (6. It is given as the residual, divided by t, when the exact solution ũ n j is entered into the scheme: b k (µũ n+1 j+k k= α c k (µũ n j+k =: tτ n+1 j. (8 If τj n = O(( xp +( t q the method is of order p in space and q in time. The method is consistent if p 1andq 1. If we use a constant µ, or more generally if t/( x = O(1, then τj n = O(( x p +( x q =O(( x r where r = min(p, q and we simply say that the method is of order r. Consistency and order can either be checked by direct Taylor expansion of the exact solution in (8, or by the following theorem, which characterizes the order via a(z,µ, Theorem 1 If ( a e i x t, ( x = e t + O( t[( x p +( t q ], then the method is of order p and q in space and time respectively. If µ =constand then the method is of order r. (C.f. Theorem 13.6 in Iserles. a ( e i x,µ = e µ( x + O(( x r+, 4

Example: The Euler method is of order in space and 1 in time, i.e. of order if µ is constant. Crank Nicolson is of order both in time and space. This should come as no surprise recalling the order of the corresponding ODE methods (forward Euler and the trapezoidal rule and that central differencing gives a second order approximation of the second derivative. 1.. Stability The method is said to be stable if ū n x C(T ū 0 x, n =0,...,N t, (9 when t = λ( x r for some positive constants λ, r and N t t = T is fixed. Note that the constant C depends on T but not on t and x. For methods derived via semi-discretization, one can show that the stability (9 follows if the ODE-method is linearly stable for each pair of t and x that is used. One can thus follow the methodology in Section 1.1 to check stability. It is, however, not always so straightforward to write down the eigenvalues corresponding to the matrix A, as in (4, and in practice it is often easier to use another method, based on Fourier analysis. The method is called von Neumann anlaysis. For simplicity we assume that the diffusion equation is solved over the entire real axis, and not just in the interval [0, 1]. The spatial index then ranges over all integers, j Z, and we can interpret the sequence u n j as the Fourier series of a function in L [0, π], û n ( := j= u n j e ij. (10 (Here we tacitly assume that {u n j } l (Z for fixed n. See Iserles. After multiplication by e ij and summing the left and right hand side of (6 over all j, we obtain b k (µ b k (µ j= j= j+k e ij = j e i(j k = c k (µ u n j+ke ij, k= α j= c k (µ u n j e i(j k. k= α j= Using the definition (10 we get û n+1 ( b k (µe ik =û n ( k= α c k (µe ik, and finally, after dividing with the b k sum and recalling the definition (7 of a(z,µ, we have û n+1 ( =a(e i,µû n (. The characteristic function a(e i,µ thus shows how frequency is amplified in each timestep. According to a version of Parseval s theorem, ū n x = x π π 5 0 û n ( d,

and therefore, with a := sup 0 π a(e i,µ, ū n+1 x = x π π 0 a(e i,µ û n ( d a x π Consequently, ū n x a n ū 0 x, and the method is stable if a 1. We thus get π Theorem The method in (6 applied to the whole real axis,is stable if 0 û n ( d = a ū n x. a(e i,µ 1, [0, π]. (C.f. Theorem 13.11 in Iserles. This restriction then translates into a restriction on µ. Example 1: The Euler method. Here a(e i,µ=1 4µ sin (, and the method is stable if a 1 for all [0, π], i.e. if µ 1/ (as we already knew. Example : The Crank-Nicolson method. Here a(e i,µ= 1 µ ( sin 1+µ sin (, and 1 µ sin ( a = 1+µ sin ( 1+µ ( sin 1+µ sin ( =1, for all µ>0. We can thus choose any timestep to get stability, which is expected since it is an implicit method. We also have to think about accuracy, however. The local truncation error is O(( x +( t and in order to balance the errors from the time stepping and the space discretization, one often picks t x. 6