More Convection Derivatives February 22, 2010
Outline
Finite Volume Method for
• Review finite-volume convection
Convection Derivatives II – Note need for average φ value at cell faces
for convection terms
Larry Caretto – Examine use of arithmetic mean as
Mechanical Engineering 692 average value and show its problems
Computational Fluid Dynamics • Look at other schemes
– Upwind differencing
February 22, 2010 – Hybrid and power law
– Total variation diminishing (TVD)
Review Convection Terms Review Integrated PDE
• Steady equation with • Constant area result
dρuϕ d dϕ
convection and diffusion = Γ – Define F = ρu and D = Γ/δx
Fe ϕe − Fwϕ w = De (ϕ E − ϕ P ) − Dw (ϕ P − ϕW )
terms in one dimension dx dx dx
• Steady continuity dρu
=0 • Use (second-order accurate) arithmetic
equation in one dimension dx
• Apply finite volume approach to mean for face values
ϕE + ϕP ϕ + ϕW
integrate small volume Fe − Fw P = De (ϕ E − ϕ P ) − Dw (ϕ P − ϕW )
2 2
dρuϕ d dϕ dρ u F F
∫ dx
dV = Γ dV
dx dx ∫ ∫ dx
dV = 0 aE = De + e aW = Dw + w a P = a E + aW + Fe − Fw
2 2
3 aW ϕW − a P ϕ P + aE ϕ E = 0 4
Exact Solution
Review Example Problem 1
• Constant ρ, u, and Γ with φ = φ0 at x = 0 0.9
and φ = φL at x = L 0.8
dρuϕ d dϕ ρ u dϕ d dϕ 0.7 Pe = -10
= Γ ⇒ =
(ξ - ξ 0)/(ξ L - ξ 0)
Pe = -5
0.6
dx dx dx Γ dx dx dx Pe = -2
0.5 Pe = -1
• Exact solution below with plot on next Pe = 1
0.4
slide Pe = 2
0.3 Pe = 5
ρux
Pe = ρuL/Γ
ϕ( x ) − ϕ0
Pe = 10
e Γ −1 0.2
= ρuL Pecell = ρuδx/Γ = F/D
ϕ L − ϕ0 0.1
e Γ −1 0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
5 6
x
ME 692 – Computational Fluid Dynamics 1
More Convection Derivatives February 22, 2010
Review Numerical Solution Review Numerical Solution II
• Here δx, ρu and Γ are constants • Data: L = 1 m, u = 0.1 m/s, Γ = 0.1 kg/m·s,
– Fe = Fw = ρu = F De = Dw = Γ / δx = D δx = 0.2 m, ρ = 1 kg/m3
⎛ D⎞ ⎛ D⎞
– F = ρu = (1 kg/m3)(0.1 m/s) = 0.1 kg/m2·s
aW ϕW − a P ϕ P + aE ϕ E = ⎜ F + ⎟ϕW − 2 Fϕ P + ⎜ F − ⎟ϕ E = 0
⎝ 2⎠ ⎝ 2⎠
|-----●-----|-----●-----|-----●-----|-----●-----|-----●-----|-----●-----| – D = Γ/δx = (0.1 kg/m·s)(0.2 m) = 0.5 kg/m2·s
left 1 2 3 4 5 6 right – Ratio F/D = 0.2
• Boundary conditions at x = 0 and x = L • Second case: change from 0.1 m/s to 2.5
⎛F ⎞ ⎛ F⎞ m/s changing F/D from 0.2 to 5
− ⎜ + 3D ⎟ϕ1 + ⎜ D − ⎟ϕ2 = −(F + 2 D )ϕleft
⎝2 ⎠ ⎝ 2⎠ • Third case: leave u at 0.1 m/s; change dx
⎛ F⎞ ⎛ F⎞ from 0.2 to 0.05 changing F/D to 1.25
⎜ D + ⎟ϕ N − 2 − ⎜ 3D − ⎟ϕ N −1 = −(2 D − F )ϕright
⎝ 2⎠ ⎝ 2⎠
7 8
Comparison of Numerical and Exact Comparison of Numerical and Exact
Results (F/D = u x/ = 0.2) Results (F/D = u x/ = 5)
1 2
0.9 1.8
0.8 Exact 1.6 Exact
Numerical Numerical
0.7 1.4
0.6
1.2
0.5
1
0.4
0.8
0.3
0.6
0.2
0.4
0.1
0.2
0
9 0 10
0 0.2 0.4 x 0.6 0.8 1
0 02 04 x 06 08 1
Comparison of Numerical and Exact
Results (♦u♦x/♦ = 1.25)
What is Happening Here?
1.2
• When flow term F = ρu is large
1 compared to diffusion term D = δx/Γ the
use of average values does not
0.8 recognize the directionality of the flow
Exact • Keeping the F/D ratio small allows use
♦ 0.6
Numerical of average values in convection terms
0.4 – Requires small δx for large flow rates
• How can we use larger δx for large flow
0.2
rates and keep accuracy?
0 11 12
0 0.2 0.4 x 0.6 0.8 1
ME 692 – Computational Fluid Dynamics 2
More Convection Derivatives February 22, 2010
Algorithm Properties Algorithm Properties II
• Conservative schemes – conserve • Limit on coefficient magnitude for
properties in finite difference equations iteration schemes (boundedness)
– Requires exit flux from one face to be – Absolute value of diagonal coefficient must
same as input flux in adjacent cell be greater than the sum of absolute values
• Transportive schemes – have correct of all other coefficients
• For simple equations here |aP| ≥ |aE| + |aW|
balance between diffusion and
convection – Deferred correction separates coefficients
into two parts
• Accuracy – need schemes that have a • Adjustment leaves |aP| ≥ |aE| + |aW|
good truncation error • Places part removed from adjusted coefficients
into source term
13 14
Upwind Convection Term Positive F Terms
• Models directionality of flow • If Fe and Fw are both positive then φe =
|----------●----------|----------●----------|----------●----------| φP and φw = φW
W w P e E
|----------●----------|----------●----------|----------●----------|
• Previously we replaced Feφe by Fe(φE + W w P e E
φP)/2 in convection term Fe ϕe − Fwϕ w = De (ϕ E − ϕ P ) − Dw (ϕ P − ϕW )
• Upwind difference uses φe = φP if Fe is
Fe ϕ P − FwϕW = De (ϕ E − ϕ P ) − Dw (ϕ P − ϕW )
positive and φe = φE if Fe is negative
• Start with basic finite volume equation 0 = De ϕ E − (De + Fe + Dw )ϕ P + (Dw + Fw )ϕW
aP = De + Fe + Dw + Fw − Fw = De + Dw + Fw + Fe − Fw
Fe ϕe − Fwϕ w = De (ϕ E − ϕ P ) − Dw (ϕ P − ϕW ) aE = De aW = Dw + Fw aP = a E + aW + Fe − Fw
15 16
Negative F Terms Computational Formulas
• If Fe and Fw are both negative then φe = • Positive F terms
φE and φw = φP aE = De aW = Dw + Fw aP = a E + aW + Fe − Fw
|----------●----------|----------●----------|----------●----------| • Negative F terms
W w P e E
aE = De − Fe aW = Dw aP = a E + aW + Fe − Fw
Fe ϕe − Fwϕ w = De (ϕ E − ϕ P ) − Dw (ϕ P − ϕW )
• Computational formulas
Fe ϕ E − Fwϕ P = De (ϕ E − ϕ P ) − Dw (ϕ P − ϕW )
aW = Dw + max(Fw ,0) aE = De + max(− Fe ,0)
0 = (De − Fe )ϕ E − (De − Fw + Dw )ϕ P + DwϕW
aP = De − Fw + Dw + Fe − Fe = De − Fe + Dw + Fe − Fw aP = aE + aW + Fe − Fw
aE = De − Fe aW = Dw a P = aE + aW + Fe − Fw
17 18
ME 692 – Computational Fluid Dynamics 3
More Convection Derivatives February 22, 2010
Comparison of Upwind and Exact Results
Upwind Solution (° u°x/° = 1.25)
1.2
• Case III for previous problem
– L=1m 1
– u = 0.1 m/s
0.8
– Γ = 0.1 kg/m·s
– δx = 0.05 m ° 0.6 Exact
– ρ = 1 kg/m3 Numerical
• F = ρu = (1 kg/m3)(2.5 m/s) = 2.5 kg/m2·s 0.4
• D = Γ/δx = (0.1 kg/m·s) / (0.05 m) = 0.2
2 kg/m2·s
• Ratio F/D = 1.25 = Pecell 19 0 20
0 0.2 0.4 x 0.6 0.8 1
Errors in CFD Algorithms for Model Problem with Pecell = 1.25 Other Algorithms
1.E+00
1.E-01 • Hybrid algorithm
1.E-02 – Combination of central difference for Pecell
1.E-03 < 2 and upwind for Pecell ≥ 2
1.E-04
⎡ ⎛ F ⎞ ⎤ ⎡ ⎛ F ⎞ ⎤
aW = max ⎢ Fw , ⎜ Dw + w ⎟,0⎥ aE = max ⎢− Fe , ⎜ De + e ⎟,0⎥
⎝ 2 ⎠ ⎦ ⎝ 2 ⎠ ⎦
1.E-05
⎣ ⎣
Error
1.E-06
1.E-07
aP = a E + aW + Fe − Fw
1.E-08
Central • Power-law algorithm
Upwind
1.E-09 – Similar to hybrid
1.E-10 – Sets D = 0 for |Pecell| > 10
1.E-11
21
– Uses power law formula for |Pecell| ≤ 10 22
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x
Other Algorithms II Other Algorithms III
– Power law formula aP = a E + aW + Fe − Fw • QUICK formulas for central node P
[(
aW = Dw max 0, 1 − Pew )]+ max[F ,0]
5
w Pew = Fw Dw involve five nodes instead of three
●-------|-------●-------|-------●-------|-------●--------|-------●
= D max[0, (1 − Pe )]+ max[− F ,0]
5 WW ww W w P e E ee EE
aE e e e Pee = Fe De
aWW ϕWW + aW ϕW − aP ϕ P + aE ϕ E + aEE ϕ EE = 0
• QUICK – Quadratic Upstream
6α w Fw + 3(1 − α w )Fw + α e Fe α w Fw
Interpolation for Convective Kinetics aW = Dw + aWW = −
8 8
– Uses quadratic intrepolation formula
3α e Fe + 6(1 − α e )Fe + (1 − α w )Fw (1 − α e )Fe
– Choose nodes to use for interpolation a E = De − a EE =
8 8
depending on velocity αw = 1 if Fw > 0 and αe = 1 if Fe > 0
23 αw = 0 if Fw < 0 and αe = 0 if Fe < 0 24
ME 692 – Computational Fluid Dynamics 4
More Convection Derivatives February 22, 2010
Homework for March 3 TVD Algorithms
• Download the Excel workbook from the • Total Variation Diminishing schemes
course web site for the sample – Designed to maintain both accuracy and
convection problem with Pecell = 1.25 stability with no unphysical “wiggles”
– Shows results for Central and Upwind on – Consider set of different differencing
separate worksheets schemes for φe with positive u velocity
|----------●----------|----------●----------|----------●----------|
• Add similar worksheets to get results for
W w P e E
Hybrid, Power Law, and QUICK
• Upwind: φe = φP
• Add error results for these algorithms to φ P − φW
• Linear Upwind: φe = φ P + x − x (xe − xP )
the error chart P W
– For constant δx: φ P − φW
φe = φ P +
25 2 26
TVD Algorithms II Why TVD?
|----------●----------|----------●----------|----------●----------|
• Developed for transient compressible
W w P e E
3φ E − 2φ P − φW gas dynamics equations
• QUICK: φe = φ P + 8 • Scheme to obtain accurate compromise
φ − φP between false diffusion of upwinding
• Second order: φe = φ P + E
2 and “wiggles” of more accurate
• General form is φe = φP + Correction schemes in some regions
• Correction can always be written as a • Basic development mathematically
correction (ψ/2) times φE – φP complex, but results useful
• Correction function ψ depends on (φP – • Basic equation φe = φP + ψ(r)(φE – φP)/2
φW)/(φE – φP) – r = (φP – φW)/(φE – φP)
27 28
What is ψ? TVD Region Limits on ψ(r)
• Upwind: φe = φP ψ=0 • For 0 < r ≤ 1, ψ(r) ≤ 2r
• Second order arithmetic mean: • For r ≥ 1, ψ(r) ≤ 2
φE − φP 1 • For second-order accuracy and TVD
φe = φ P + = 1(φ E − φ P ) ⇒ ψ = 1
2 2
– For 0 < r ≤ 1, r ≤ ψ(r) ≤ 2r
• Linear upwind with constant δx: – For 1 ≥ r ≥ 2, 1 ≤ ψ(r) ≤ r
φ P − φW 1 φ P − φW
φe = φ P + = φP + (φ E − φ P ) = φ P + 1 r (φ E − φ P ) ⇒ ψ = r – For r > 2, 1 ≤ ψ(r) ≤ 2
2 2 φE − φP 2
• Implementation of TVD requires parts of
• QUICK (after some algebra) coefficient terms in Su term as deferred
1 ⎡1 ⎛ φ − φ ⎞⎤ 1 ⎡3 + r ⎤
φe = φ P + ⎢ ⎜⎜ 3 + P W ⎟⎟⎥ (φ E − φ P ) = φ P + ⎢ (φ E − φ P ) ⇒ ψ = 3 + r correction
2 ⎣4 ⎝ φ E − φ P ⎠⎦ 2 ⎣ 4 ⎥⎦ 4
29 30
ME 692 – Computational Fluid Dynamics 5
More Convection Derivatives February 22, 2010
Convection Schemes TVD Limiter Functions
3 2.5
2
2
UD Van Leer
2r 1.5 Van Albada
ψ (r) LUD ψ(r) min-mod
QUICK 1 SUPERBEE
1
CD UMIST
0.5
0 0
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
31 32
r r
ME 692 – Computational Fluid Dynamics 6