Numerical Methods for Partial Differential Equations

46
Numerical Methods for Partial Differential Equations CAAM 452 Spring 2005 Lecture 5 Summary of convergence checks for LMM and one-step time stepping Instructor: Tim Warburton

description

Numerical Methods for Partial Differential Equations. CAAM 452 Spring 2005 Lecture 5 Summary of convergence checks for LMM and one-step time stepping Instructor: Tim Warburton. Today. - PowerPoint PPT Presentation

Transcript of Numerical Methods for Partial Differential Equations

Page 1: Numerical Methods for Partial Differential Equations

Numerical Methods for Partial Differential Equations

CAAM 452Spring 2005

Lecture 5Summary of convergence checks for LMM and

one-step time steppingInstructor: Tim Warburton

Page 2: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Today

• I will summarize the steps we took to examine the stability, consistency and thus convergence of the AB and RK schemes

Page 3: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

AB

• The general AB scheme reads:

• To check linear stability we assume that f is linear in u (we can also achieve a similar goal by assuming f is Lipschitz)

• Assuming:

• We know that all the solutions of this recurrence relationship are bounded provided the corresponding stability polynomial:

has roots which satisfy the root condition (all roots bounded by 1, and if they have magnitude 1 must be simple roots).

1 11

m s

n n m n mm

u u dt f u

1 11

m s

n n n n m n mm

f u u u u dt u

1

1

m ss s s m

mm

z z dt z

Page 4: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

AB cont

• We must then check the roots of:

• For roots with |z|<1 we are sure that the method is stable. What we wish to know is what values of mu*dt guarantee this condition. We can think of this formula defining a map between the (complex) plane of roots to the (complex) plane of mu*dt

• We must determine the image of the unit circle in the root plane in the mu*dt plane.

1

1

m ss s s m

mm

z z dt z

Page 5: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

AB cont

• Given the root equation:

• We determine the map in a trivial manner:

• Example AB3:

1

1

m ss s s m

mm

z z dt z

11

1

1

s sm ss s s m

m m ss mm

mm

z zz z dt z dt

z

3 2

2:(23 -16 5) /12

z zz z

Page 6: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

AB3 Stability

3 2

2:(23 -16 5) /12

z zz z

iz re

Page 7: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

AB Accuracy

• Next we perform a local truncation error analysis.

• That is we estimate what correction at each step of the solution is required for the exact solution of the ODE to be a solution to the numerical method:

1 11

m s

n n nm n mm

u t u t dt f u t T

Page 8: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

cont

• We now use Taylor expansions to express the truncation error in terms of u and its derivatives at tn:

• We found that Tn scaled as:

• Finally we apply Dahlquist’s equivalence theorem, which requires consistency and stability convergence and corollary which gives us global error estimates:

1 11

m s

n n nm n mm

u t u t dt f u t T

1

1 * *11 for some constant and ,

ss

n nsn n n

d uCdt t C t

dtT t t

, , ,...n

sn n t s uu t u C dt

Page 9: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

RK Analysis

• A similar analysis is required for the Runge-Kutta schemes.

• The stability analysis was straightforward as we found that the recurrence for a linear f was:

• For stability we required:

• We examined this by setting

10 !

mm s

n nm

u um

0

1!

mm s

m m

0 !

mm si

m

em

Page 10: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

RK3 Stabilityand let Matlab do the work.

2 3

12 3!

ire

ire

Page 11: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

RK Accuracy

• The error estimate process for RK schemes is a little more complicated, but still boils down to dt expansions of the one-step operator.

• Again, once we have consistency and stability we have convergence.

Page 12: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Implicit Schemes

• Later on in the semester we will discuss implicit schemes.

• Then we will also discuss the Butcher block formulation of RK methods.

Page 13: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

After Time Stepping… Back to PDE’s

• We have now proposed two quite distinct but reliable ways to advance an ODE approximately in time.

• But our original goal was to solve a PDE

• And not just for one mode.

