REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13,...

19
2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14 REVIEW Lecture 12-13: Classification of PDEs and examples of finite-difference discretization Error Types and Discretization Properties Finite Differences based on Taylor Series Expansions – Higher Order Accuracy Differences, with Examples Incorporate more higher-order terms of the Taylor series expansion than strictly needed and express them as finite differences themselves (making them function of neighboring function values) If these finite-differences are of sufficient accuracy, this pushes the remainder to higher order terms => increased order of accuracy of the FD method • General approximation: m u s au m i j i x x j i r – Taylor Tables or Method of Undetermined Coefficients (Polynomial Fitting) • More systematic (Tables) way to solve for coefficients a i of higher-order FD 2.29 Numerical Fluid Mechanics PFJL Lecture 14, 1 1

Transcript of REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13,...

Page 1: REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13, cont’d: • Finite Differences based Polynomial approximations – Obtain polynomial

2.29 Numerical Fluid MechanicsFall 2011 – Lecture 14

REVIEW Lecture 12-13: • Classification of PDEs and examples of finite-difference discretization

• Error Types and Discretization Properties • Finite Differences based on Taylor Series Expansions

– Higher Order Accuracy Differences, with Examples • Incorporate more higher-order terms of the Taylor series expansion than

strictly needed and express them as finite differences themselves (making them function of neighboring function values)

• If these finite-differences are of sufficient accuracy, this pushes the remainder to higher order terms => increased order of accuracy of the FD method

• General approximation: mu s

a u m i ji x x j ir

– Taylor Tables or Method of Undetermined Coefficients (Polynomial Fitting)• More systematic (Tables) way to solve for coefficients ai of higher-order FD

2.29 Numerical Fluid Mechanics PFJL Lecture 14, 1 1

Page 2: REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13, cont’d: • Finite Differences based Polynomial approximations – Obtain polynomial

2.29 Numerical Fluid MechanicsFall 2011 – Lecture 14

REVIEW Lecture 13, cont’d: • Finite Differences based Polynomial approximations

– Obtain polynomial (in general un-equally spaced), then differentiate if needed • Newton’s interpolating polynomial formulas

Triangular Family of Polynomials (case of Equidistant Sampling, similar if not equidistant)

• Lagrange polynomial n n x xf x x ( ) j

(Reformulation of Newton’s polynomial) ( ) Lk ( ) ( f xk ) with Lk x k 0 j0, jk xk x j

• Hermite Polynomials and Compact/Pade’s Difference schemes s m q (Use the values of the function and b u

a u i m i ji xits derivative(s) at nodes) ir x j i i p

2.29 Numerical Fluid Mechanics PFJL Lecture 14, 2 2

Page 3: REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13, cont’d: • Finite Differences based Polynomial approximations – Obtain polynomial

FINITE DIFFERENCES – Outline for Today

• Polynomial approximations – Newton’s formulas – Lagrange polynomial and un-equally spaced differences – Hermite Polynomials and Compact/Pade’s Difference schemes

• Finite Difference: Boundary conditions • Finite-Differences on Non-Uniform Grids and Uniform Errors: 1-D • Grid Refinement and Error Estimation:

– Order of convergence, discretization error, Richardson’s extrapolation and Iterative improvements using Roomberg’s algorithm

• Fourier Analysis and Error Analysis – Differentiation, definition and smoothness of solution for ≠ order of spatial operators

• Stability – Heuristic Method – Energy Method – Von Neumann Method (Introduction)

• Hyperbolic PDEs 2.29 Numerical Fluid Mechanics PFJL Lecture 14, 3

3

Page 4: REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13, cont’d: • Finite Differences based Polynomial approximations – Obtain polynomial

References and Reading Assignments

• Chapter 3 on “Finite Difference Methods” of “J. H. Ferzigerand M. Peric, Computational Methods for Fluid Dynamics. Springer, NY, 3rd edition, 2002”

• Chapter 3 on “Finite Difference Approximations” of “H. Lomax, T. H. Pulliam, D.W. Zingg, Fundamentals of ComputationalFluid Dynamics (Scientific Computation). Springer, 2003”

• Chapter 23 on “Numerical Differentiation” and Chapter 18 on “Interpolation” of “Chapra and Canale, Numerical Methods for Engineers, 2010/2006.”

2.29 Numerical Fluid Mechanics PFJL Lecture 14, 4 4

