lecture 7: grid discretization, actual pde’s

28
Lecture 7: Grid discretization, actual PDE’s October 7, 2015 1 Goal The goal of this Lecture is to provide practical examples of PDE discretizations and discuss them in view of the general criteria exposed in the previous lecture. 1

Upload: others

Post on 25-May-2022

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 7: Grid discretization, actual PDE’s

Lecture 7: Grid discretization, actual PDE’s

October 7, 2015

1 Goal

The goal of this Lecture is to provide practical examples of PDE discretizationsand discuss them in view of the general criteria exposed in the previous lecture.

1

Page 2: Lecture 7: Grid discretization, actual PDE’s

2 Von Neumann analysis and discrete disper-sion relation

A powerful way of analyzing the stabiliy and accuracy of discrete equationsis to derive their dispersion relation, discrete dispersion relation (DDR). Thisamounts to Fourier transforming the equation, i.e expanding the discrete solu-tion in plane waves of the form:

ei(kxj−ωtn)

and inspect the functional relation

f(ωh, kd) = 0

Consistency requirement impose that this relation reduces to the continuumone in the limit kd → 0 and ωh → 0. However, many sources of inaccuracymay arise due to the discretization. These errors split into two main categories:amplitude errors and phas eerrors. Amplitude errors may either show in the formof uncontrolled growth (instability) or excessive damping (numerical diffusion).Phase errors usually associate with defective propagation, i.e. correction to theexact proapgation speed and deformation of the propgating profile (dispersionerrors).

3 Diffusion equation in d=1

Consider the Diffusion Equation (DE) in d=1 spatial dimensions:

∂tφ = D∂xxφ (1)

The exact solution in infinite space with initial condition φ(x, t = 0) = δ(x)is a gaussian function centered about x = 0 with spread δ(t) =

√Dt. This

is inherently stable. We next compute the Dispersion Relation (DR), whichamounts to Fourier-transforming the above. With the operational correspon-dence ∂t = −iω and ∂x = ik, we obtain

−iω = −Dk2

namely, separating real and imaginary parts:

ωR = 0, γ = −Dk2

The physical meaning is that a wavelength λ = 2π/k is exponentially dampedat a rate γ = Dk2, small wavelengths are much more damped than large ones.Everything is nicely stable (so long as D > 0).

2

Page 3: Lecture 7: Grid discretization, actual PDE’s

4 Euler + centered space differences

This amounts to

φn+1j − φnj =

Dh

d2(φnj+1 − 2φnj + φnj−1)

Upon FT:e−iωh − 1 = CD(eikd − 2 + e−ikd)

where CD ≡ Dhd2 is the diffusive CFL.

Separating the real-imaginary parts

eγhcos(ωRh) = 1 + 2CD(cos(kd)− 1)) (2)

eγhsin(ωRh) = 0 (3)

The second immediately delivers ωR = 0, which is exact, no approximation.The first is less immediate; let us square both and sum up, to obtain

e2γh = [1 + 2CD(cos(kd)− 1))]2 = 1 + 4CDX + 4C2DX

2

where we have set X ≡ cos(kd)− 1.Stability implies γ < 0, hence X+CDX

2 < 0 For X < 0, the regime relevantto the continuum limit kd→ 0, this yields 1−CD|X| > 0 and since 0 < |X| < 2,this implies

CD < 1/2

This is the CFL condition introduced in the previous lecture.

4.0.1 Continuum limit and order of accuracy

In the continuum limit kd → 0 and ωh → 0, the discrete dispersion relation(DDR) reduces to

1 + 2γh ∼ 1− 2Cdk2d2

namelyγ ∼ −k2D

which is precisely the continuum DR. Of course, this is approximateto first orderin h and second order in d: i.e. the scheme is first order in time and second inspace.

4.1 Stability from realizability

Rearrange the scheme in 3-diagonal form:

φn+1j = aφnj−1 + cφnj + bφnj+1 (4)

where a simple calculation shows that:

a = b = CD, c = 1− 2CD

3

Page 4: Lecture 7: Grid discretization, actual PDE’s

The above eq. lends itself to a transparent interpretation: the future state ata given location j is a weighted sum of the past state in a close neighborhood,in fact just the same site and its left/right neighbors. This is typical of local-explicit schemes, the simplest brand in town. One notes that the coefficientsa, b, c sum to 1, which configures them as a sort of probability of transferinginformation from site to site in time. In this respect, a realizability constraintimposes that they are all non-negative, which implies indeed CD < 1/2, i.e, thestability condition we found before by more elaboarte calculations.

Realizability often offers a shortest path to assess stability; however the twoconditions are not one-to-one related.

5 Advection equation

Let us now consider the advection eqaution

∂tφ = −U∂xφ (5)

where U = const for simplicity.Upon FT, the continuum DR reads as

ωR = kU, γ = 0

Let us now consider a first-order Euler in time as combined with centereddifferences in space

φn+1j − φnj = −Uh

2d(φnj+1 − φnj−1)

After some elementary algebra, the tridiaginal form delivers the followingcoefficients

a = CA/2, b = −CA/2, c = 1

where

CA =Uh

d

is the advective CFL number.Simple calculations deliver the DDR in implicit form:

eγhcos(ωRh) = 1 (6)

eγhsin(ωRh) = CAsin(kd) (7)

By squaring and summing:

e2γh = 1 + C2Asin