u uc

t x

Page 14: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Sample Points in Time Space

nt

u uc

t x

• We chose to sample the ODE at discrete points on the time axis.

• We can also make the same choice for the spatial representationat each discrete time level.

• We follow this choice with the dilemma of how to reconstruct anapproximation to the derivative of discretely sampled data.

mx 1mx 1mx 2mx 2mx x

3mx 3mx

Page 15: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Choice of Stencil

ntmx 1mx 1mx 2mx 2mx

x3mx 3mx

ntmx 1mx 1mx 2mx 2mx

x3mx 3mx

ntmx 1mx 1mx 2mx 2mx

x3mx 3mx

ntmx 1mx 1mx 2mx 2mx

x3mx 3mx

ntmx 1mx 1mx 2mx 2mx

x3mx 3mx

And many more combinations

Page 16: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Use Taylor’s Series

• In much the same spirit as time-domain we can expand the solution at each grid point in terms of u and its derivatives as a power series in dx (the space between spatial grid points)

• Examples:

2 2 3 3*

1 2 3

2 2 3 3**

1 2 3

2! 3!

2! 3!

m m m m m

m m m m m

du dx d u dx d uu x u x dx x x x

dx dx dx

du dx d u dx d uu x u x dx x x x

dx dx dx

Page 17: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Left Differencing

• Using the data points on this stencil we wish to compute an approximation to the gradient of u at

• Dividing and rearranging we find:

ntmx 1mx 1mx 2mx 2mx

x3mx 3mx

mx

2 2 3 3

*1 2 32! 3!m m m m m

du dx d u dx d uu x u x dx x x x

dx dx dx

2 2 3

1 *2 32! 3!

m mm m m

u x u xdu dx d u dx d ux x x

dx dx dx dx

Page 18: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Left Differencing

ntmx 1mx 1mx 2mx 2mx

x3mx 3mx

2 2 3

1 *2 32! 3!

m mm m m

u x u xdu dx d u dx d ux x x

dx dx dx dx

This gives us an obvious one-sided linear interpolation formulaof the derivative.

We will later on decide whether it is suitable for time-stepping withAB or RK.

Page 19: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

• We define the following difference operator (appalling but fairly standard notational choice):

• Where represents the function sampled at the m’th data point.

• The difference formula shows

2 2 3

*2 32! 3!m m m m

du dx d u dx d uu x x x

dx dx dx

Left Difference Operator

1m mm

u uu

dx

mu

i.e. delta- is a first order approximation of the derivative operator

Page 20: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Right Difference Operator

ntmx 1mx 1mx 2mx 2mx

x3mx 3mx

1m mm

u uu

dx

2 2 3

*2 32! 3!m m m m

du dx d u dx d uu x x x

dx dx dx

i.e. delta+ is a first order approximation of the derivative operator

Page 21: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Central Differencing Operator

• Subtracting the forward and backward expansions:

• We obtain:

2 2 3 3 4 4 5 5*

1 2 3 4 5

2 2 3 3 4 4 5 5**

1 2 3 4 5

2! 3! 4! 5!

2! 3! 4! 5!

m m m m m m m

m m m m m m m

du dx d u dx d u dx d u dx d uu x u x dx x x x x x

dx dx dx dx dx

du dx d u dx d u dx d u dx d uu x u x dx x x x x x

dx dx dx dx dx

0

3 3

51 1 3

22

3!m m m m

du dx d uu x u x dx x x O dx

dx dx

ntmx 1mx 1mx 2mx 2mx

x3mx 3mx

Page 22: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

cont

• i.e. the central differencing operator is second order accurate in dx

• Note: for the error term to be bounded we require that the third derivative be bounded.

2 3

41 10 3

:2 3!

m mm m m

u u du dx d uu x x O dx

dx dx dx

Page 23: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Approximating the Second Derivative

• We can create an approximation of the second derivative:

12

1 12 2

1 12

2 2 3 3 4 4*

2 3 4