Page 5: REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13, cont’d: • Finite Differences based Polynomial approximations – Obtain polynomial

Finite Difference Schemes: Implementation of Boundary conditions

• For unique solutions, information is needed at boundaries • Generally, one is given either:

i) the variable: u x( x , ) t u ( )t (Dirichlet BCs) bnd bnd

uii) a gradient in a specific direction, e.g.: = bnd (t) (Neumann BCs) x ( xbnd , ) t

iii) a linear c ombination of the two quantities (Robin BCs)

• Straightforward cases: – If value is known, nothing special needed (one doesn’t solve for the BC) – If derivatives are specified, for first-order schemes, this is also

straightforward to treat

2.29 Numerical Fluid Mechanics PFJL Lecture 14, 5 5

Page 6: REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13, cont’d: • Finite Differences based Polynomial approximations – Obtain polynomial

Finite Difference Schemes: Implementation of Boundary conditions, Cont’d

• Harder cases: when higher-order approximations are used – At and near the boundary: nodes outside of domain would be needed

• Remedy: use different approximations at and near the boundary – Either, approximations of lower order are used – Or, approximations go deeper in the interior and are one-sided. For example,

u u2 u1• 1st order forward-difference: 0 0 u2 u1x t x2 x( xbnd , ) 1

• Parabolic fit to the bnd point and two inner points: 2 2 2 2u x( x ) u (x x ) u (x x ) (x x ) u 3 2 1 2 3 1 1 3 1 2 1 u3 4 u2 3u1 for equidistant nodes x , ) (x )( x x x2 )x x )( 2x ( xbnd t 2 1 3 1 3

u 2u 9u 18u 11u4 3 2 1 3• Cubic fit to 4 nodes (3rd order difference): ( ) for equidistant nodes O xx 6x( xbnd , ) t

18u 9u 2u 6x u 2 3 4• Compact schemes, cubic fit to 4 pts: u( t u1 for equidistant nodes , ) xbnd 11 11 x 1

• In Open-boundary systems, boundary problem is not well posed => –Separate treatment for inflow/outflow points, multi-scale approach and/or

generalized inverse problem (using data in the interior)2.29 Numerical Fluid Mechanics PFJL Lecture 14, 6

6

Page 7: REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13, cont’d: • Finite Differences based Polynomial approximations – Obtain polynomial

Finite-Differences on Non-Uniform Grids: 1-D

• Truncation error depends not only on grid spacing but also on the derivatives of variable

2 3 nx x x nf (x ) f (x ) x f '(x ) f ''(x ) f '''(x ) ... f (x ) Ri1 i i i i i n2! 3! n! n1x ( 1) R f n ( )n n 1!

• Uniform error distribution can not be achieved on a uniform grid => non-uniform grids – Use smaller (larger) Δx in regions where derivatives of the function are

large (small) => uniform discretization error

– However, in some approximation (centered-differences), specific terms cancel only when the spacing is uniform

• Example: let’s define x x x , x x xi1 i1 i i i i1

2 3 n(x x ) (x x ) (x x ) ni i if ( ) f (x ) (x x ) f '(x ) f ''(x ) f '''(x ) ... f (x x ) Ri i i i i i n2! 3! n!and n1(x xi ) ( 1) nR f ( )n n 1!

2.29 Numerical Fluid Mechanics PFJL Lecture 14, 7 7

Page 8: REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13, cont’d: • Finite Differences based Polynomial approximations – Obtain polynomial

Non-Uniform Grids Example: 1-D Central-difference

• Evaluate f(x) at xi+1 and xi-1 , subtract results, lead to central-difference 2 3 nx x x ni1 i1 i1f (x ) f (x ) x f '(x ) f ''(x ) f '''(x ) ... f (x ) Ri1 i i1 i i i i n2! 3! n!

2 3 nx x ( x )i i i n( ) f x ) x f '(x ) f ''(x ) f '''(x ) ... f (f x ( x ) Ri1 i i i i i i n2! 3! n! 2 2 3 3( ) f x ) x x xf x ( xi1 i1 i1 i i1 if '(x ) f ''(x ) f '''(x ) ... Ri i i nx x 2! ( x x ) 3! ( x x )i1 i1 i1 i1 i1 i1

= Truncation error x

• For a non-uniform mesh, the leading truncation term is O(Δx)

– The more non-uniform the mesh, the larger the 1st term in truncation error

x– If the grid contracts/expands with a constant factor re : xi1 re i

(1 r ) xre e i– Leading truncation error term is : x f ''(xi )2 – If re is close to one, the first-order truncation error remains small: this is

good for handling any types of unknown function f(x)

2.29 Numerical Fluid Mechanics PFJL Lecture 14, 8 8

Page 9: REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13, cont’d: • Finite Differences based Polynomial approximations – Obtain polynomial

Non-Uniform Grids Example: 1-D Central-difference

• However, what matters is: “rate of error reduction as grid is refined”!

x 2h r x2hi1 e h, i 2

ix 1 r , xe i h

• Consider case where refinement is done by adding more grid points but keeping a constant ratio of spacing (geometric progression), i.e.

• For coarse grid pts to be collocated with fine-grid pts: (re,h)2 = re,2h

• The ratio of the two truncation errors at a common point is then: (1 r ,2 e h i f ''(x ) (1 2

2 i rR which is R , e h ) since x2h

(1 r ) xh r i x i xi 1 (r , xi1 1 e h ) ,e h i f ''(x , e h

i )2 – The factor R = 4 if re = 1 (uniform grid)

– When re > 1 (expending grid) or re < 1 (contracting grid), the factor R > 4

) x2h

2.29 Numerical Fluid Mechanics PFJL Lecture 14, 9 9

i-1

i-2 i-1 i+1 i+2

i+1i

i

Grid 2h

Grid h

Image by MIT OpenCourseWare.

Page 10: REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13, cont’d: • Finite Differences based Polynomial approximations – Obtain polynomial

Non-Uniform Grids Example: 1-D Central-differenceConclusions

• When a non-uniform grid is refined, error due to the 1st order term decreases faster than that of 2nd order term !

• Since (re,h)2 = re,2h , we have re,h → 1 as the grid is refined. Hence, convergence becomes asymptotically 2nd order (1st order term cancels)

• Non-uniform grids are thus useful, if one can reduce Δx in regions where derivatives of the unknown solution are large • Automated means of adapting the grid to the solution (as it evolves)

• However, automated grid adaptation schemes are more challenging in higher dimensions and for multivariate (e.g. physics-biology-acoustics) or multiscale problems

• (Adaptive) Grid generation still a very challenging problem in CFD

• Conclusions also valid for higher dimensions and for other methods (finite elements, etc)

2.29 Numerical Fluid Mechanics PFJL Lecture 14, 10 10

Page 11: REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13, cont’d: • Finite Differences based Polynomial approximations – Obtain polynomial

Grid-Refinement and Error estimation

• We found that for a convergent scheme, the discretization error ε is of ˆ ˆ ˆ O x p ) ( ) 0 )

