Sunteți pe pagina 1din 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:
| c
m
u |
s
a u =t
m | i j+i Ax
\
cx
.
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

2.29 Numerical Fluid Mechanics
Fall 2011 Lecture 14
REVIEW Lecture 13, contd:
Finite Differences based Polynomial approximations
Obtain polynomial (in general un-equally spaced), then differentiate if needed
Newtons interpolating polynomial formulas
Triangular Family of Polynomials
(case of Equidistant Sampling,
similar if not equidistant)
Lagrange polynomial n n
x x
f x x ( ) =
j
(Reformulation of Newtons polynomial)
( ) =

L
k
( ) ( f x
k
) with L
k
x
[
k =0 j=0, j=k
x
k
x
j
Hermite Polynomials and Compact/Pades Difference schemes
s m q
| |
(Use the values of the function and

b
c u


a u =t
i m | i j+i Ax
its derivative(s) at nodes)
i=r \
cx
.
j i
i= p
+
2.29
Numerical Fluid Mechanics PFJL Lecture 14, 2
2

FINITE DIFFERENCES Outline for Today
Polynomial approximations
Newtons formulas
Lagrange polynomial and un-equally spaced differences
Hermite Polynomials and Compact/Pades 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, Richardsons extrapolation and Iterative
improvements using Roombergs 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

References and Reading Assignments
Chapter 3 on Finite Difference Methods of J. H. Ferziger
and M. Peric, Computational Methods for Fluid Dynamics.
Springer, NY, 3
rd
edition, 2002
Chapter 3 on Finite Difference Approximations of H. Lomax,
T. H. Pulliam, D.W. Zingg, Fundamentals of Computational
Fluid 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


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
c u
ii) a gradient in a specific direction, e.g.: = |
bnd
(t) (Neumann BCs)
cx
( x
bnd
, ) t
iii) a linear c ombination of the two quantities (Robin BCs)
Straightforward cases:
If value is known, nothing special needed (one doesnt 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

Finite Difference Schemes:
Implementation of Boundary conditions, Contd
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,
c u u
2
u
1
1
st
order forward-difference:
= 0 ~ 0 u
2
= u
1
cx
t
x
2
x
( x
bnd
, ) 1
Parabolic fit to the bnd point and two inner points:
2 2 2 2
u x ( x ) + u (x x ) u (x x ) (x x ) (
c u 3 2 1 2 3 1 1

3 1 2 1

|
u
3
+ 4 u
2
3u
1
|
~

~ for equidistant nodes


|
cx
, )
(x )( x x x
2
) x x )(
\
2Ax
.
( x
bnd
t 2 1 3 1 3
c u 2u 9u +18u 11u
4 3 2 1
3
Cubic fit to 4 nodes (3
rd
order difference):
+ (A ) for equidistant nodes ~ O x
cx 6Ax
( x
bnd
, ) t
18u 9u + 2u 6Ax
|
c u
|
2 3 4
Compact schemes, cubic fit to 4 pts:
u
( t
= u
1
~

for equidistant nodes
, ) | x
bnd
11 11
\
cx
.
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


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 n
Ax Ax Ax
n
f (x ) = f (x ) + A x f '(x ) + f ''(x ) + f '''(x ) + ... + f (x ) + R
i+1 i i i i i n
2! 3! n!
n+1
Ax
( 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: lets define
Ax = x x , Ax = x x
i+1 i+1 i i i i1
2 3 n
(x x ) (x x ) (x x )
n
i i i
f ( ) = f (x ) + (x x ) f '(x ) + f ''(x ) + f '''(x ) + ... + f ( x x ) + R
i i i i i i n
2! 3! n!
and n+1
(x x
i
)
( 1) +

n
R = f ( )
n
n + 1!
2.29
Numerical Fluid Mechanics PFJL Lecture 14, 7
7

Non-Uniform Grids Example: 1-D Central-difference
Evaluate f(x) at x
i+1
and x
i-1
, subtract results, lead to central-difference
2 3 n
Ax Ax Ax
n
i+1 i+1 i+1
f (x ) = f (x ) + A x f '(x ) + f ''(x ) + f '''(x ) + ... + f (x ) + R
i+1 i i+1 i i i i n
2! 3! n!
2 3 n
Ax Ax (A x )
i i i
n
( ) = f x ) A x f '(x ) + f ''(x ) f '''(x ) + ... + f ( f x ( x ) + R
i1 i i i i i i n
2! 3! n!
2 2 3 3
( ) f x ) Ax A x Ax f x ( + A x
i+1 i1 i+1 i i+1 i
f '(x ) = f ''(x ) f '''(x ) + ... + R
i i i n
x x 2! ( x x ) 3! ( x x )
i+1 i1 i+1 i1 i+1 i1
= Truncation error t
Ax
For a non-uniform mesh, the leading truncation term is O(x)
The more non-uniform the mesh, the larger the 1
st
term in truncation error
= Ax
If the grid contracts/expands with a constant factor r
e
:
Ax
i+1
r
e i
(1 r ) Ax
r
e
e i
Leading truncation error term is :
t
Ax
~ f ''(x
i
)
2
If r
e
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

Non-Uniform Grids Example: 1-D Central-difference
However, what matters is: rate of error reduction as grid is refined!
Ax
2h
= r Ax
2h
i+1 e h , i 2
A
i
x
+1
= r
,
Ax
e 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: (r
e,h
)
2
= r
e,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
+ r
R ~
which is
R

~



, e h
)
since
Ax
2h
(1 r ) Ax
h
r
i
x =
i
A x
i
+
1
A = (r
,
+ Ax
i
1
1 e h
)
, e h i
f ''(x
, e h
i
)
2
The factor R = 4 if r
e
= 1 (uniform grid)
When r
e
> 1 (expending grid) or r
e
< 1 (contracting grid), the factor R > 4
) Ax
2h
2.29
Numerical Fluid Mechanics PFJL Lecture 14, 9
9
i-1
i-2 i-1 i+1 i+2
i+1 i
i
Grid 2h
Grid h
Image by MIT OpenCourseWare.

Non-Uniform Grids Example: 1-D Central-difference
Conclusions
When a non-uniform grid is refined, error due to the 1
st
order term
decreases faster than that of 2
nd
order term !
Since (r
e,h
)
2
= r
e,2h
, we have r
e,h
1 as the grid is refined. Hence,
convergence becomes asymptotically 2
nd
order (1
st
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


Grid-Refinement and Error estimation
We found that for a convergent scheme, the discretization error is of

c o O x A
p
)
= + | ( ) 0 = )
where R is the remainder
the form:
= ( + R
(recall: | | c , L ( ) 0 , = L
Ax
|
This discretization error can be estimated between solutions obtained
on systematically refined/coarsened grids
p
u u
Ax
+ | Ax = + R
-True solution u can be expressed either as:
u u = + | ' (2 Ax)
p
+ R '
2Ax
-Thus, the exponent p can be estimated:
2 4
2
log log 2
x x
x x
u u
p
u u
A A
A A
| |

~
|

\ .
(need two equations to eliminate both x and p, hence u
4x
)
u u
Ax 2Ax
-The discretization error on the grid x can be estimated by:
c
Ax
~
p
2 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

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
h
1
h
2
Richardson Extrapolation:
Consider:
2
2
2
Example
Assume:
)
For two different grid space h1 and h2:

From two O(h
2
),
we get an O(h
4
)!

2.29
Numerical Fluid Mechanics PFJL Lecture 14, 12
12


Rombergs Integration:
Iterative application of Richardsons extrapolation
Romberg Integration Algorithm, for any order k
h
I(h)
I
For Order 2 (case of previous slide):
h
2
h
1
k
1: O(h
2
) 2: O(h
4
) 3: O(h
6
) 4: O(h
8
)
a. 0.172800
1.068800
b. 0.172800
1.068800
1.484800
c. 0.172800 1.367467 1.640533 1.640533
j
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



Rombergs Differentiation:
Iterative application of Richardsons extrapolation
Romberg Differentiation Algorithm, for any order k
h
3
h
2
h
1
k
h
D(h)
D
D D
D
D
4D
2,1
D
1,1
For Order 2 (as previous slide, but for differentiation):
1: O(h
2
) 2: O(h
4
) 3: O(h
6
) 4: O(h
8
)
a. 0.172800
1.068800
b,. 0.172800
1.068800
1.484800
c. 0.172800 1.367467 1.640533 1.640533
j
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

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:
( ) = f
k
e
i kx
( f x

k integer, wavenumber)
k =
}
2t
i k x i mx
e e = 2to
km
(orthogonality property)
0
1
2t
Using the orthog. property,
i k x
x e dx
taking the integral/FT of f(x):
f =
}
f ( )
k
2t
0
Note: rate at which | f
k
| 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