2

2 2 3 3 4 4**

2 3 4

:

2

2! 3! 4!1

2

2! 3! 4!

m mm m

m m m m

m m m

m m m m m

m

m m m m m

u uu u

dxu u u u

dx dxu u u

dx

du dx d u dx d u dx d uu x dx x x x x

dx dx dx dxu x

dxdu dx d u dx d u dx d u

u x dx x x x xdx dx dx dx

Page 24: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

cont

2 2 3 3 4 4*

2 3 4

22

2 2 3 3 4 4**

2 3 4

22

2

2! 3! 4!1

2

2! 3! 4!

m m m m m

m m

m m m m m

m

du dx d u dx d u dx d uu x dx x x x x

dx dx dx dxu u x

dxdu dx d u dx d u dx d u

u x dx x x x xdx dx dx dx

d ux O dx

dx

Page 25: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Delta Operators

2 2 3*

2 3

2 2 3*

2 3

22 2

2

2 34

0 3

2! 3!

2! 3!

3!

m m m m

m m m m

m m

m m m

du dx d u dx d uu x x x

dx dx dx

du dx d u dx d uu x x x

dx dx dx

d uu x O dx

dx

du dx d uu x x O dx

dx dx

Page 26: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Using the delta’s: Example 1

2 34

0 3

2 24

2

3!

13!

m m m

m

du dx d uu x x O dx

dx dx

dx d dux O dx

dx dx

We use:

2 34

0 3

22 4

3!

13!

m m m

m

du dx d uu x x O dx

dx dx

dx dux O dx

dx

Page 27: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Example 2

• We can use the difference operators to eliminate the third order spatial derivative:

2 24

0 2

22 2 2 4

0

22 4

0

13!

3!

3!

m m

m m

m m

dx d duu x O dx

dx dx

du dxx O dx O dx u O dx

dx

du dxx u O dx

dx

2

2 40 03!m m

du dxx u O dx

dx

Page 28: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Example 2 cont

• We can expand out the difference operator

• And we have a super difference formula for the derivative which is 4th order accurate!

• What is the stencil for this formula ? (volunteer)

22 4

0 0

21 12 4

1 1 42 1 1 2

42 1 1 2

3!

13! 2

12 2

2 3!21

8 812

m m

m m

m mm m m m m m

m m m m

du dxx u O dx

dx

u udxO dx

dx

u uu u u u u u O dx

dx dx

u u u u O dxdx

Page 29: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Example 2 cont

• We can think of this difference formula as a matrix operator acting on the point data values aligned in a vector:

• Becomes

42 1 1 2

18 8

12m m m m m

dux u u u u O dx

dx dx

Page 30: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

For 10 Points on a Periodic Interval

1 1

2 2

3 3

4

10 10

0 8 1 1 8

8 0 8 1 1

1 8 0 8 1

1 8 0 8 1

1 8 0 8 11

1 8 0 8 112

1 8 0 8 1

1 8 0 8 1

1 1 8 0 8

8 1 1 8 0

u u

u u

u u

dO dx

dx dx

u u

Notice: the matrix is skew-symmetrix imaginary eigenvalues

Page 31: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Diagonalize

• We now use this formula in the PDE which we evaluate at the 10 spatial sample points:

1 1

2 2

3 3

4 4

5 5

6 6

7 7

8 8

9 9

10 10

0 8 1 1 8

8 0 8 1 1

1 8 0 8 1

1 8 0 8 1

1 8 0 8 1

1 8 0 8 112

1 8 0 8 1

1 8 0 8 1

1 1 8 0 8

8 1 1 8 0

u u

u u

u u

u u

u ud d cc

u udt dx dx

u u

u u

u u

u u

1

2

3

4

5 4

6

7

8

9

10

u

u

u

u

uO dx

u

u

u

u

u

This is an identity (although we are a little fuzzy about the O(dx^4) term)

Page 32: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Some Notation

• We will represent the set of data values at the spatial points as a vector:

1

2

3

4

5

6

7

8

9

10

u

u

u

u

u

u

u

u

u

u

u

Page 33: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

cont

• The system matrix is an approximation of the derivative operator so we will denote it as D

0 8 1 1 8

8 0 8 1 1

1 8 0 8 1

1 8 0 8 1

1 8 0 8 11

1 8 0 8 112

1 8 0 8 1

1 8 0 8 1

1 1 8 0 8

8 1 1 8 0

dx

D

Page 34: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

PDE System of ODE’s -> Decoupled ODE’s

• So we can express the PDE as:

• Let’s make a semi-discrete scheme:

• As a theoretical exercise we can diagonalize the skew symmetric D operator with a diagonal matrix.

• Then:

4dc O dx

dt u Du

1 D S S

where

dc

dtd

cdt

1

1

u S S u

v v v S u

Λ

dc

dtu Du

Page 35: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

cont

• The system of 10 ODE’s:

• are now totally decoupled, so we can apply our extensive knowledge of treating scalar ODE’s to each of the components of vhat.

• All we have to do is make sure that the eigenvalues of the cD matrix are squeezed into the time-stepping region by choosing small enough dt

dc

dt v v

Page 36: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

cont

• By linearity of the right hand side we can be sure that time stepping (say using AB or RK) the original ODE will be fine as long as fits in the relevant stability region…

• We now need to solve:

• Noting our studies of the stability regions, the fact that all the eigenvalues sit on the imaginary axis rules out – Euler-Forward (unconditionally unstable)

– AB2 and RK2 (marginally stable)

1 10max ii

cdt

dc

dt u f u Du

Page 37: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

cont

• In this case we can use Gerschgorin’s theorem to bound the magnitude of the eigenvalues.

• The Gerschgorin disk for each row is centered at zero with radius:

0 8 1 1 8

8 0 8 1 1

1 8 0 8 1

1 8 0 8 1

1 8 0 8 11

1 8 0 8 112

1 8 0 8 1

1 8 0 8 1

1 1 8 0 8

8 1 1 8 0

dx

D

38 1 1 8

12 2

c c

dx dx

Page 38: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Cont (dt estimate)

• The skew symmetry tells us the eigenvalues are on the imaginary axis so we know that if:

• is in the stability region we have sufficient conditions for stability of the ODE.

• This is a pretty good estimate, as the eigenvalues given by Matlab for the 10x10 matrix are:

3 3,

2 2

cdt cdti i

dx dx

dxD

Page 39: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Comment on Gerschgorin Bound

• The Gerschgorin estimate was pretty good in this case (we suggested eigenvalues in i*[-1.5,1.5] )

>> 12*dxD

ans =

0 8 -1 0 0 0 0 0 1 -8 -8 0 8 -1 0 0 0 0 0 1 1 -8 0 8 -1 0 0 0 0 0 0 1 -8 0 8 -1 0 0 0 0 0 0 1 -8 0 8 -1 0 0 0 0 0 0 1 -8 0 8 -1 0 0 0 0 0 0 1 -8 0 8 -1 0 0 0 0 0 0 1 -8 0 8 -1 -1 0 0 0 0 0 1 -8 0 8 8 -1 0 0 0 0 0 1 -8 0

>> [v,dxD] = test4th(10); >> >> v

v =

0 - 1.36603956377562i 0 - 1.17011114634479i 0 - 0.94222308910582i 0 - 0.62520425034077i 0 - 0.00000000000000i 0 + 0.00000000000000i 0 + 0.62520425034077i 0 + 0.94222308910582i 0 + 1.17011114634479i 0 + 1.36603956377562i

Page 40: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Note on Those Eigenvalues

• What should the eigenvalues of the derivative operator ideally tend to in the limiting of decreasing dx?

• Example (10, 20, 80 points with the periodic length 2*pi):

>> [dxDeigs, dxD] = test4th(10);>> dx = 2*pi/10; >> sort(dxDeigs/dx)

