computational fluid - university of notre damegtryggva/cfd-course2017/lecture-7-2017.pdf ·...
TRANSCRIPT
Computational Fluid Dynamics
Computational Fluid Dynamics
http://www.nd.edu/~gtryggva/CFD-Course/
Grétar Tryggvason
Lecture 7February 6, 2017
Computational Fluid Dynamicshttp://www.nd.edu/~gtryggva/CFD-Course/
Classical Methods
Discontinuous solutions
Entropy conditions
Shock speed
Conservative discretization
Computational Fluid Dynamics
Classical Methodsfor Hyperbolic
Equations
Computational Fluid Dynamics
�
∂ 2 f∂t 2
− c 2 ∂2 f∂x 2
= 0
�
∂u∂t
− c 2 ∂v∂x
= 0
∂v∂t
− ∂u∂x
= 0
The wave equation:
Write as:
In general:
∂u∂t∂v∂t
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
+a11 a12a21 a22
⎡
⎣⎢⎢
⎤
⎦⎥⎥
∂u∂x∂v∂x
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
= 0
Most of the issues involved can be addressed by examining:
�
∂f∂t
+U ∂f∂x
= 0
Methods for Advection
Computational Fluid Dynamics
Forward in Time, Centered in Space
(FTCS) and Upwind
Computational Fluid Dynamics
We will start by examining the linear advection equation:∂f∂t
+ U∂f∂x
= 0
The characteristic for this equation are:dxdt
=U; dfdt
= 0;
Showing that the initial conditions are simply advected by a constant velocity U
t
f
f
x
Methods for Advection
Computational Fluid Dynamics
A simple forward in time, centered in space discretization yields
∂f∂t
+ U∂f∂x
= 0
fjn+1 = fj
n −Δt2hU ( fj+1
n − fj−1n )
j-1 j j+1n
n+1
Methods for AdvectionComputational Fluid Dynamics
This scheme is O(Δt, h2) accurate, but a stability analysis shows that the error grows as
ε n+1
ε n= 1− i
UΔt2h
sin kh
Since the amplification factor has the form 1+i() the absolute value of this complex number is always larger than unity and the method is unconditionally unstable for this case.
iUΔt2h
sinkh
1
ε n+1
ε n
Methods for Advection
Computational Fluid Dynamics
A simple forward in time but “upwind” in space discretization yields
∂f∂t
+ U∂f∂x
= 0
fjn+1 = fj
n −ΔthU ( fj
n − fj−1n )
j-1 jn
n+1 This scheme is O(Δt, h) accurate.
Another scheme for
Flow direction
Methods for AdvectionComputational Fluid Dynamics
To examine the stability we use the von Neuman’s method:
ε jn+1 − ε j
n
Δt+Uh(ε j
n − ε j−1n ) = 0
ε jn = εneikx j
ε n+1 − ε n
Δt+U ε n
h(1− e− ikh) = 0
The evolution of the error is governed by:
Write the error as:
�
εn+1
εn=1−UΔt
h(1− e−ikh )
�
G = εn+1
εn=1− λ(1− e−ikh ), λ = UΔt
h
Amplification factor
�
G =1− λ + λe− ikhOr:
�
G <1Need to find when
Methods for Advection
Computational Fluid Dynamics
Stable
Im(G)
1
1
kh
λ 1-λ
G
UΔth
≤ 1
This restriction was first derived by Courant, Fredrik, and Levy in 1932, and is usually called the Courant condition, or the CFL condition.
�
G =1− λ + λe− ikh, λ = UΔth
Stability condition: λ<1
Graphically:
Methods for AdvectionComputational Fluid Dynamics
�
G =1− λ + λe− ikh =1− λ + λcoskh − iλ sinkh
�
G 2 = 1− λ + λcoskh( )2 + λ2 sin2 kh
= 1− λ( )2 + 2 1− λ( )λcoskh + λ2 cos2 kh + λ2 sin2 kh
= 1− λ( )2 + 2 1− λ( )λcoskh + λ2
=1− 2λ + 2λ2 + 2 1− λ( )λcoskh
�
G 2 =1− 2λ 1− λ( ) if coskh = 0
G 2 =1 if coskh =1
G 2 =1− λ 4 − 3λ( ) if coskh = −1
�
G 2 ≤1 if λ ≤1
Another way: Find the absolute value of the amplification factor
1
�
G 2
�
λ1�
coskh = 0
�
coskh = −1
Methods for Advection
Computational Fluid Dynamics
The CFL condition implies that a signal has to travel less than one grid spacing in one time step
�
UΔt ≤ h
Flow direction
j-1 j
n
n+1
Allowable characteristics
Not allowable characteristics
Methods for AdvectionComputational Fluid Dynamics
fjn+1 = fj
n −ΔthU ( fj
n − fj−1n )
j-1 jn
n+1
O(Δt, h) accurate.
For the linear advection equation:
Flow direction
UΔth
≤ 1
Uh
The Upwind Scheme
�
∂f∂t
+U ∂f∂x
= 0
Methods for Advection
Computational Fluid Dynamics
dt=0.25*h
20 40 60 80-0.5
0
0.5
1
1.5
Upwind
Although the upwind method is exceptionally robust, its low accuracy in space and time makes it unsuitable for most serious computations
Methods for AdvectionComputational Fluid Dynamics
Finite Volume point of view:
xj-1/2 xj+1/2
�
f j−1
�
f j
x
f
�
f j+1
�
f jn+1 = f j
n − Δth(Fj+1/ 2
n − Fj−1/ 2n ) = f j
n − ΔthU( f j
n − f j−1n )
�
Fj+1/ 2=Uf jn
�
Fj−1/ 2=Uf j−1n
Methods for Advection
Computational Fluid Dynamics
Stability in terms of Fluxes
for the upwind scheme
Computational Fluid Dynamics
f j−1 f j f j+1
Fj−1 / 2 = Ufj−1n = 1
Fj+1 / 2 = Ufjn = 0
Consider the following initial conditions:
1
During one time step, U∆t of f flows into cell j, increasing the average value of f by U∆t/h.
U = 1
Δ th
= 1.5 ⋅U = 1.5
Stability in terms of fluxes
Computational Fluid Dynamics
fi+1
Consider the following initial conditions:
1f j−1 fi
Fj−1 / 2 = Ufj−1n = U
Fj+1 / 2 = Ufjn = 0
f jn+1 = fj
n −Δth(Fj+1 / 2
n − Fj−1 / 2n ) = 0 − 1.5(0 −1) = 1.5
Stability in terms of fluxes
Δ th
= 1.5 ⋅U = 1.5
Computational Fluid Dynamics
f j+11
f j−1 f j
Fj−1 / 2 = Ufj−1n =U
Fj+1 / 2 = Ufjn = 1.5U
f jn+1 = fj
n −Δth(Fj+1 / 2
n − Fj−1 / 2n ) = 0 − 1.5(1.5 − 1) = 0.75
f j+1n+1 = fj+1
n −Δth(Fj+ 3/ 2
n − Fj+1/ 2n ) = 0 −1.5(0 −1.5) = 2.25
Stability in terms of fluxes
Δ th
= 1.5 ⋅U = 1.5
Computational Fluid Dynamics
f j+11
f j−1 f j
Fj−1 / 2 = Ufj−1n =U
Fj+1 / 2 = Ufjn = 0.75U
Taking a third step will result in an even larger positive value, and so on until the compute encounters a NaN (Not a Number).
Fj+1 / 2 = Ufjn = 2.25U
Stability in terms of fluxesΔ th
= 1.5 ⋅U = 1.5
Computational Fluid Dynamics
If U∆t/h > 1, the average value of f in cell j will be larger than in cell j-1. In the next step, f will flow out of cell j in both directions, creating a larger negative value of f. Taking a third step will result in an even larger positive value, and so on until the compute encounters a NaN (Not a Number).
Stability in terms of fluxes
Computational Fluid Dynamics
MOVIE FROM MATLAB% one-dimensional advection by first order upwind.n=80; nstep=100; dt=0.0125; length=2.0;h=length/(n-1);y=zeros(n,1);f=zeros(n,1);f(1)=1.0;
for m=1:nstep,m hold off, plot(f); axis([1, n, -0.5, 1.5]); pause(0.01); y=f; for i=2:n-1, f(i)=y(i)-(dt/h)*(y(i)-y(i-1)); %upwind end;end;
Stability in terms of fluxesComputational Fluid Dynamics
Generalized Upwind Scheme (for both U > 0 and U < 0 )
�
f jn+1 = f j
n −UΔth( f j
n − f j−1n ), U > 0
�
f jn+1 = f j
n −UΔth( f j+1
n − f jn ), U < 0
Define:
�
U + = 12U + U( ), U− = 1
2U − U( )
The two cases can be combined into a single expression:
�
f jn+1 = f j
n − ΔthU +( f j
n − f j−1n ) +U−( f j+1
n − f jn )[ ]
Or, substituting −+ UU ,
�
f jn+1 = f j
n −U Δt2h( f j+1
n − f j−1n ) +
U Δt2h
( f j+1n − 2 f j
n + f j−1n )
central difference + numerical viscosity Dnum =U h2
Computational Fluid Dynamics
Other First Order Schemes
Computational Fluid Dynamics
Implicit (Backward Euler) Method
- Unconditionally stable- 1st order in time, 2nd order in space- Forms a tri-diagonal matrix (Thomas algorithm)
( ) 02
11
11
1
=−+Δ− +
−++
+nj
nj
nj
nj ff
hU
tff
nj
nj
nj
nj f
tf
hUf
tf
hU
Δ=−
Δ+ +
−++
+
12
12
11
111
jnjj
njj
njj Cfbfdfa =++ +
−++
+11
111
Methods for Advection
Computational Fluid Dynamics
Lax-Fredrichs method
f jn+1 − 1
2 f j+1n + f j−1
n( )Δt
+U2h
f j+1n − f j−1
n( ) = 0
Methods for Advection
f jn= 12 f j+1
n + f j−1n( )
f jn+1 − f j
n
Δt+U2h
f j+1n − f j−1
n( ) = 0
Start with the unstable centered difference approximation
Replace the old value by
Resulting in
Computational Fluid Dynamics
Lax-Fredrichs method- stable for λ < 1- 1st order in time and space- Conditionally consistent, but!
Uh2
1λ−λ
⎛
⎝⎜
⎞
⎠⎟ fxx +
Uh2
31−λ 2( ) fxxx
12h2
Δt−UΔt
⎛
⎝⎜
⎞
⎠⎟ fxx +
13Uh2 −U 3Δt2( ) fxxx
Error term:
λ =UΔth
hλ=
h2
UΔt
Methods for Advection
Δt ~ h
O Δt,h( )
If we assume that then we have
Used as a starting point for higher order methods
Computational Fluid Dynamics
Second Order Schemes
Computational Fluid Dynamics
)(2
211
tOtff
tf n
jnj Δ+
Δ−
=∂∂ −+
Leap Frog Method
The simplest stable second-order accurate (in time) method:
Modified equation
( )nj
nj
nj
nj ff
htUff 11
11−+
−+ −Δ−=
( ) +−=∂∂+
∂∂
xxxfUh
xf
Utf 1
62
2
λ
- Stable for 1<λ- Dispersive (no dissipation) – error will not damp out- Initial conditions at two time levels - Oscillatory solution in time (alternating)
λ =UΔth
Methods for Advection
Computational Fluid Dynamics
+Δ∂∂+Δ
∂∂+Δ
∂∂+=Δ+
62)()(
3
3
32
2
2 ttft
tft
tftfttf
Lax-Wendroff’s Method (LW-I)
First expand the solution in time
Then use the original equation to rewrite the time derivatives
xf
Utf
∂∂−=
∂∂
2
22
2
2
xf
Utf
xU
xf
Utt
ftt
f∂∂=
∂∂
∂∂−=⎟
⎠⎞⎜
⎝⎛
∂∂
∂∂−=⎟
⎠⎞⎜
⎝⎛∂∂
∂∂=
∂∂
Methods for AdvectionComputational Fluid Dynamics
)(2
)()( 32
2
22 tOtxfUt
xfUtfttf Δ+Δ
∂∂+Δ
∂∂−=Δ+
Substituting
Using central differences for the spatial derivatives
�
f jn+1 = f j
n −UΔt2h
f j+1n − f j−1
n( ) + U2Δt 2
2h2f j+1n − 2 f j
n + f j−1n( )
2nd order accurate in space and time
Stable for 1<ΔhtU
Methods for Advection
Computational Fluid Dynamics
Two-Step Lax-Wendroff’s Method (LW-II)
LW-I into two steps:
For the linear equations, LW-II is identical to LW-I
02/
2/)( 112/12/1 =
−+
Δ+− ++
++
hff
Ut
fff nj
nj
nj
nj
nj
02/12/1
2/12/1
1
=−
+Δ− +
−++
+
hff
Utff n
jnj
nj
nj
Step 1 (Lax)
Step 2 (Leapfrog)
- Stable for 1/ <Δ htU- Second order accurate in time and space
Methods for AdvectionComputational Fluid Dynamics
MacCormack Method
Similar to LW-II, without
( )njnj
nj
tj ff
htUff −Δ−= +1
( )⎥⎦⎤
⎢⎣⎡ −Δ−+= −
+ tj
tj
tj
nj
nj ff
htUfff 1
1
21
Predictor
Corrector
- A fractional step method- Predictor: forward differencing- Corrector: backward differencing
- For linear problems, accuracy and stability properties are identical to LW-I.
2/1,2/1 −+ jj
Methods for Advection
Computational Fluid Dynamics
Second-Order Upwind Method
Warming and Beam (1975) – Upwind for both steps
( )nj
nj
nj
tj ff
htUff 1−−Δ−=
f j
n+1 =12
f jn + f j
t −U Δth
f jt − f j−1
t( ) −U Δth
f jn − 2 f j−1
n + f j−2n( )⎡
⎣⎢
⎤
⎦⎥
Predictor Corrector
Combining the two:
f j
n+1 = f jn − λ f j
n − f j−1n( ) + 1
2λ(λ −1) f j
n − 2 f j−1n + f j−2
n( )- Stable if- Second-order accurate in time and space
20 ≤≤ λ
Methods for AdvectionComputational Fluid Dynamics
The one-step Lax-Wendroff is not easily extended to non-linear or multi-dimensional problems. The split version is.
In the Lax-Wendroff and the MacCormack methods the spatial and the temporal discretization are not independent.
Other methods have been developed where the time integration is independent of the spatial discretization, such as the Beam-Warming and various Runge-Kutta methods
Methods for Advection
Computational Fluid Dynamics
FTCSUnconditionally
Unstable
UpwindStable for
ImplicitUnconditionally
Stable
Lax-Friedrichs Conditionally consistent
Stable for
0=+ xt Uff
02
111
=−
+Δ− −+
+
hff
Utff n
jnj
nj
nj ( ) xxxxx f
Uhf
Ut 2
22
2162
λ+−Δ−
011
=−
+Δ− −
+
hff
Utff n
jnj
nj
nj
( )
( ) xxx
xx
fUh
fUh
1326
12
22
+−−
−
λλ
λ
1≤λ
( ) xxxxx fUh
fUh 2
2
13
12
λλλ
−+⎟⎠⎞⎜
⎝⎛ −
( )0
2
11
11
1
=−
+Δ− +
−++
+
hff
Utff n
jnj
nj
nj
xxxxx ftUUhftU
⎥⎦⎤
⎢⎣⎡ Δ+−Δ 232
2
31
61
2
( )
( )0
2
2/
11
111
=−
+
Δ+−
−+
−++
hff
U
tfff
nj
nj
nj
nj
nj
1≤λ
SummaryComputational Fluid Dynamics
Leap FrogStable for
Lax-Wendroff IStable for
Lax-Wendroff IISame as LW-I
Stable for
MacCormackSame as LW-I
Stable for
0=+ xt Uff
022
1111
=−
+Δ− −+
−+
hff
Utff n
jnj
nj
nj ( ) xxxf
Uh 16
22
−λ
( )
( ) xxxx
xxx
fUh
fUh
23
22
18
16
λλ
λ
−−
−−
1≤λ
1≤λ
1≤λ
( )
( )0
222
21122
111
=+−
Δ−
−+
Δ−
−+
−++
hfff
tU
hff
Utff
nj
nj
nj
nj
nj
nj
nj
02/
2/)( 112/12/1 =
−+
Δ+− ++
++
hff
Ut
fff nj
nj
nj
nj
nj
02/12/1
2/12/1
1
=−
+Δ− +
−++
+
hff
Utff n
jnj
nj
nj 1≤λ
( )01 =
−+
Δ− +
hff
Utff n
jnj
nj
tj
( ) ( )0
2/ 11
=−
+Δ+− −
+
hff
Utfff t
jtj
tj
nj
nj
Summary
Computational Fluid Dynamics
Beam-WarmingStable for
QUICKStable for
ENO
WENO
0=+ xt Uff
( )
( ) 022
243
212
2
211
=+−Δ−
+−+
Δ−
−−
−−+
nj
nj
nj
nj
nj
nj
nj
nj
fffhtU
hfff
Utff
20 ≤≤ λ
( )( )
( ) ( ) xxxx
xxx
fUh
fUh
λλ
λλ
−−−
−−
218
216
23
2
�
f jn+1 − f j
n
Δt+
U3 f j
n + 6 f j−1n − f j−2
n( ) − 3 f j+1n + 6 f j
n − f j−1n( )
8h1≤λ
A large number of (conditionally) stable and accurate methods exists for hyperbolic equations with smooth solutions
And Many More!
SummaryComputational Fluid Dynamics
Higher order upwindQUICK
Computational Fluid Dynamics
s=1f1
s=2f2
s=3f3
s=4f4
s=5/2
At s = 5/2
�
∂f 2
∂x⎞
⎠ ⎟ i
≈ 1h
fi+1/ 22 − fi−1/ 2
2{ }
= 164h
3 fi+1 + 6 f i − fi−1[ ]2 − 3 f i + 6 f i−1 − f i−2[ ]2{ }�
f5 / 2 = 1/8( ) 3 f3 + 6 f2 − f1[ ] �
∂f∂t
+ 12∂f 2
∂x= D∂ 2 f
∂x 2
QUICK (Quadratic Upstream Interpolation for Convective Kinematics)
Use to solve:
Computational Fluid Dynamics
Centered
UpwindQUICK
�
∂f∂t
+ 12∂f 2
∂x= D∂ 2 f
∂x 2
Computational Fluid Dynamics
0 5 10 15 20 25 30 35 400
1
2
3
4
5
6
7
8
9
10
0 5 10 15 20 25 30 35 400
1
2
3
4
5
6
7
8
9
10
Re_cell=20Re_cell=10
�
∂f∂t
+ 12∂f 2
∂x= D∂ 2 f
∂x 2
Centered
UpwindQUICK
Computational Fluid Dynamics
Discontinuoussolutions—shocks
Computational Fluid Dynamics
�
∂f∂t
+U ∂f∂x
= 0
The analytic solution is obtained by characteristics
�
dxdt
=U; dfdt
= 0;
Consider the linear Advection Equation
t
f
f
xDiscontinuity of solution is allowed
( )RLR
L ffxxfxxf
xf >⎩⎨⎧
><
=0
0)0,(
�
dxdt
=U
Discontinuous SolutionsComputational Fluid Dynamics
( )RLR
L ffxxfxxf
xf >⎩⎨⎧
><
=0
0)0,(0=∂∂+
∂∂
xf
ftf
;0; ==dtdf
fdtdx
Inviscid Burgers’ Equation
t
x
Characteristics
0x
Lf
Rf
??=dtdx
0x
Shock Wave
Discontinuous Solutions
Computational Fluid Dynamics
( ) ( ) axa
axfax
ffff
axf
xf
R
RLRL
L
<<−
⎪⎪⎩
⎪⎪⎨
⎧
>
⎥⎦⎤
⎢⎣⎡ −−+
−<
=21)0,(
A slight variation of the initial condition – formation of shock
t
x
Shock Wave
a− a
Lf
Rf 0=t
RL ffat−
= 2
Discontinuous SolutionsComputational Fluid Dynamics
Shock Speed
Discontinuous Solutions
Computational Fluid Dynamics
x
∂f∂t
=∂f∂t
+∂f∂x'
∂x'∂t
∂f∂t
+∂F∂x
= 0
∂f∂t
− C∂f∂x'
+∂F∂x'
= 0
x' = x − Ct
∂x'∂t
= C
x’The speed of the shock Write:
Substitute into:
where
∂f∂t
− C∂f∂x'
+∂F∂x'
⎛ ⎝
⎞ ⎠
Δ→ 0∫ dx = 0
�
∂f∂t
⎛ ⎝ ⎜
⎞ ⎠ ⎟
Δ→0∫ dx − C ∂f
∂x'⎛ ⎝ ⎜
⎞ ⎠ ⎟
Δ→0∫ dx + ∂F
∂x'⎛ ⎝ ⎜
⎞ ⎠ ⎟
Δ→0∫ dx = 0
0
Discontinuous SolutionsComputational Fluid Dynamics
�
− C ∂f∂x'
⎛ ⎝ ⎜
⎞ ⎠ ⎟
Δ→0∫ dx + ∂F
∂x'⎛ ⎝ ⎜
⎞ ⎠ ⎟
Δ→0∫ dx = 0
−C fR − fL( ) + FR − FL( ) = 0
C =FR − FLfR − fL
x
x’
Rankine-Hugoniot relations
Discontinuous Solutions
Computational Fluid Dynamics
∂f∂t
+ f∂f∂x
= 0
Example
F =12f 2
C =FR − FLfR − fL
=12fR2 − fL2
fR − fL=12
fR − fL( ) fR + fL( )fR − fL
C =12fR + fL( )
Discontinuous SolutionsComputational Fluid Dynamics
The Entropy Conditions
Computational Fluid Dynamics
0=∂∂+
∂∂
xf
ftf
Inviscid Burgers’ Equation
The transformation
t
x0x
�
x→−x; t→−tLeaves the equation unchanged but results in an unphysical solution.
The entropy condition is used to select the correct solution
t
x0x
The Entropy ConditionsComputational Fluid Dynamics
( )RLR
L ffxxfxxf
xf <⎩⎨⎧
><
=0
0)0,(0=∂∂+
∂∂
xf
ftf
;0; ==dtdf
fdtdx
Reverse Shock (?)
Characteristics
0x
Lf
Rf t
x0x
Unstable, entropy-violatingsolution
The Entropy Conditions
Computational Fluid Dynamics
( )RLR
L ffxxfxxf
xf <⎩⎨⎧
><
=0
0)0,(0=∂∂+
∂∂
xf
ftf
;0; ==dtdf
fdtdx
Rarefaction Wave (physically correct solution)
Characteristics
0x
Lf
Rf t
x0x
The Entropy ConditionsComputational Fluid Dynamics
Weak solutions to hyperbolic equations may not be unique.
How can we find a physical solution out of many weaksolutions?
In fluid mechanics, the actual physics always includes dissipation, i.e. in the form of viscous Burgers’ equation:
2
2
xf
xf
ftf
∂∂=
∂∂+
∂∂ ε
Therefore, what we are truly seeking is the solution to the viscous Burgers’ equation in the limit of 0→ε
The Entropy Conditions
Computational Fluid Dynamics
Entropy Condition:A discontinuity propagating with speed C satisfies the entropy condition if
For a conservation equation
)()( RL fFCfF ′>>′
( ) ( ) ( ) ( )R
R
L
L
fffFfFC
fffFfF
−−≥≥
−−
0)( =∂
∂+∂∂
xfF
tf
Version I:
Version II:
And some others…
Entropy Condition
t
x
Shock Wave
for
fL ≥ f ≥ fR
Computational Fluid Dynamics
The Entropy Condition states that the characteristics must “enter” the discontinuity. Thus, its speed C satisfies must satisfy
Given a conservation equation
)()( RL fFCfF ′>>′
0)( =∂
∂+∂∂
xfF
tf
Entropy Condition
t
x
Shock Wave
�
∂f∂t
+ ∂F∂f
∂f∂x
= 0
�
dxdt
= ∂F∂f
= ′ F ( f )
Rewrite in “characteristic” form
where:
�
dtds
=1; dxds
= ∂F∂f
or:
Computational Fluid Dynamics
Similarly, the shock speed is given by
( ) ( ) ( ) ( )R
R
L
L
fffFfFC
fffFfF
−−≥≥
−−
Thus
Entropy Condition
t
x
Shock Wave
C =FR − FLfR − fL
fL ≥ f ≥ fRfor
Means that the hypothetical shock speed for values of f between the left and the right state must give shock speeds that are larger on the left and smaller on the right.
Computational Fluid Dynamics
Conservative discretization
Computational Fluid Dynamics
In finite volume method, equations in conservative forms are needed in order to satisfy conservation properties.
As an example, consider a 1-D equation
�
∂f (x, t)∂t
+∂F[ f (x, t)]
∂x= 0
where F denotes a general advection/diffusion term, e.g.
�
F =12f 2; F = µ(x) ∂f
∂x
Conservative SchemesComputational Fluid Dynamics
�
∂F∂x
dxL∫ =
Fj+1/ 2 − Fj−1/ 2
Δx∑ Δx
Xj-1/2 xj+1/2
�
f j+1
�
f j−1
�
f j
x
In discretized form:
�
= + Fj−1/ 2 − Fj−3 / 2 + Fj+1/ 2 − Fj−1/ 2 + Fj+3 / 2 − Fj+1/ 2 +[ ]
�
= FL − F0
If F = 0 at the end points of the domain, f is conserved.
Integrating over the domain L,
�
∂f∂tdx
L∫ +
∂F∂x
dxL∫ = 0
�
F(L) − F (0) = 0
�
⇒ddt
fdxL∫ = 0
Conservative Schemes
Computational Fluid Dynamics
�
∂f∂t
+ ∂∂x
12f 2
⎛ ⎝ ⎜
⎞ ⎠ ⎟ = 0
Examples of Conservative Form
Discretize using upwind
�
∂∂x
12f 2
⎛ ⎝ ⎜
⎞ ⎠ ⎟ ≈
12h
fi2 − f i−1
2( ) Conservative�
∂f∂t
+ f ∂f∂x
= 0
�
f ∂f∂x
≈ f ih
f i − f i−1( ) Non-conservative
versus
Conservative SchemesComputational Fluid Dynamics
�
∂F∂x
dxL∫ ≈ Fj+1/ 2 − Fj−1/ 2∑ =
+ fi−12 − f i−2
2 + f i2 − f i−1
2 + f i+12 − fi
2 +
�
∂F∂x
dxL∫ ≈ Fj+1/ 2 − Fj−1/ 2∑ =
+ fi−12 − f i−1 f i + f i
2 − f i f i−1 + f i+12 − f i+1 f i +
�
∂∂x
12f 2
⎛ ⎝ ⎜
⎞ ⎠ ⎟ ⎞ ⎠ ⎟ i
≈ 12h
fi2 − f i−1
2( )
�
f ∂f∂x
⎞ ⎠ ⎟ i
≈ f ih
fi − f i−1( )
Conservative Schemes
Computational Fluid Dynamics
�
∂f∂t
+ ∂∂x
µ(x) ∂f∂x
⎛ ⎝ ⎜
⎞ ⎠ ⎟ = 0
Another example (variable diffusion coefficient)
Discretize
�
∂∂x
µ(x) ∂f∂x
⎛ ⎝
⎞ ⎠
Conservative
�
µ∂2 f∂x 2
+∂µ∂x
∂f∂x
Non-conservative
versus
Conservative SchemesComputational Fluid Dynamics
�
∂f∂t
+ f ∂f∂x
= 0
�
f ∂f∂t
+ f ∂f∂x
⎛ ⎝ ⎜
⎞ ⎠ ⎟ = 0
�
∂∂t
f 2
2+ ∂∂x
f 3
3= 0
�
ddt
f 2
2dx∫ = − ∂
∂xf 3
3dx∫ = f 3
3⎡
⎣ ⎢
⎤
⎦ ⎥ −∞
∞
= 0
�
f ∞( ) = f −∞( ) = 0
�
ddt
f n
ndx∫ = 0
Similarly, it can be shown that
Conservation of higher order quantitiesConsider:
Integrate:
Conservative Schemes
Computational Fluid Dynamics
Generally it is believed that conservative schemes are superior to non-conservative ones and that the more conserved quantities the discrete approximation preserves, the better the scheme. While mostly true, there are exceptions as we will discuss later!
Computational Fluid Dynamics
Conservative Schemes are guarantied to give the correct Shock Speed since they correspond to a direct application of the conservation principles.
Non-conservative schemes may or may not do so.
Discontinuous Solutions
Computational Fluid Dynamics
In capturing the correct solution behavior for discontinuousInitial data, conservative methods are essential (Lax).
Conservation and shock speed
Example: inviscid Burgers equation:
021
or0 2 =⎟⎠⎞⎜
⎝⎛
∂∂+
∂∂=
∂∂+
∂∂
fxt
fxf
ftf
Conservative MethodComputational Fluid Dynamics
Consider upwind and forward Euler scheme:
Example: for inviscid Burgers equationwith discontinuous initial data
0=+ xt fff
1−j
1
j 1+j
�
f jn+1 = f j
n − Δthf jn f j
n − f j−1n( ) = 0
Non-conservative form
Never moves!
�
ft + 12 f
2( )x = 0
�
f jn+1 = f j
n − Δt2h
( f jn )2 − ( f j−1
n )2( ) = Δt2h
Conservative form
Conservative Method
Computational Fluid Dynamics
Advecting a shock withseveral schemes
Computational Fluid Dynamics
Example Problem: Linear Wave Equation
0,,0 ≥∞<<∞−=∂∂+
∂∂
txxf
Utf
⎩⎨⎧
><
=0001
)0,(xx
xf
Exact Solution: )( Utxf −
Apply various numerical methods
Computational Fluid Dynamics
fjn+1 = fj
n −ΔthU ( fj
n − fj−1n )
�
f jn+1 = f j
n −UΔt2h
f j+1n − f j−1
n( ) + U2Δt 2
2h2f j+1n − 2 f j
n + f j−1n( )
f jn+1 = f j
n−1 −UΔth
f j+1n − f j−1
n( )
( )njnj
nj
tj ff
htUff −Δ−= +1
( )⎥⎦⎤
⎢⎣⎡ −Δ−+= −
+ tj
tj
tj
nj
nj ff
htUfff 1
1
21
Upwind
Leap-frog
Lax-Wendroff
MacCormack
Computational Fluid Dynamics
Comparison: h=0.1; dt= 0.05;n=41, time=2.75
5 10 15 20 25 30 35 40-0.5
0
0.5
1
1.5
Leap-frog
5 10 15 20 25 30 35 40-0.5
0
0.5
1
1.5
Upwind
5 10 15 20 25 30 35 40-0.5
0
0.5
1
1.5
Lax-Wendroff
5 10 15 20 25 30 35 40-0.5
0
0.5
1
1.5
MacCormack
Computational Fluid Dynamics
Comparison: h=0.05; dt= 0.025;n=81, time=2.75
10 20 30 40 50 60 70 80-0.5
0
0.5
1
1.5
Lax-Wendroff
10 20 30 40 50 60 70 80-0.5
0
0.5
1
1.5
Upwind
10 20 30 40 50 60 70 80-0.5
0
0.5
1
1.5
Leap-frog
10 20 30 40 50 60 70 80-0.5
0
0.5
1
1.5
MacCormack
Computational Fluid Dynamics
Comparison: n=41 and n=81, time=2.75
10 20 30 40 50 60 70 80-0.5
0
0.5
1
1.5
Upwind
10 20 30 40 50 60 70 80-0.5
0
0.5
1
1.5
MacCormack
5 10 15 20 25 30 35 40-0.5
0
0.5
1
1.5
Upwind
5 10 15 20 25 30 35 40-0.5
0
0.5
1
1.5
MacCormack
Computational Fluid Dynamics
Observation 1:Second-order methods tends to capture shaper solution (better accuracy), but they produce wiggly solutions.
Observation 2:First-order methods are dissipative and less accurate, but the solution does not oscillate. (preserves monotonicity).
Computational Fluid Dynamicshttp://www.nd.edu/~gtryggva/CFD-Course/
Classical Methods
Discontinuous solutions
Entropy conditions
Shock speed
Conservative discretization