Fourier (Error) Analysis:
Differentiations
Consider the decompositions:

i kx i kx
( ) = f
k
e or f x t = f
k
( ) t e f x

( , )

k = k =
n
c f n
i kx
Taking spatial derivatives gives:
n
=

f
k
( ) t
( )
ik e
c x
k =
r

r
k
i kx
Taking temporal derivatives gives:
c f
=

d f ( ) t
e
ct
r
k =
dt
r
Hence, in particular, for even or odd spatial derivatives:
q 2q
2q
( )
n
= k (real) n = ik ( 1)
q 2 1
n = 2q 1
( )
n
= i ( 1)
q
ik k (imaginary)
2.29
Numerical Fluid Mechanics PFJL Lecture 14, 16
16


Fourier (Error) Analysis:
Generic equation
c f c f
Consider the generic PDE: =
n
ct c x
n

x t ( ) t e
i kx
Fourier Analysis: f ( , ) =

f
k
k =

d f
k
( ) t

n
i kx i kx

f
k
( ) ik
Hence:

e = t
( )
e
k =
dt
k =
d f
k
( ) t n n
Thus:
=
( )
f ( ) = f
k
t for o ik ik
k
t o ( ) =
( )
dt

ot i kx +ot
And:
f t ( ) = f
k
(0) e , f (x t , ) =

f (0) e
k k
k =
Phase speed:
c = o / ik
2.29
Numerical Fluid Mechanics PFJL Lecture 14, 17
17



Fourier (Error) Analysis:
Generic equation
d f
k
( ) t n n
Generic PDE, FT:
= ik f
k
( ) t = o f
k
( ) t for o = ik
( ) ( )
dt
q 2q
2q ( )
n
= k (real) n = ik ( 1)
q 2 1
n = ( )
n
( 1)
q
2q 1 ik = i k (imaginary)
Hence:
c f c f
Propagation: c = o / ik = 1,
n = 1 = o = ik
ct c x No dispersion
c f c
2
f
2
n = 2 = o = k Decay
ct c x
2
c f c
3
f Propagation: c = o / ik = +k
2
,
n = 3 = o = ik
3
ct c x
3
With dispersion
c f c
4
f
n = 4 =
4
o = k
4
+: (Fast) Growth, : (Fast) Decay
ct c x
Etc
2.29
Numerical Fluid Mechanics PFJL Lecture 14, 18
18

MIT OpenCourseWare
http://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.

S-ar putea să vă placă și