You are on page 1of 27

Finite difference schemes

Alternative to function approximations for (spatial) discretization of PDE Collocation method is the limit of FD Related to Lagrange Poly
Similar to Lagrange Polynomial, but applied locally

Measure of errors points per wavelength

Ae232a. Tim Colonius

FD discretization of PDE Method of lines


Semi-discrete approach Approximate each term in the equation locally based on function values at nearby points Not always unambiguous because continuous terms can be written in different forms (e.g. apply chain rule), and discrete approximations do not necessarily obey these continuous identities Different approximations usually needed for interior points than boundary or near-boundary points Leads to a system of ODE

Ae232a. Tim Colonius

Finite-difference Formulae:
Simplest to derive using Taylor-series expansion

Stencil Size: l+r +1

Ae232a. Tim Colonius

Ae232a. Tim Colonius

Simply done in maple

Classroom Note:Calculation of Weights in Finite Difference Formulas Bengt Fornberg, SIAM Rev. 40, 685 (1998)
Ae232a. Tim Colonius 5

Notes
Higher order derivatives similar On evenly spaced grid, symmetry/antisymmetry for even/ odd derivatives automatically zeros the odd/even equations Biased (no symmetry) schemes are useful for representing points near the edge of a domain. Construction of stencils larger than ~3 points need to be constructed with care due to instability. Geometry handled by overset grids.

Ae232a. Tim Colonius

Unevenly spaced grid

A better approach is to solve on a curvilinear grid

Ae232a. Tim Colonius

Geometry is handled by overset grids

Ae232a. Tim Colonius

Can we do better using same stencil?


Suppose we use derivatives at adjacent points in our formula

Ae232a. Tim Colonius

Notes
Terminology:
Compact Finite Difference Pad Finite Difference Implicit Finite Difference

Better accuracy and smaller stencil for same order Can play same games to derive forward/backward biased schemes But.we have coupled terms on the LHS In matrix form:

Ae232a. Tim Colonius

10

Solution
If we take at most L=R=1 tridiagonal matrix If we take at most L=R=2 penta-diagonal matrix Still O(N) computations to compute the derivative More computations Bad for parallel computations Obvious questionis the better accuracy for, say, the 4th order compact scheme (compared to explicit scheme) cost effective?
4 times smaller leading error E4 requires 3A + 2M per N C4 requires 3A + 3M per N

The answer is generally yes, but we will discuss more later

Ae232a. Tim Colonius

11

Optimized Finite Difference Schemes


Note that we have used all of the coefficients to minimize the error in the limit of h 0. Perhaps we should examine errors at finite h and see if we can choose (some or all of) the coefficients more wisely? How do we examine error at finite h? Need to pick a function (or class of functions) How about cosine and sine?
Ae232a. Tim Colonius 12

Fourier Analysis of Differencing Errors


Consider FD schemes applied to periodic problems Compare FD derivative to spectral derivative for each wavenumber Later this analysis will be crucial in understanding the stability of FD schemes

Ae232a. Tim Colonius

13

Fourier analysis of differencing errors


For local approximations (Finite-difference) it is useful to compare results to Spectrally accurate method. Analyze how accurate local differencing is for complex exponential at a given wavelength Gives nonlocal information about error (i.e. information at all scales) Rigorously restricted to periodic domains, but also useful as an approximate analysis for the interior of large domains

Ae232a. Tim Colonius

14

The modified wavenumber

Ae232a. Tim Colonius

15

Explicit formula for modified wavenumber

Ae232a. Tim Colonius

16

Centered 1st Derivative Examples

7pt 5pt 3pt

Ae232a. Tim Colonius

17

Points per wavelength


10 ppw 4 ppw 3 ppw 2 ppw

7pt 5pt 3pt

Ae232a. Tim Colonius

18

Biased schemes
Have complex modified wavenumbers

Ae232a. Tim Colonius

19

2nd Derivative Approximations (symmetric)

7 pt (6th order) 5 pt (4th order) 3 pt (2nd order)

Ae232a. Tim Colonius

20

Compact schemes (1st deriv)


6th order compact (r=l=2, R=L=1), 6th order explicit (r=l=3,R=L=0) 4th order compact (r=l=1, R=L=1),

4th order explicit (r=l=2,R=L=0)

Ae232a. Tim Colonius

21

The modified wavenumber (another derivation)

Ae232a. Tim Colonius

22

The modified wavenumber

Ae232a. Tim Colonius

23

Centered 1st Derivative Examples

Explicit schemes

5pt 3pt

7pt

Implicit (compact, Pad) schemes

6th order compact th order (r=l=2, 6 R=L=1), explicit (r=l=3,R=L= 0) 4th order explicit (r=l=2,R=L= 0)

4th order compact (r=l=1, R=L=1),

Ae232a. Tim Colonius

24

Optimized FD schemes
Choose some coefficients to give a certain order of accuracy Choose some coefficients to give a good modified wavenumber relation:
e.g. Make k=k at some particular points Minimize the error in k-k

Choose some coefficients to give other desirable properties


Efficiency? Low storage? Parallalizability? And so on

Ae232a. Tim Colonius

25

Efficiency
Different schemes have different operation counts Real cost is CPU time to compute a derivative, can be estimated with operation count Weight PPW with operation count to get normalized cost
Aside: scheme can also impact maximum stable time step for a given PDE. The plot on the next page accounts for this for the model advection equation, ut + ux = 0

Ae232a. Tim Colonius

26

Efficiency

Ref: Colonius & Lele, Prog. Aerosp. Science, 2005


Ae232a. Tim Colonius 27

You might also like