where R is the remainder

the form: ( R (recall: , L ( ) 0 , Lx

• This discretization error can be estimated between solutions obtained on systematically refined/coarsened grids

pu ux x R -True solution u can be expressed either as:

u u ' (2 x) p R ' 2x

-Thus, the exponent p can be estimated: 2 4

2

log log 2 x x

x x

u u p u u

(need two equations to eliminate both Δx and p, hence u4Δx )

u ux 2x-The discretization error on the grid Δx can be estimated by: x p2 1

-Good idea: estimate p to check code. Is it equal to what it is supposed to be?

-When solutions on several grids are available, an approximation of higher accuracy can be obtained from the remainder: Richardson Extrapolation!

2.29 Numerical Fluid Mechanics PFJL Lecture 14, 11 11

Page 12: REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13, cont’d: • Finite Differences based Polynomial approximations – Obtain polynomial

Richardson Extrapolation and Romberg Integration

Richardson Extrapolation: method to obtain a third improved estimate of an integral based on two other estimates

Trapezoidal Rule:

h (grid space)

I(h)

I

h1h2

Richardson Extrapolation:

Consider:

2

2

2

Example

Assume:

)

For two different grid space h1 and h2:

From two O(h2), we get an O(h4)!

2.29 Numerical Fluid Mechanics PFJL Lecture 14, 12 12

Page 13: REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13, cont’d: • Finite Differences based Polynomial approximations – Obtain polynomial

Romberg’s Integration:Iterative application of Richardson’s extrapolation

Romberg Integration Algorithm, for any order k

h

I(h)

I

For Order 2 (case of previous slide):

h2 h1

k 1: O(h2) 2: O(h4) 3: O(h6) 4: O(h8)

a. 0.172800 1.068800

b. 0.172800 1.068800 1.484800

c. 0.172800 1.367467 1.640533 1.640533j 1.068800 1.623467 1.640533

1.484800 1.639467 1.600800

1.367467

1.367467 1.640533 1.623467

2.29 Numerical Fluid Mechanics PFJL Lecture 14, 13 13

Page 14: REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13, cont’d: • Finite Differences based Polynomial approximations – Obtain polynomial

Romberg’s Differentiation:Iterative application of Richardson’s extrapolation

‘Romberg’ Differentiation Algorithm, for any order k

h3 h2 h1

k

h

D(h)

D

D D

D

D

4D2,1 – D1,1

For Order 2 (as previous slide, but for differentiation):

1: O(h2) 2: O(h4) 3: O(h6) 4: O(h8)

a. 0.172800 1.068800

b,. 0.172800 1.068800 1.484800

c. 0.172800 1.367467 1.640533 1.640533j 1.068800 1.623467 1.640533

1.484800 1.639467 1.600800

1.367467

1.367467 1.640533 1.623467

2.29 Numerical Fluid Mechanics PFJL Lecture 14, 14 14

Page 15: REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13, cont’d: • Finite Differences based Polynomial approximations – Obtain polynomial

Fourier (Error) Analysis: Definitions

• Leading error terms and discretization error estimates can be complemented by a Fourier error analysis

• Fourier decomposition: – Any arbitrary periodic function can be decomposed into its Fourier

components:

( ) fk eikx (f x k integer, wavenumber) k

2

i k x im x e e 2km (orthogonality property) 0

1 2Using the orthog. property, i k x x e dx taking the integral/FT of f(x): f f ( )k 2 0

– Note: rate at which | fk | with |k| decays determine smoothness of f (x) • Examples drawn in lecture: sin(x), Gaussian exp(-πx 2), multi-frequency functions,

etc 2.29 Numerical Fluid Mechanics PFJL Lecture 14, 15

15

Page 16: REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13, cont’d: • Finite Differences based Polynomial approximations – Obtain polynomial

Fourier (Error) Analysis: Differentiations

• Consider the decompositions:

i kx i kx ( ) fk e or f x t fk ( ) t ef x ( , ) k k

n f n i kx • Taking spatial derivatives gives:n fk ( )t ik e

x k

r r k i kx • Taking temporal derivatives gives: f

d f ( )t e

t r k d t r

• Hence, in particular, for even or odd spatial derivatives:q 2q2q n k (real) n ik ( 1)

q 2 1n 2q 1 n i ( 1) qik k (imaginary)

2.29 Numerical Fluid Mechanics PFJL Lecture 14, 16 16

Page 17: REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13, cont’d: • Finite Differences based Polynomial approximations – Obtain polynomial

Fourier (Error) Analysis: Generic equation

f f• Consider the generic PDE: n

t xn

x t ( ) t eikx • Fourier Analysis: f ( , ) fk k

d fk ( )t nikx i kx fk ( ) ik • Hence: e t e

k d t k

d fk ( )t n n• Thus: f ( ) fk t for ik ik k t ( ) d t

t i kx t• And: f t( ) fk (0) e , f (x t , ) f (0) ek k

k

– “Phase speed”: c / ik

2.29 Numerical Fluid Mechanics PFJL Lecture 14, 17 17

Page 18: REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13, cont’d: • Finite Differences based Polynomial approximations – Obtain polynomial

Fourier (Error) Analysis: Generic equation

d fk ( )t n n• Generic PDE, FT: ik fk ( )t fk ( )t for ik d t

q 2q2q n k (real) n ik ( 1) q 2 1n n ( 1) q2q 1 ik i k (imaginary)

• Hence: f f Propagation: c / ik 1,

n 1 ik t x No dispersion

f 2 f 2n 2 k Decay t x2

f 3 f Propagation: c / ik k 2 ,n 3 ik 3

t x3 With dispersion f 4 f n 4 4 k 4 +: (Fast) Growth, : (Fast) Decayt x

• Etc

2.29 Numerical Fluid Mechanics PFJL Lecture 14, 18 18

Page 19: REVIEW Lecture 12-13 · 2.29 Numerical Fluid Mechanics Fall 2011 – Lecture 14. REVIEW Lecture 13, cont’d: • Finite Differences based Polynomial approximations – Obtain polynomial

MIT OpenCourseWarehttp://ocw.mit.edu

2.29 Numerical Fluid Mechanics Fall 2011

For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.