Beruflich Dokumente
Kultur Dokumente
Grétar Tryggvason
Worcester Polytechnic Institute,
Spring 2009
1D Advection/diffusion equation
∂f ∂f ∂2 f
+U = D 2
∂t ∂x ∂x
Methods for the Forward in time/centered in space (FTCS)
f jn +1 − f jn f n − f j−1
n
f n − 2 f jn + f j−1
n
advection-diffusion € Δt
+ U j +1
2h
= D j +1
h 2
Stability limits
equation
UΔt
2D
≤1 &
DΔt 1
h2
≤
2
R=
UL
D
€
2D h2
Δt = & Δt =
U 2D
€
Δt → 0 For high and low D
€
€
∂f ∂f ∂2 f
+U = D 2
∂t ∂x ∂x
€
2D
≤1 &
h2
≤
2 The Cell Reynolds
UΔt DΔt
€
Upwind
O(Δt,h )
€
h
+ 2 2 ≤1
h number
UΔt 2 DΔt
L-W
O(Δt 2 ,h 2 ) ≤ 2 2 ≤ 1
h h
€ €
C-N
O(Δt ,h 2 )
2
Unconditionally stable
€ €
€
Computational Fluid Dynamics I
Computational Fluid Dynamics I
∂f ∂2f 0.9
U =D 2
∂x ∂x 0.8
RL=1 0.7
U RL=5
0.6
f =0 f =1 RL=10
0.5
RL=20
0.4
L
0.3
€
€Exact solution
€ 0.2
0.1
exp( RL x€
/ L) − 1 UL
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
f = RL =
exp( RL ) − 1 D
€ €
( R − 2) f j +1 + 4 f j − ( R + 2) f j −1 = 0 ( R − 2)q2 + 4q1 − ( R + 2 ) = 0
Solution
Solving for q gives two solutions:
j
fj = q 2+R
q1 = 1 and
q2 =
Substitute:
2− R
( R − 2)q j +1 + 4q j − ( R + 2)q j −1 = 0 The general solution is:
j j
j −1 f j = C1 q1 + C2 q2
Divide by
q
or
j
( R − 2)q2 + 4q1 − ( R + 2 ) = 0 2 + R
f j = C1 + C2
2 − R
Computational Fluid Dynamics I
Computational Fluid Dynamics I
Upwind
Apply the boundary conditions
f j − f j−1 f − 2 f j + f j−1
U = D j +1
2 + R
0
h h2
f 0 = C1 + C2 = C1 + C2 = 0 or
2 − R (R + 2) f j − (R + 1) f j−1 − f j +1 = 0 Uh
N R=
2 + R fj =qj D
f N = C1 + C2 =1 € Try solutions
2 − R
The final solution is:
€ giving
j q 2 − ( R + 2)q1 + ( R + 1) = 0
2 + R €
−1
f j = 2 − R N +1 Solution
j
2 + R 1− (1+ R)
−1 fj = N
2 − R € 1− (1+ R)
Upwind
Upwind
Exact
Exact
Centered
Centered
Computational Fluid Dynamics I
Computational Fluid Dynamics I
2D example
When centered differencing is used for the
advection/diffusion equation, oscillations may ∂ 2 f ∂ 2 f
∂f ∂f ∂f
appear when the Cell Reynolds number is +U + V = D 2 + 2
higher than 2. For upwinding, no oscillations ∂t ∂x ∂y ∂x ∂y
appear. In most cases the oscillations are
small and the cell Reynolds number is
f =0
frequently allowed to be higher than 2 with
relatively minor effects on the result.
€
Flow
Compuitations
f =1 using centered
Uh differences on a
R= <2 €
D 32 by 32 grid
f =0
€
€
€
Recell=3.2258 Recell=6.4516
D=0.02
D=0.01
t=1.5088
t=1.5088
Recell=12.9032
D=0.02
D=0.005
t=1.50
t=1.5088
Fine grid
Coarser grid
Recell=3.2258
Recell=6.6716
1.5
1.5
1
1
0.5
0.5
0
0
30
25 15
30
20 25 15
15 20 10
10 15 10
5 10 5
5 5
0 0
0 0
Computational Fluid Dynamics I
Computational Fluid Dynamics I
http://users.wpi.edu/~gretar/me612.html
Outline
Grétar Tryggvason
Worcester Polytechnic Institute,
2009
in space h h
Centered
∂f f j−2 − 8 f j−1 + 8 f j +1 − f j +2
= + O(h 4 )
∂x j 12h
∂ 2 f − f j−2 + 16 f j−1 − 30 f j + 16 f j +1 − f j +2
= + O(h 4 ) Compact schemes
∂x 2 j 12h 2
€
Skewed
∂f f j−2 − 6 f j−1 + 3 f j + 2 f j +1
= + O(h 3 )
€ ∂x j 6h
€
Computational Fluid Dynamics I
Computational Fluid Dynamics I
Solution of the vorticity-streamfunction equations
By a Taylor series expansion the following forth order
∂ 2ω ∂ 2ω relations between the values of f and the derivatives of
∂ω ∂ψ ∂ω ∂ψ ∂ω f can be derived
= − + ν 2 + 2
∂t ∂x ∂y ∂ y ∂x ∂x ∂x 3
∂ 2ψ ∂ 2ψ ( f x ) i+1, j + 4( f x ) i, j + ( f x ) i−1, j =
h
( f i+1, j − f i−1, j ) (1)
+ = −ω
∂x 2 ∂x 2 3
( f y )i, j +1 + 4( f y )i, j + ( f y )i, j−1 = h ( f i, j +1 − f i, j−1) (2)
€ Use “compact schemes” to find O(h4)
approximations for the spatial derivatives
12
€
( f xx ) i+1, j + 10( f xx ) i, j + ( f xx ) i−1, j =
h2
( f i+1, j − 2 f i, j + f i−1, j ) (3)
€
12
( f yy )i, j +1 + 10( f yy )i, j + ( f yy )i, j−1 = h 2 ( f i, j +1 − 2 f i, j + f i, j−1) (4)
The vorticity-streamfunction equations at grid point i,j are
1. Given the vorticity, ω, we solve tridiagonal
equations (1-4) for
ω x , ω y , ω xx , ω yy
∂ω ∂ψ ∂ω ∂ψ ∂ω
= − 2. For ψ use (3) and (4) plus the elliptic equation
∂t i, j ∂x i, j ∂y i, j ∂y i, j ∂x i, j
for the streamfunction (6) for
ψ xx , ψ yy , ψ
∂ 2ω ∂ 2ω
+ ν 2 + 2 (5)
3. Then €
use 1 and 2 for (tridiagonal systems)
ψ x , ψ y
∂x i, j ∂x i, j
∂ 2ψ ∂ 2ψ 4. Everything on the right hand side of (5) is now
€
2 + 2 = −ω i, j known to O(h4) accuracy and
∂x i, j ∂y i, j (6)
€ ∂ψ €
To find the time derivative, we need
∂t
can be found
€ ψ x , ψ y , ψ xx , ψ yy , ω x , ω y , ω xx , ω yy
Quadratic interpolation:
∂f 2 1 2 2
€ 1-3: Add the above:
€ ≈ { f i+1/ 2 − f i−1/ 2 }
∂x i h
€ 0.5 ( 3− s)[( 2 − s) f1 + ( s − 1) f 2 ] + 0.5( s − 1)[( 3− s) f 2 + ( s − 2) f 3 ]
1 2 2
At s = 5/2
=
64h
{
[3 f i+1 + 6 f i − f i−1 ] − [3 f i + 6 f i−1 − f i− 2 ] }
f 5 / 2 = (1/8)[ 3 f 3 + 6 f 2 − f1]
€
€
€
∂f 1 ∂f 2 ∂2 f
+ =D 2
∂t 2 ∂x ∂x
∂f 1 ∂f 2 ∂2 f
+ =D 2 10
∂t 2 ∂x ∂x 10
9
Centered
9
8
8
€ QUICK
7
7
6
Upwind
6
€ 5 5
4 4
Centered
3 3
QUICK 2 2
Upwind 1 1
0 0
0 5 10 15 20 25 30 35 40 0 5 10 15 20 25 30 35 40
Re_cell=10 Re_cell=20
Therefore:
d 1 1 ∂f 3 The kinetic
€
dt
∫2f 2
dx = − ∫
3 ∂x
dx = 0 energy is
conserved
€
Computational Fluid Dynamics I
Computational Fluid Dynamics I
€ dt 2 ∂x j
Is f2 conserved?
= … + f j−1
2
( f j − f j−2 ) + f j2 ( f j +1 − f j−1) + … ≠ 0
€
€
€
€
€
Computational Fluid Dynamics I
Computational Fluid Dynamics I
1 1
J1i, j =
3
(Ji, j + Ji,2 j + Ji,3 j ) Higher order
Conserves both the vorticity and the kinetic energy
in time for the vorticity-
€
Arakawa also presented a fourth order scheme with streamfunction
the same properties
formulation
Leapfrog
ω i,n +1 n−1
j − ω i, j
Due to the relatively straightforward coupling = −J i,n j + ν∇ 2hω i,n−1
j
2Δt
between the elliptic equation for the
streamfunction and the vorticity advection- Adams-Bashford/Crank-Nicholson
diffusion equation, the algorithms discussed ω i,n +1 n
j − ω i, j 1 ν 2 n +1
already can be used with ease.
= − ( 3J i,n j − J i,n−1
j )+ (∇ hω i, j + ∇ 2hω i,n j )
€ Δt 2 2
Predictor-corrector
ω˜ i, j − ω i,n j
= −J i,n j + ν∇ 2hω i,n j
€ Δt
ω i,n +1
j −ω ˜ i, j 1 ν
= − ( J i,n j + J˜i, j ) + (∇ 2hω i,n j + ∇ 2hω˜ i, j )
Δt 2 2
€
€
Computational Fluid Dynamics I
Computational Fluid Dynamics I
Runge Kutta methods: take intermidiate steps 4th order Runge-Kutta method
∇ 2hψ˜ i,n +1 ˜ n +1
j = −ω i, j Generating higher order methods for the
Navier-Stokes equations in the corticity/
Δt
ω i,n +1 n
j = ω i, j + (
−J i,n j − 2 J˜i,n +1/
j
2
− 2 J˜˜i,n +1/
j
2
− J˜i,n +1
j
streamfunction form is relatively straight
6 forward and any method developed for the
€ 2 ˜ n +1/ 2 advection diffusion equation can be used
+ ν∇ hω i, j + 2ν∇ hω˜ i, j + 2ν∇ hω˜ i, j + ν∇ 2hω˜ i,n +1 j )
2 n 2 n +1/ 2
without much difficulty
corrected
final value
€
t t + Δt /2 t + Δt
€ € €