2(kd

This shows, that regardless of the value of CA, the rhs cannot be smallerthan 1, which indicates unconditional instability!

4

Page 5: Lecture 7: Grid discretization, actual PDE’s

The same conclusion would follow by inspecting the realizability of the tridi-agonal formulation: one of the two side coefficients a and b is bound to benegative regardless of the value of CA.

How come such a simple scheme can be such a disaster? The reason is that itbreaks a basic continuum symmetry between space and time. In the continuum,space and time derivatives come on teh same footing, both first order, in factx/U is an equivalent time.

X n+1

X 0 X n

j-1 j j+1

Spacetime connectivity diagram of the Euler-centered scheme.

The centered diferencing in space breaks this equivalence, since space in-formation is taken from both sides; innocent as it may seem, this is a fatalflaw!

5.1 Remedy: the upwind scheme

Having recognized the cause of the instability, a simple remedy comes by imme-diately: take finite-differences from one side only too. In particular, if U > 0, onewould difference the side the wind blows from, i.e. from left: −U(φj − φj−1/d.

Elementary algebra delivers the following coefficients

a = CA, b = 0, c = 1− CA

This shows that stability is expected whenever CA < 1, again the CFL condition.But, how about accuracy?

By carrying on the detailed calculations, the upwind DDR reads as follows:

γ ∼ (CA − 1)Udk2

This shows that under stable conditions, the upwind scheme introduces asubstantial artificial damping, known as numerical diffusion.

Better solutions consist of adding some extra-diffusion term with negativediffusivity so as to compensate the artificial upwind diffusivity. This is knownas Lax-Wendroff scheme, and it is tantamount to a centered difference of theoriginal advection problem plus an artificial diffusion term of the form (δ +U2h/2)∂xx, with 0 < delta << 1.

6 Advection-Diffusion-Reaction

∂tφ = −U∂xφ+D∂xxφ+R(φ) (8)

5

Page 6: Lecture 7: Grid discretization, actual PDE’s

where the reaction term is local and non-linear. A very popular expression isthe logistic growth R(φ) = αφ(1− φ).

7 Other equations

The above notions are fairly powerful and general, they permit to analyse virtu-ally any linear equation with constant coefficients. When non-linearity and/orinhomogeneity come into play, Fourier analysis formally fades away. However,it is still useful if these effects are sufficiently weak.

8 Boundary conditions

For the simple time-marching schemes discussed so far, it’s pretty simple. Con-sider the case of Dirichlet b.c.

φnj=1 = L, φnj=N = R,

Once this are set once and for all, one simply updates the bulk sites j = 2, N−1according to the usual scheme:

φn+1j = aφnj−1 + cφnj + bφnj+1, j = 2, N1

where boundary values are taken from the Dirichlet condition. The boundarynodes, on the other hand, require no update, since the Dirichlet conditions holdat all times.

L x x x ... x x x ... R

1 2 ... N

9 Multiple dimensions

The principles remain the same but new sources of error become relevant, a pri-mary one being breaking of isotropy. Consider for instance the two-dimensionaldiffusion equation

∂tφ = D(∂xx + ∂yy)φ(x, y; t)

With xj = jdx and yl = ldy, a straightforward discrete Laplacian reads

∆φ ∼ φj+1,l − 2φjl + φj−1,l

d2x+φj,l+1 − 2φjl + φj,l−1

d2y

For the case dx = dy = d, this leads to the well-known stencil

6

Page 7: Lecture 7: Grid discretization, actual PDE’s

1 l+1

1 -4 1 l

1 l-1

j-1 j j+1

which is second order accurate and second order isotropic. To fourth order,anisotropic terms appear due to lack of connections along the diagonal, whichintroduce spurious terms proportional to the mixed derivatives ∂xxyy. Power-ful ways of obtaining accurate and isotropic stencils in d=2 and d=3 maybediscussed in a lecture apart, if desired.

10 Exercises

1. Write a computer program to solve the diffusion equation, test the accu-racy and stability upon changing the mesh spacing

2. Same with the advection-diffusion equation

3. Show that the lax-Wendroff coefficients read as follows: a = Cδ +CA(1 +CA)/2, b = Cδ + CA(−1 + CA)/2, c = 1− a− b, and analyze its stabilityand accuracy.

7

Page 8: Lecture 7: Grid discretization, actual PDE’s

8

Page 9: Lecture 7: Grid discretization, actual PDE’s

9

Page 10: Lecture 7: Grid discretization, actual PDE’s

10

Page 11: Lecture 7: Grid discretization, actual PDE’s

11

Page 12: Lecture 7: Grid discretization, actual PDE’s

12

Page 13: Lecture 7: Grid discretization, actual PDE’s

13

Page 14: Lecture 7: Grid discretization, actual PDE’s

14

Page 15: Lecture 7: Grid discretization, actual PDE’s

15

Page 16: Lecture 7: Grid discretization, actual PDE’s

16

Page 17: Lecture 7: Grid discretization, actual PDE’s

17

Page 18: Lecture 7: Grid discretization, actual PDE’s

18

Page 19: Lecture 7: Grid discretization, actual PDE’s

19

Page 20: Lecture 7: Grid discretization, actual PDE’s

20

Page 21: Lecture 7: Grid discretization, actual PDE’s

21

Page 22: Lecture 7: Grid discretization, actual PDE’s

22

Page 23: Lecture 7: Grid discretization, actual PDE’s

23

Page 24: Lecture 7: Grid discretization, actual PDE’s

24

Page 25: Lecture 7: Grid discretization, actual PDE’s

25

Page 26: Lecture 7: Grid discretization, actual PDE’s

26

Page 27: Lecture 7: Grid discretization, actual PDE’s

27

Page 28: Lecture 7: Grid discretization, actual PDE’s

28