ans =

0.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 - 0.9950i 0.0000 + 0.9950i 0 - 1.4996i 0 + 1.4996i 0 - 1.8623i 0 + 1.8623i -0.0000 - 2.1741i -0.0000 + 2.1741i

>> [dxDeigs, dxD] = test4th(20);>> dx = 2*pi/20;>> >> e = sort(dxDeigs/dx);>> e(1:10)

ans =

-0.0000 -0.0000 -0.0000 - 0.9997i -0.0000 + 0.9997i 0.0000 - 1.6233i 0.0000 + 1.6233i -0.0000 - 1.9901i -0.0000 + 1.9901i 0.0000 - 2.9290i 0.0000 + 2.9290i

>> [dxDeigs, dxD] = test4th(80);>> dx = 2*pi/80;>> e = sort(dxDeigs/dx);>> >> e(1:10)

ans =

0.0000 - 0.0000i 0.0000 + 0.0000i -0.0000 - 1.0000i -0.0000 + 1.0000i -0.0000 - 1.6639i -0.0000 + 1.6639i -0.0000 - 2.0000i -0.0000 + 2.0000i 0.0000 - 2.9997i 0.0000 + 2.9997i

Page 41: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

cont

• From Fourier analysis we know that the field u, if sufficiently smooth has a Fourier representation.

• Taking the first derivative we achieve:

• Also, each Fourier mode is an eigenfunction of the differentiation operator with eigenvalue

2

ˆi xLu u e

2 2

2

i x i xL L

i xL

de u e

dx L

duu e

dx L

2 for all

L

Page 42: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

cont

• By the completeness of the Fourier modes, we would hope the eigenvalues of the discrete approximation differentation operator would converge to

• However, we see an oddity

• There is the +/-1.6639 in there.

• More about this later.

0, 1, 2, 3,...

>> [dxDeigs, dxD] = test4th(80);>> dx = 2*pi/80;>> e = sort(dxDeigs/dx);>> >> e(1:10)

ans =

0.0000 - 0.0000i 0.0000 + 0.0000i -0.0000 - 1.0000i -0.0000 + 1.0000i -0.0000 - 1.6639i -0.0000 + 1.6639i -0.0000 - 2.0000i -0.0000 + 2.0000i 0.0000 - 2.9997i 0.0000 + 2.9997i

2 for all

L

Page 43: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Using RK4

1

/ 2 / 2

/ 2 / 2

12 2

6

n n

n n

n n

n n

n n

dt cdt

dt cdt

dt cdt

dt cdt

a f u Du

b f u a D u a

c f u b D u b

d f u c D u c

u u a b c d

To avoid confusion with subindices for the vector, we haveused super indices to represent the time level.

Page 44: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Using AB4

Page 45: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

That’s a Scheme

• Without much trouble we have created a stable finite difference scheme for the advection equation – given the local truncation errors are small we might expect that the scheme is high order too.

• We will examine the accuracy and conditions for convergence of this kind of finite difference scheme next lecture.

• However, I did steer the choice of spatial difference discretization towards a skew symmetric operator

• I will motivate the choices next lecture.

Page 46: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Homework 2 (due 02/03/2005)

Q1) Implement the 6 stage, 5th order Runge-Kutta from:

http://www.library.cornell.edu/nr/bookcpdf/c16-2.pdf

Use equations: 16.2.4 , 16.2.5, 16.2.6 with coefficients at the top of table 717 (Cash-Karp coefficients provided on the website)

Q1a) Solve

Q1b) Estimate dtmax by concocting a Lipschitz constant for the right hand side of the ODE.

Q1c) Solve 4 times, using (i) dt=dtmax (ii) dt=dtmax/2 (iii) dt=dtmax/5 (iv) dt=dtmax/6At each time step estimate the error (using 16.2.7) and compare with actual error (plot both on a graph, use log scale if necessary).

cos 0 1

0 1

dut u t

dtu