computational fluid numerical methods for dynamics...
TRANSCRIPT
Computational Fluid Dynamics
Computational Fluid Dynamics
http://www.nd.edu/~gtryggva/CFD-Course/
Grétar Tryggvason
Lecture 12March 6, 2017
Computational Fluid Dynamics
Numerical Methods forParabolic Equations
http://www.nd.edu/~gtryggva/CFD-Course/
Computational Fluid Dynamics
One-Dimensional Problems• Explicit, implicit, Crank-Nicolson• Accuracy, stability• Various schemes
Multi-Dimensional Problems• Alternating Direction Implicit (ADI)• Approximate Factorization of Crank-Nicolson
Splitting
Outline
Solution Methods for Parabolic Equations
Computational Fluid Dynamics
Numerical Methods forOne-Dimensional Heat
Equations
Computational Fluid Dynamics
bxatxf
tf <<>
∂∂=
∂∂ ,0;
2
2
α
which is a parabolic equation requiring
)()0,( 0 xfxf =
Consider the diffusion equation
Initial Condition
)(),();(),( ttbfttaf ba φφ == Boundary Condition(Dirichlet)
)(),();(),( ttbxf
ttaxf
ba ϕϕ =∂∂=
∂∂ Boundary Condition
(Neumann)
or
and
Computational Fluid Dynamics
Parabolic equations can be viewed as the limit of a hyperbolic equation with two characteristics as the signal speed goes to infinity
Increasing signal speed
x
t
Computational Fluid Dynamics
211
1 2h
ffftff n
jnj
nj
nj
nj −++ +−
=Δ−
α
Explicit: FTCS
f jn+1 = f j
n +αΔth2
f j+1n − 2 f j
n + f j−1n( )
j-1 j j+1n
n+1
Explicit Method: FTCS - 1
∂ 2 f∂x2
⎞
⎠⎟ j
n
=f j+1
n − 2 f jn + f j−1
n
h2
∂ f∂t
⎞⎠⎟ j
n
=f j
n+1 − f jn
Δt
∂f∂t
⎛⎝⎜
⎞⎠⎟ j
n
= α ∂2 f∂x2
⎛
⎝⎜⎞
⎠⎟ j
n
Computational Fluid Dynamics
Modified Equation
xxxxxxxxxx fhthtOfrhxf
tf ),,()61(
12422
2
2
2
ΔΔ+−=∂∂−
∂∂ αα
2htr Δ= αwhere
- Accuracy ),( 2htO Δ
- No odd derivatives; dissipative
Explicit Method: FTCS - 2
Computational Fluid Dynamics
Stability: von Neumann Analysis
14112<Δ−<−
htα
210
2<Δ≤
htα
Fourier Condition
ε n+1
ε n= 1− 4αΔt
h2sin2 k h
2G = 1− 4r sin2 (β / 2)⎡⎣ ⎤⎦
Explicit Method: FTCS - 3
β = khwhere
Computational Fluid Dynamics
Domain of Dependence for Explicit Scheme
BC
x
t
Initial Data
BCh
P Δt
In the limit of Δt and Δx going to zero, the computational domain contains the physical domain of dependence since Δt ~ Δx2 for stability
Explicit Method: FTCS - 4
Boundary effect is not felt at P for many time steps
This may result in unphysical solution behavior
Computational Fluid Dynamics
Implicit Method for the One-Dimensional Heat
Equation
Computational Fluid Dynamics
2
11
111
1 2h
ffftff n
jnj
nj
nj
nj
+−
+++
+ +−=
Δ−
α
Implicit Method: Backward Euler
j-1 j j+1n
n+1Tri-diagonal matrix system
Implicit Method
fin+1 − fi
n =αΔth2
fi+1n+1 − 2 fi
n+1 + fi−1n+1( )
�
a j−1 f j−1 − d j f j + c j+1 f j+1 = bj
rfi+1n+1 − 1+ 2r( ) fin+1 + rfi−1n+1 = − fin r = αΔt
h2
Computational Fluid Dynamics
aj f j−1 − dj f j + cj f j+1 = bj
�
d1 f1 + c1 f2 = b1a2 f1 + d2 f2 + c2 f3 = b2
aN−1 fN−2 + dN−1 fN−1 + cN−1 fN = bN−1
aN fN−1 + dN fN = bN
�
b1 = −a1 f0bN = −cN fN +1
Write out
If the endpoints are given
Implicit MethodComputational Fluid Dynamics
Gaussian Elimination- Pivoting: rearranging equations to put the largest coefficient on the main diagonal.- Eliminate the column below main diagonal.- Repeat until the last equation is reached.- Back-substitution
- Special case: tri-diagonal matrix - Thomas algorithm
nnn cfafa
cfafacfafa
=++
=++=++
2211
2222121
1212111
nnnn cfa
cfacfafa
=′
=+′=++
2222
1212111
è
Implicit Method
Computational Fluid Dynamics
% solving a tridiagonal system nx=50;r=0.1; a=zeros(nx,1)+(1+r);d=zeros(nx,1)-2;c=zeros(nx,1)+(1-r); b=zeros(nx,1); x=zeros(nx,1); b(nx)=-(1-r); % forward elimination for j=2:nx d(j)=d(j)-(a(j)/d(j-1))*c(j-1); b(j)=b(j)-(a(j)/d(j-1))*b(j-1); x(j)=b(j)/d(j); end % backward substitution for j=nx-1:-1:1 x(j)=(b(j)-c(j)*x(j+1))/d(j); end plot(x)
Implicit MethodComputational Fluid Dynamics
Matlab functions
For simple problems MATLAB has a number of functions to deal with matrices.
Help matfun: generalHelp sparfun:sparse matrices
Implicit Method
Computational Fluid Dynamics
- The + sign suggests that implicit method may be less accurate than a carefully implemented explicit method.
Modified Equation∂f∂t
−α ∂2 f∂x2
=αh2
12(1+ 6r) fxxxx +O(Δt
2 ,h2Δt,h4 ) fxxxxxx
Amplification Factor (von Neumann analysis)
G = 1+ 2r(1− cosβ)[ ]−1
Unconditionally stable
Implicit MethodComputational Fluid Dynamics
⎟⎟⎠
⎞⎜⎜⎝
⎛ +−+
+−=
Δ− −+
+−
+++
+
211
2
11
111
1 222 h
fffh
ffftff n
jnj
nj
nj
nj
nj
nj
nj α
Crank-Nicolson Method (1947)
j-1 j j+1n
n+1
Tri-diagonal matrix system
−rf j+1n+1 + 2 r +1( ) f jn+1 − rf j−1n+1 = rf j+1n − 2 r −1( ) f jn + rf j−1n
Crank-Nicolson - 1
Computational Fluid Dynamics
- Second-order accuracy
Modified Equation
xxxxxxxxxx fhtfh
xf
tf
⎥⎦⎤
⎢⎣⎡ +Δ+=
∂∂−
∂∂ 423
2
2
2
3601
121
12αααα
Crank-Nicolson - 2
Amplification Factor (von Neumann analysis)
( )( )β
βcos11cos11
−+−−=
rrG
Unconditionally stable
),( 22 htO Δ
Computational Fluid Dynamics
⎟⎟⎠
⎞⎜⎜⎝
⎛ +−−+
+−=
Δ− −+
+−
+++
+
211
2
11
111
1 2)1(
2h
fffh
ffftff n
jnj
nj
nj
nj
nj
nj
nj θθα
Generalization
j-1 j j+1n
n+1
⎪⎩
⎪⎨⎧
−=
NicolsonCrank1/2Implicit1
(FTCS)Explicit0θ
θ×( )θ−× 1
Combined Method A - 1
Computational Fluid Dynamics
( )2
11
111
11 21
hfff
tff
tff n
jnj
nj
nj
nj
nj
nj
+−
+++
−+ +−=
Δ−
−Δ−
+ αθθ
Generalized Three-Time-Level Implicit Scheme:Richtmyer and Morton (1967)
j-1 j j+1
n
n+1
⎩⎨⎧
=implicitfully level-Three1/2
Implicit0θ
( )θ+× 1θ×
n-1
Combined Method B - 1Computational Fluid Dynamics
Modified Equation:
Combined Method B - 2
+Δ+⎥⎦⎤
⎢⎣⎡ +Δ⎟
⎠⎞⎜
⎝⎛ −−=− )(
1221 2
22 tOfhtff xxxxxxt
ααθα
Special Cases:
),(21 22 htO Δ⇒=θ
r121
21 +=θ ),( 42 htO Δ⇒
Computational Fluid Dynamics
211
11 22 h
ffftff n
jnj
nj
nj
nj −+
−+ +−=
Δ−
α
Richardson’s Method
Richardson Method
),( 22 htO Δ
Similar to Leapfrog
but unconditionally unstable!
j-1 j j+1
n
n+1
n-1
Computational Fluid Dynamics
21
111
11
2 hffff
tff n
jnj
nj
nj
nj
nj −
−++
−+ +−−=
Δ−
α
The Richardson method can be made stable by splitting by time average
j-1 j j+1
n
n+1
DuFort-Frankel - 1
n-1
njf f j
n+1 + f jn−1( ) / 2
( ) ( )nj
nj
nj
nj
nj fffrfrf 1
11
11 221 −−
+−+ +−+=+
Computational Fluid Dynamics
xxxxxxt fht
hff ⎥⎦⎤
⎢⎣⎡ Δ−=−
2
232
121 ααα
Modified Equation
DuFort-Frankel - 2
xxxxxxfht
th ⎥⎦⎤
⎢⎣⎡ Δ+Δ−+
4
45234 2
31
3601 ααα
Amplification factor
rrr
G21
sin41cos2 22
+−±
=ββ Unconditionally
stable
Conditionally consistent
Computational Fluid Dynamics
FTCSStable for
BTCSUnconditionally
Stable
Crank-NicolsonUnconditionally
Stable
RichardsonUnconditionally
Unstable
xxt ff α=
211
1 2h
ffftff n
jnj
nj
nj
nj −++ +−
=Δ−
α ( ) xxxxfrh 6112
2
−α
Parabolic Equation – Elementary Schemes
21≤r
2
11
111
1 2h
ffftff n
jnj
nj
nj
nj
+−
+++
+ +−=
Δ−
α ( ) xxxxfrh 6112
2
+α
f jn+1 − f j
n
Δt=
α2h2
f j+1n+1 − 2 f j
n+1 + f j−1n+1( )⎡⎣
+ f j+1n − 2 f j
n + f j−1n( )⎤⎦
xxxxxxxxxx ft
fh
1212
232 Δ+αα
211
11 22 h
ffftff n
jnj
nj
nj
nj −+
−+ +−=
Δ−
α ),( 22 htO Δ
Computational Fluid Dynamics
DuFort-Frankel UnconditionallyStable,
ConditionallyConsistent
3-Level ImplicitUnconditionally
Stable
xxt ff α=
( ) xxxxfrh 22
12112
−α
2
11
111
11
2243
hfff
tfff
nj
nj
nj
nj
nj
nj
+−
+++
−+
+−
=Δ
+−
αxxxxf
h12
2α
21
111
11
2 hffff
tff n
jnj
nj
nj
nj
nj −
−++
−+ +−−=
Δ−
α
And others!
Parabolic Equation – Elementary SchemesComputational Fluid Dynamics
Numerical Methods forMulti-Dimensional Heat
Equations
Computational Fluid Dynamics
Two-dimensional grid
j
j-1
j+1
i i+1i-1
⎟⎟⎠
⎞⎜⎜⎝
⎛∂∂+
∂∂=
∂∂
2
2
2
2
yf
xf
tf α
Consider a 2-D heat equation
Computational Fluid Dynamics
⎟⎟⎠
⎞⎜⎜⎝
⎛∂∂+
∂∂=
∂∂
2
2
2
2
yf
xf
tf α
Applying forward Euler scheme:
⎟⎟⎠
⎞⎜⎜⎝
⎛Δ
+−+
Δ+−
=Δ− −+−+
+
21,,1,
2,1,,1,
1, 22
yfff
xfff
tff n
jinji
nji
nji
nji
nji
nji
nji α
2-D heat equation
hyx =Δ=ΔIf
( )njinji
nji
nji
nji
nji
nji fffff
htff
,1,1,,1,12,
1, 4−+++=Δ−
−+−+
+ α
Explicit Method - 1
Computational Fluid Dynamics
In matrix form
f1,1n+1
f1,2n+1
f1,J
n+1
f2,1n+1
f2,2n+1
fI ,J −1n+1
fI ,Jn+1
⎡
⎣
⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥
=
f1,1n
f1,2n
f1,J
n
f2,1n
f2,2n
fI ,J −1n
fI ,Jn
⎡
⎣
⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥
+αΔth2
−4 1 0 0 1 0 1 −4 1 0 0 1 0 1 −4 1 0 1 1 00 10 0 1
0 1 −4
⎡
⎣
⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥
f1,1n
f1,2n
f1,J
n
f2,1n
f2,2n
fI ,J −1n
fI ,Jn
⎡
⎣
⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥
Explicit Method - 2Computational Fluid Dynamics
Explicit Method - 3
Von Neumann Analysis imyikxnnj eeεε =
�
εn+1 = εn + αΔth2
eikh + e− ikh + eimh + e−imh − 4( )εn
�
εn+1
εn=1+ αΔt
h22coskh + 2cosmh − 4( )
⎟⎠⎞⎜
⎝⎛ +Δ−=
2sin
2sin41 22
2
mhkhhtα
Worst case
1811 2 ≤Δ−≤−htα
41
2 ≤Δhtα
Computational Fluid Dynamics
Δtαh2
=12
Δtαh2
=14
�
Δtαh2
= 16
One-dimensional flow
Two-dimensional flow
Three-dimensional flow
Stability limits depend on the dimension of the problems
Different numerical algorithms usually have different stability limits
StabilityComputational Fluid Dynamics
Implicit time integration
Computational Fluid Dynamics
f
i , j
n+1 = fi , j
n +Δtαh2
⎛⎝⎜
⎞⎠⎟
fi+1, jn + fi−1, j
n + fi, j−1n + fi, j+1
n − 4 fi, jn( )
Implicit Methods
f
i , j
n+1 = fi , j
n +Δtαh2
⎛⎝⎜
⎞⎠⎟
fi+1, jn+1 + fi−1, j
n+1 + fi, j−1n+1 + fi, j+1
n+1 − 4 fi, jn+1( )
Evaluate the spatial derivatives at the new time (n+1), instead of at n
(1+ 4A) f
i , j
n+1 − A fi+1, jn+1 + fi−1, j
n+1 + fi, j−1n+1 + fi, j+1
n+1( ) = fi , j
n
This gives a set of linear equations for the new temperatures:
Known source term
Recall forward in time method
Computational Fluid Dynamics
�
fi , j
n+1 = 11+ 4A
A fi+1, jn+1 + f i−1, j
n+1 + f i, j−1n+1 + f i, j+1
n+1( ) + fi , j
n( )
Isolate the new fi,j and solve by iteration
The implicit method is unconditionally stable, but it is necessary to solve a system of linear equations at each time step. Often, the time step must be taken to be small due to accuracy requirements and an explicit method is competitive.
Implicit Methods
Computational Fluid Dynamics
Second order accuracy in time can be obtained by using the Crank-Nicolson method
n
n+1
i i+1
i-1
j+1
j-1
j
Implicit MethodsComputational Fluid Dynamics
The matrix equation is expensive to solve
Crank-Nicolson
Crank-Nicolson Method for 2-D Heat Equation
⎟⎟⎠
⎞⎜⎜⎝
⎛∂∂+
∂∂+
∂∂+
∂∂=
Δ− +++
2
2
2
2
2
12
2
121
2 yf
xf
yf
xf
tff nnnnnn α
( )1,11,
11,
1,1
1,12,
1, 4
2++
−++
+−
++
+ −+++Δ+= nji
nji
nji
nji
nji
nji
nji fffff
htff α
hyx =Δ=ΔIf
( )njinji
nji
nji
nji fffff
ht
,1,1,,1,12 42
−+++Δ+ −+−+α
Computational Fluid Dynamics
Expensive to solve matrix equations.
Can larger time-step be achieved without having solve the matrix equation resulting from the two-dimensional system?
The break through came with the Alternation-Direction-Implicit (ADI) method (Peaceman & Rachford-mid1950’s)
ADI consists of first treating one row implicitly with backward Euler and then reversing roles and treating the other by backwards Euler.
Peaceman, D., and Rachford, M. (1955). The numerical solution of parabolic and elliptic differential equations, J. SIAM 3, 28-41
Computational Fluid Dynamics
The ADI Method
Computational Fluid Dynamics
Fractional Step:
Alternating Direction Implicit (ADI)
�
f n+1/ 2 − f n = αΔt2h2
fi+1, jn+1/ 2 − 2 f i, j
n+1/ 2 + f i−1, jn+1/ 2( ) + f i, j+1
n − 2 f i, jn + f i, j−1
n( )[ ]
( )hyx =Δ=Δ
�
f n+1 − f n+1/ 2 = αΔt2h2
fi+1, jn+1/ 2 − 2 f i, j
n+1/ 2 + f i−1, jn+1/ 2( ) + f i, j+1
n+1 − 2 f i, jn+1 + f i, j−1
n+1( )[ ]
Step 1:
Step 2:
⎥⎦
⎤⎢⎣
⎡⎟⎟⎠
⎞⎜⎜⎝
⎛∂∂+
∂∂+
∂∂Δ=−
+++
2
2
2
12
2
2/121
21
2 yf
yf
xft
ffnnn
nn α
Combining the two becomes equivalent to:
Midpoint Trapisodial
Computational Fluid Dynamics
Computational Molecules for the ADI Method
n
n+1/2
n+1
i i+1
i-1
j+1
j-1
j
Computational Fluid Dynamics
Instead of solving one set of linear equations for the two-dimensional system, solve 1D equations for each grid line.
The directions can be alternated to prevent any bias
Computational Fluid Dynamics
In matrix form, for each row
fi,1n+1/ 2
fi,2n+1/ 2
fi,N
n+1/ 2
⎡
⎣
⎢⎢⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥⎥⎥
=
fi,1n
fi,2n
fi,N
n
⎡
⎣
⎢⎢⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥⎥⎥
+αΔth2
−2 1 01 −2 10 1 −2
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
fi,1n+1/ 2
fi,2n+1/ 2
fi,N
n+1/ 2
⎡
⎣
⎢⎢⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥⎥⎥
+ source
This equation is easily solved by forward elimination and back-substitution
Computational Fluid Dynamics
Stability Analysis:
ADI Method is accurate
Similarly,
( )22 ,htO Δimyikxnn
j eeεε =
ε n+1/2 = ε n + αΔth2
ε n+1/2 eikh − 2 + e− ikh( ) + ε n eimh − 2 + e− imh( )⎡⎣ ⎤⎦
ε n+1/2
ε n=1− 2αΔt
h2sin2 kh
21+ 2αΔt
h2sin2 mh
2
ε n+1
ε n+1/2=1− 2αΔt
h2sin2 mh
21+ 2αΔt
h2sin2 kh
2
Computational Fluid Dynamics
Combining
Unconditionally stable!
1
2sin21
2sin21
2sin21
2sin21
22
22
22
221
<⎟⎟⎟⎟
⎠
⎞
⎜⎜⎜⎜
⎝
⎛
Δ+
Δ−
⎟⎟⎟⎟
⎠
⎞
⎜⎜⎜⎜
⎝
⎛
Δ+
Δ−=
+
khht
mhht
mhht
khht
n
n
α
α
α
α
εε
The 3-D version does not have the same desirable stability properties. However, it is possible to generate similar methods for 3D problems
Computational Fluid Dynamics
Implicit methods for parabolic equations• Allow much larger time step (but must be
balanced against accuracy!)• Preserve the parabolic nature of the equation
But, require the solution of a linear set of equations and are therefore much more expensive that explicit methods
ADI provides a way to convert multidimensional problems into a series of 1D problems
Computational Fluid Dynamics
Approximate factorization
Splitting
Computational Fluid DynamicsApproximate Factorization - 1
The Crank-Nicolson for heat equation becomes
Define δ xx ( ) = 1Δx2
( )i−1, j − 2( )i, j + ( )i+1, j⎡⎣ ⎤⎦
δ yy ( ) = 1Δy2
( )i, j−1 − 2( )i, j + ( )i, j+1⎡⎣ ⎤⎦
f n+1 − f n
Δt=α2δ xx f n+1 + f n( ) + α
2δ yy f n+1 + f n( ) +O(Δt 2 ,Δx2 ,Δy2 )
1− αΔt2
δ xx −αΔt2
δ yy⎛⎝⎜
⎞⎠⎟f n+1 = 1+ αΔt
2δ xx +
αΔt2
δ yy⎛⎝⎜
⎞⎠⎟f n
+ΔtO(Δt 2 ,Δx2 ,Δy2 )
which can be rewritten as
Computational Fluid DynamicsApproximate Factorization - 2
Factoring each side
+ΔtO(Δt 2 ,Δx2 ,Δy2 )
1− αΔt2
δ xx⎛⎝⎜
⎞⎠⎟1− αΔt
2δ yy
⎛⎝⎜
⎞⎠⎟f n+1 −
α 2Δt 2
4δ xxδ yy f
n+1 =
or
1+ αΔt2
δ xx⎛⎝⎜
⎞⎠⎟1+ αΔt
2δ yy
⎛⎝⎜
⎞⎠⎟f n −
α 2Δt 2
4δ xxδ yy f
n
1− αΔt2
δ xx⎛⎝⎜
⎞⎠⎟1− αΔt
2δ yy
⎛⎝⎜
⎞⎠⎟f n+1 = 1+ αΔt
2δ xx
⎛⎝⎜
⎞⎠⎟1+ αΔt
2δ yy
⎛⎝⎜
⎞⎠⎟f n
+α 2Δt 2
4δ xxδ yy f n+1 − f n( ) + ΔtO(Δt 2 ,Δx2 ,Δy2 )
Crank-Nicolson
Computational Fluid DynamicsApproximate Factorization - 3
The ADI method can be written as
1− αΔt2
δ xx⎛⎝⎜
⎞⎠⎟f n+1/2 = 1+ αΔt
2δ yy
⎛⎝⎜
⎞⎠⎟f n
1− αΔt2
δ yy⎛⎝⎜
⎞⎠⎟f n+1 = 1+ αΔt
2δ xx
⎛⎝⎜
⎞⎠⎟f n+1/2
Eliminating fn+1/2
1− αΔt2
δ yy⎛⎝⎜
⎞⎠⎟1− αΔt
2δ xx
⎛⎝⎜
⎞⎠⎟f n+1 = 1+ αΔt
2δ yy
⎛⎝⎜
⎞⎠⎟1+ αΔt
2δ xx
⎛⎝⎜
⎞⎠⎟f n+1
Computational Fluid Dynamics
�
αΔt2
⎛ ⎝ ⎜
⎞ ⎠ ⎟ 2
δyyδxx f n+1 − f n( ) ≈ α2
⎛ ⎝ ⎜
⎞ ⎠ ⎟ 2
Δt 3δxxδyy∂f∂t
= O(Δt 3)
Up to a factor:
ADI is an approximate factorization of the Crank-Nicolson method
Approximate Factorization - 4
Computational Fluid Dynamics
The Peaceman-Rachford methods does not have the same stability properties in 3D as in 2D. A method with similar properties is:
1− αΔt2
δ xx⎛⎝⎜
⎞⎠⎟f n+1* = 1+ αΔt
2δ xx + 2δ yy + 2δ zz( )⎡
⎣⎢⎤⎦⎥f n
1− αΔt2
δ yy⎛⎝⎜
⎞⎠⎟f n+1** = f n+1* − αΔt
2δ yy f
n
1− αΔt2
δ zz⎛⎝⎜
⎞⎠⎟f n+1 = f n+1** − αΔt
2δ zz f
n
Several other splitting methods have been proposed in the literature.
Approximate Factorization - 5Computational Fluid Dynamics
Similar ideas can be used for time splitting:
fi, jn+1/2 = 1+αΔtδ xx( ) fi, jn
fi, jn+1 = 1+αΔtδ yy( ) fi, jn+1/2
fi, jn+1 = 1+αΔtδ yy( ) 1+αΔtδ xx( ) fi, jn
Eliminate the half step:
Which is equivalent to the standard FTCS method, except for the
α 2Δt 2δ yyδ xx fi, jn
term, which is higher order.
Approximate Factorization - 6
Computational Fluid Dynamics
Why splitting?
1. Stability limits of 1-D case apply.
2. Different Δt can be used in x and y directions.
Computational Fluid Dynamics
Implicit time marching by fast
elliptic solvers
Computational Fluid Dynamics
fi, jn+1 − fi, j
n
Δt= α∇h
2 fi, jn+1
∇h2 fi, j
n+1 −fi, jn+1
αΔt= −
fi, jn
αΔt
∇h2 fi, j
n+1 − λ fi, jn+1 = S
Backward Euler
Rearrange
or
Can be solved by elliptic solvers
Computational Fluid Dynamics
One-Dimensional Problems• Explicit, implicit, Crank-Nicolson• Accuracy, stability• Various schemes
Multi-Dimensional Problems• Alternating Direction Implicit (ADI)• Approximate Factorization of Crank-Nicolson
Splitting
Outline
Solution Methods for Parabolic Equations
Computational Fluid Dynamics
TheAdvection-Diffusion
Equation
http://www.nd.edu/~gtryggva/CFD-Course/Computational Fluid Dynamics
�
∂u∂t
+ u∂u∂x
+ v∂u∂y
= −1ρ∂P∂x
+µρ
∂ 2u∂x 2
+∂ 2u∂y2
⎛ ⎝ ⎜ ⎞
⎠ ⎟
Navier-Stokes equations
�
∂u∂x
+∂v∂y
= 0
Parabolic part
Hyperbolic part
Elliptic equation
Summary
The Navier-Stokes equations contain three equation types that have their own characteristic behavior
Depending on the governing parameters, one behavior can be dominant
The different equation types require different solution techniques
For inviscid compressible flows, only the hyperbolic part survives
Computational Fluid Dynamics
�
∂f∂t
+U ∂f∂x
= D∂ 2 f∂x 2
�
f jn+1 − f j
n
Δt+U
f j+1n − f j−1
n
2h= D
f j+1n − 2 f j
n + f j−1n
h2
1D Advection/diffusion equation
Forward in time/centered in space (FTCS)
Stability:
22
21111
1
hD
hU
t
nj
nj
nj
nj
nj
nj
nj −+−++ +−
=−
+Δ− εεεεεεε
jikxnnj eεε =
Write:ε j±1n = ε neikx j e±ikhand use
Computational Fluid Dynamics
Gives)2()(
21 2
1ikhikhikhikh
n
n
eehtDee
htU −−
+
+−Δ+−Δ−=εε
�
=1− 4 DΔth2
sin2 k h2− iUΔt
hsinkh α =
kh2
A = DΔth2
B =UΔth
G2 = 1− 4Asin2α( )2+B2 sin2 2α ≤1
For stability
1−8Asin2α +16A2 sin4α +B2 sin2 2α ≤1
8Asin2α 2Asin2α −1( )+ 4B2 cos2α sin2α ≤ 0AB2
2cos2α
2Asin2α −1( )+1≤ 0or
Must be <0
Must be <-1
A ≤ 12
2 AB2
≥1
ΔtDh2
≤12
U2ΔtD
≤ 2
Computational Fluid Dynamics
U 2Δt2D
≤ 1 & DΔth2 ≤
12
�
∂f∂t
+U ∂f∂x
= D∂ 2 f∂x 2
�
f jn+1 − f j
n
Δt+U
f j+1n − f j−1
n
2h= D
f j+1n − 2 f j
n + f j−1n
h2
1D Advection/diffusion equation
Forward in time/centered in space (FTCS)
Stability limitsR =
ULD
Δt = 2D
U 2 & Δt = h2
2D
�
Δt→ 0 For high and low D
Computational Fluid Dynamics
�
∂f∂t
+U ∂f∂x
= D∂ 2 f∂x 2
�
O Δt,h2( )FTCS
�
UΔt2D
≤1 & DΔth2
≤ 12
�
O Δt,h( )Upwind
�
UΔth
+ 2DΔth2
≤1
�
O Δt 2,h2( )L-W
�
UΔth
⎛ ⎝ ⎜
⎞ ⎠ ⎟ 2
≤ 2 DΔth2
⎛ ⎝ ⎜
⎞ ⎠ ⎟ ≤1
�
O Δt 2,h2( )C-N Unconditionally stable
Computational Fluid Dynamics
Steady state solution to the advection/diffusion equation
U∂f∂x
= D∂ 2 f∂x2
Exact solution
�
f =exp RL x /L( ) −1exp RL( ) −1
�
RL = ULD
�
f = 0
�
f =1
�
U
�
L
Computational Fluid Dynamics
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
RL=1RL=5RL=10RL=20
Computational Fluid Dynamics
The Cell Reynolds number
Computational Fluid Dynamics
�
U ∂f∂x
= D∂ 2 f∂x 2
�
Uf j+1 − f j−12h
= Df j+1 − 2 f j + f j−1
h2
Centered difference approximation
Numerical solution of:
�
Uf j − f j−1h
= Df j+1 − 2 f j + f j−1
h2
Upwind
Computational Fluid Dynamics
Ufj+1 − f j−12h
= Df j+1 − 2 f j + f j−1
h2
Uh2
2hDfj+1 − fj−1( ) = fj+1 − 2 fj + fj−1
R =UhD
Where:
Rearrange:
Rearrange:
R− 2( ) fj+1 + 4 fj − R + 2( ) fj−1 = 0
Centered difference approximation
Computational Fluid Dynamics
fj = qj
Divide by
Solution
Substitute:
R− 2( )qj+1 + 4qj − R+ 2( )qj−1 = 0
R− 2( )q2 + 4q1 − R+ 2( ) = 0
q j−1
R− 2( ) fj+1 + 4 fj − R + 2( ) fj−1 = 0
Computational Fluid Dynamics
Solving for q gives two solutions:
q1 =1 and
The general solution is:
R− 2( )q2 + 4q1 − R+ 2( ) = 0
q2 =2 + R2 − R
fj = C1q1j + C2q2
j
fj = C1 + C22 + R2 − R
⎛ ⎝
⎞ ⎠
jor
Computational Fluid Dynamics
Apply the boundary conditions
f0 = C1 + C22 + R2 − R
⎛ ⎝
⎞ ⎠
0
= C1 + C2 = 0
fN = C1 + C22 + R2 − R
⎛ ⎝
⎞ ⎠
N
= 1
fj =
2 + R2 − R
⎛ ⎝
⎞ ⎠
j
−1
2 + R2 − R
⎛ ⎝
⎞ ⎠
N +1
−1
The final solution is:
Computational Fluid Dynamics
�
Uf j − f j−1h
= Df j+1 − 2 f j + f j−1
h2
�
R + 2( ) f j − R +1( ) f j−1 − f j+1 = 0R =
UhD
�
f j = q j
�
q2 − R + 2( )q1 + R +1( ) = 0
�
f j =1− 1+ R( ) j
1− 1+ R( )NSolution
Upwind
Try solutions
giving
or
Computational Fluid Dynamics
fj =
2 + R2 − R
⎛ ⎝
⎞ ⎠
j
−1
2 + R2 − R
⎛ ⎝
⎞ ⎠
N +1
−1
�
f =exp RL x /L( ) −1exp RL( ) −1
�
RL = ULD
R =UhD
Exact solution
Centered differences
Upwind
�
f j =1− 1+ R( ) j
1− 1+ R( )N
Computational Fluid Dynamics
UpwindExact
Centered
Computational Fluid Dynamics
UpwindExact
Centered
Computational Fluid Dynamics
UpwindExact
Centered
Computational Fluid Dynamics
When centered differencing is used for the advection/diffusion equation, oscillations may appear when the Cell Reynolds number is higher than 2. For upwinding, no oscillations appear. In most cases the oscillations are small and the cell Reynolds number is frequently allowed to be higher than 2 with relatively minor effects on the result.
�
R = UhD
< 2
Computational Fluid Dynamics
2D example
�
∂f∂t
+U ∂f∂x
+V ∂f∂y
= D ∂ 2 f∂x 2
+ ∂ 2 f∂y 2
⎛
⎝ ⎜
⎞
⎠ ⎟
�
f =1Flow
�
f = 0
�
f = 0
Computations using centered differences on a 32 by 32 grid
Computational Fluid Dynamics
D=0.02t=1.5088
Recell=3.2258
Computational Fluid Dynamics
D=0.01t=1.5088
Recell=6.4516
Computational Fluid Dynamics
D=0.005t=1.5088
Recell=12.9032
Computational Fluid Dynamics
D=0.02t=1.50
0
5
10
15
0
5
10
150
0.5
1
1.5
05
1015
2025
30
05
1015
2025
300
0.5
1
1.5
Recell=3.2258 Recell=6.6716
Fine grid Coarser grid
Computational Fluid Dynamics
The Cell Reynolds number limitation becomes an issue when the advection terms are discretized using centered differences.
In many cases the oscillations only appear in isolated regions where diffusion and advection are of comparable magnitude
Upwind avoids the problem, but generally adds dissipation