Beruflich Dokumente
Kultur Dokumente
Grétar Tryggvason!
Spring 2010!
!
equation, replacing a relation between the derivatives by
a relation between the discrete nodal values.
The!
Δt
f (t + 2Δt) Time Derivative!
f (t + Δt)
Δt
f(t,x-h) f(t,x) f(t,x+h) !
f (t)
h
h
Computational Fluid Dynamics I
Computational Fluid Dynamics I
Finite Difference Approximations! Finite Difference Approximations!
Time derivative!
The Time Derivative is found using a FORWARD
Δt
f(t,x)! ∂f (t) f (t + Δt) − f (t) ∂ 2 f (t) Δt
= − +
h
h
∂t Δt ∂t 2 2
And using the approximation just derived for the partial differential
time derivative results in:!
f n+1 − f n
= g n + O(Δt)
equation!
Δt
which is exactly the first order forward Euler method. !
First Derivative! h
h
∂f 2 (x) h 2 ∂ 4 f (x) h 4
f (x + h) + f (x − h) = 2 f (x) + 2 +2 +
∂x 2
2 ∂x 4 24
Computational Fluid Dynamics I
Computational Fluid Dynamics I
Finite Difference Approximations! Finite Difference Approximations!
∂f 2 (x) h 2 ∂ 4 f (x) h 4
f (x + h) + f (x − h) = 2 f (x) + 2 +2 +
∂x 2
2 ∂x 4 24 Solving the partial
Rearranging this equation to isolate the second derivative:!
differential equation!
∂ 2 f (x) f (x + h) − 2 f (x) + f (x − h) ∂ 4 f (x) h 2
= − +
∂x 2 h2 ∂x 4 12
f jn−1 f jn f jn+1 Δt +U = D⎜ 2
f jn+1 = f (t, x j + h) ⎝ ∂t ⎠ j ⎝ ∂x ⎠ j ⎝ ∂x ⎠ j
f jn−1 = f (t, x j − h)
h
h
f jn+1
f jn−1 f jn f jn+1 Δt
h
h
⎝ ∂x 2 ⎠ j Solving for the new value and dropping the error terms yields!
h2
UΔt n DΔt
f jn+1 = f jn − ( f j +1 − f jn−1) + 2 ( f jn+1 − 2 f jn + f jn−1)
2h h
Computational Fluid Dynamics I
Computational Fluid Dynamics I
Finite Difference Approximations!
UΔt n DΔt
f jn+1 = f jn − ( f − f jn−1) + 2 ( f jn+1 − 2 f jn + f jn−1)
2h j +1 h Example!
The value of every point at level n+1 is given
explicitly in terms of the values at the level n!
f jn+1
f jn−1 f jn f jn+1 Δt
h
h
Evolution
for!
U=1;
Finite difference approximations by Taylor
D=0.05;
expansion!
k=1
Movie: adv1!
Exact!
Numerical!
Computational Fluid Dynamics I
Computational Fluid Dynamics I
http://users.wpi.edu/~gretar/me612.html! Outline!
Grétar Tryggvason!
Spring 2010!
Evolution
for!
U=1;
D=0.05;
k=1
Movie: adv1!
Accuracy!
N=21
Δt=0.05
Exact!
Numerical!
-0.5
Numerical! -2
2 4 6 8 10 12 14 16 18 20
Computational Fluid Dynamics I
Computational Fluid Dynamics I
Accuracy! Accuracy!
Δt=0.025
1.5
Δt=0.0125
1.5
1 1
N=21
N=21
0.5 0.5
0 0
-0.5 -0.5
-1 -1
Exact! Exact!
-1.5 -1.5
Numerical! -2
Numerical! -2
2 4 6 8 10 12 14 16 18 20 2 4 6 8 10 12 14 16 18 20
Δt = 0.0005 ! k=1
1
and ! 0.5
N=200! N=200
0
Δt=0.0005
-0.5
-1
Exact!
-1.5
Numerical! -2
20 40 60 80 100 120 140 160 180 200
1/ h
Why is does the error deviate from the line for the
highest values of N?!
Showed, by numerical experiments, that
accuracy increases as the resolution is
Truncation! increased!
Error!
Roundoff!
Grétar Tryggvason!
Spring 2010!
Evolution
As long as accuracy is reasonable, integration at for!
larger time steps is more efficient and desirable. ! U=1;
D=0.05;
Can we increase the time step indefinitely?! k=1
Letʼs repeat the 1-D advection-diffusion equation N=21
with larges time step.! Δt=0.2
Use Δt = 0.2, instead of Δt = 0.05!
Exact!
Numerical!
dt Δt=0.5!
2
1
The exact solution is!
Δt=1.5! 0
f (t ) = e −t Δt=2.5! -1
-2
Forward Euler! -3
-4
f n+1
= f − f Δt
n n
f n+1
= (1 − Δt) f n
-5
0 5 10 15 20
n +1 n +1
f f
≤1 only if! Δt ≤ 2 ≤1 only if! Δt ≤ 2
fn fn
However!
f n +1 = (1− Δt) f n = (1− Δt) 2 f n−1
= ………… = (1− Δt) n f 1
Obviously, f oscillates unless! Δt ≤ 1 Stability Analysis of the!
Advection-Diffusion Equation:!
Backward Euler! Von Neumann Method!
f n +1 1
f n+1 = f n − f n+1 Δt =
fn (1+ Δt)
f n +1
≤1 for all Δt
fn
The evolution of the perturbation is governed by:! The error at node j is:!
ikx j
n +1 ε nj = ε n e
ε j −ε n
j ε n
j +1 −ε n
j −1 ε n
j +1 − 2ε + ε
n
j
n
j −1
+U =D
Δt h2
2h The error at j+1 and j -1 can be written as!
ikx j +1 ik (x j + h) ikx j ikh
Write the error as a wave (expand as a Fourier series):! ε nj +1 = ε n e = εne = εne e
∞
ε nj = ε n ( x j ) = ∑ε
k = −∞
n ikx j
ke ε nj −1 = ε n e
ikx j −1 ik (x j −h)
= ε ne = ε ne
ikx j
e −ikh
Δt 2h h2
yields! Solving for the ratio of the errors:!
ε n+1e − ε ne εn
ikx j ikx j
+ U (eikhe ikx j − e− ikheikx j ) =
Δt 2h ε n +1 UΔt ikh −ikh DΔt ikh
= 1− (e − e ) + 2 (e − 2 + e −ikh )
εn εn 2h h
D 2 (e ikheikx j − 2e ikx j + e − ikhe ikx j )
h
Dividing by the error amplitude at n:! The ratio of the error amplitude at n+1 and n is:!
amplification factor! ε n +1 DΔt h UΔt
= 1− 4 2 sin 2 k − i sin kh
ε n +1
UΔt ikh −ikh DΔt ikh εn h 2 h
= 1− (e − e ) + 2 (e − 2 + e −ikh )
εn 2h h Stability requires that!
(a) Consider first the case when U = 0, so the problem (b) Consider now the other limit where D = 0 and
reduces to a pure diffusion! we have a pure advection problem.!
ε n+1 DΔt h ε n +1 UΔt
= 1− 4 2 sin2 k = 1− i sin kh
εn h 2 εn h
2
Since sin () ≤ 1 the amplification factor is always ε n+1
Since the amplification
less than 1, and we find that it is bigger than -1 if!
factor has the form 1+i() εn
DΔt the absolute value of this
−1≤ 1− 4 ≤1
h2 complex number is always UΔt
larger than unity and the i sin kh
DΔt 1 method is unconditionally h
2 ≤
h 2 unstable for this case.!
1
ΔtD 1 U 2 Δt DΔt 1 (| U | + | V |) 2 Δt
≤ and! ≤2 ≤ and! ≤4
h2 2 D h2 4 D
Notice that high velocity and low viscosity lead to For a three-dimensional problem we get:!
instability according to the second restriction.!
DΔt 1 (|U | + |V | + |W |) 2 Δt
≤ and! ≤8
h2 6 D