The Scalar-Transport Equation
The Scalar-Transport Equation
The Scalar-Transport Equation
t
W N
w
n
s P e
S E
b
k
j
B
i
Cell Indexing
Local Global
NN i,j+2
N i,j+1
n
WW Ww P e E EE i-2,j i-1,j i,j i+1,j i+2,j
s
i,j-1
S
i,j-2
SS
Generic Scalar-Transport Equation
u
V un
A
d 𝜕ϕ
(𝑚𝑎𝑠𝑠 × ϕ) + ( 𝑚𝑎𝑠𝑠 𝑓𝑙𝑢𝑥 × ϕ −Γ 𝐴 ) = 𝑆
d𝑡 𝜕𝑛
𝑓𝑎𝑐𝑒𝑠
𝑡𝑖𝑚𝑒 𝑑𝑒𝑟𝑖𝑣𝑎𝑡𝑖𝑣𝑒 𝑎𝑑𝑣𝑒𝑐𝑡𝑖𝑜𝑛 𝑑𝑖𝑓𝑓𝑢𝑠𝑖𝑜𝑛 𝑠𝑜𝑢𝑟𝑐𝑒
1-d Advection-Diffusion Equation
• Simple analysis
• Hand solution
dϕ x
Flux: 𝑓𝑙𝑢𝑥 = ρ𝑢𝐴 ϕ −Γ𝐴
d𝑥
𝑎𝑑𝑣𝑒𝑐𝑡𝑖𝑜𝑛
𝑑𝑖𝑓𝑓𝑢𝑠𝑖𝑜𝑛
Source: 𝑠Δ𝑥
8
1 cm 1 cm. The left-hand end is kept at
o
T=100 C
100 C, whilst the right-hand end is insulated.
dT
Rod dx =0
The heat flux across any section of area 𝐴 is
given by
d𝑇 s = -c (T-T )
8
x=0 1
−𝑘𝐴
d𝑥
where the conductivity 𝑘 = 1000 W m−1 K −1 . The rod loses heat along its length at a rate
proportional to the temperature excess over ambient (Newton’s law of cooling); i.e. the
heat source per unit length is:
𝑠 = −𝑐(𝑇 − 𝑇∞ )
where the ambient temperature 𝑇∞ = 20 °C and the coefficient 𝑐 = 2.5 W m−1 K −1.
(a) Write down and solve the differential equation for temperature along the rod.
(b) Divide the rod into 5 control sections, with nodes at the centre of each section, and
carry out a finite-volume analysis to find the temperature along the rod.
Differential Equation and Exact Solution
𝑓𝑙𝑢𝑥𝑒 − 𝑓𝑙𝑢𝑥𝑤 = 𝑠𝑜𝑢𝑟𝑐𝑒
flux w source flux e
d𝑇 d𝑇
−𝑘𝐴 − −𝑘𝐴 = −𝑐(𝑇 − 𝑇∞ )Δ𝑥
d𝑥 𝑒
d𝑥 𝑤
d𝑇 d𝑇
−𝑘𝐴 − −𝑘𝐴
d𝑥 𝑒 d𝑥 𝑤
= −𝑐(𝑇 − 𝑇∞ )
Δ𝑥
d d𝑇
( −𝑘𝐴 ) = −𝑐(𝑇 − 𝑇∞ ) 𝑇(0) = 100, 𝑇 ′ (1) = 0
d𝑥 d𝑥
d2 𝑇 𝑐 𝑐
− 𝑇=− 𝑇
d𝑥 2 𝑘𝐴 𝑘𝐴 ∞
d2 𝑇
− 25𝑇 = −500
d𝑥 2
𝑇 = 𝐴e5𝑥 + 𝐵e−5𝑥 + 2ด
0 𝐴 = 0.0036 , 𝐵 = 79.9964
𝑐𝑜𝑚𝑝𝑙𝑒𝑚𝑒𝑛𝑡𝑎𝑟𝑦 𝑝𝑎𝑟𝑡𝑖𝑐𝑢𝑙𝑎𝑟
𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛 𝑖𝑛𝑡𝑒𝑔𝑟𝑎𝑙
Finite-Volume Decomposition
-4
A = 10
1 2 3 4 5
TL = 100 flux R= 0
x = 0.2
Discretisation of Fluxes
T
TE
e
TW TP TE T
w e TP
x
x
d𝑇 𝑇𝐸 − 𝑇𝑃
𝑓𝑙𝑢𝑥𝑒 = − 𝑘𝐴 ቤ
d𝑥 𝑒 → −𝑘𝐴
Δ𝑥
Finite-Volume Discretisation
Conservation: 𝑓𝑙𝑢𝑥𝑒 − 𝑓𝑙𝑢𝑥𝑤 = 𝑠𝑜𝑢𝑟𝑐𝑒 flux w source flux e
Fluxes:
d𝑇 𝑇𝐸 − 𝑇𝑃 TW TP TE
interior faces: 𝑓𝑙𝑢𝑥𝑒 = − 𝑘𝐴 ቤ → −𝑘𝐴 w e
d𝑥 𝑒 Δ𝑥
𝑘𝐴
→ −𝐷(𝑇𝐸 − 𝑇𝑃 ) 𝐷= = 0.5
Δ𝑥
d𝑇 TL TP
𝑇𝑃 − 𝑇𝐿
left boundary: 𝑓𝑙𝑢𝑥𝐿 = − 𝑘𝐴 ቤ → −𝑘𝐴
d𝑥 𝐿 1
2Δ𝑥
→ −2𝐷(𝑇𝑃 − 𝑇𝐿 )
TP
flux R = 0
right boundary: 𝑓𝑙𝑢𝑥𝑅 = 0
TW w
TP e
TE
-4
A = 10
1 2 3 4 5
TL = 100 flux R= 0
x = 0.2
2 −0.5 0 0 0 𝑇1 110
−0.5 1.5 −0.5 0 0 𝑇2 10
0 −0.5 1.5 −0.5 0 𝑇3 = 10
0 0 −0.5 1.5 −0.5 𝑇4 10
0 0 0 −0.5 1 𝑇5 10
2 −0.5 0 0 0 𝑇1 110
−0.5 1.5 −0.5 0 0 𝑇2 10
0 −0.5 1.5 −0.5 0 𝑇3 = 10
0 0 −0.5 1.5 −0.5 𝑇4 10
0 0 0 −0.5 1 𝑇5 10
4 −1 0 0 0 ∥ 220
−1 3 −1 0 0 ∥ 20
All 𝑅 × 2: 0 −1 3 −1 0 ∥ 20
0 0 −1 3 −1 ∥ 20
0 0 0 −1 2 ∥ 20
4 −1 0 0 0 ∥ 220
𝑅2 → 4𝑅2 + 𝑅1: 0 11 −4 0 0 ∥ 300
0 −1 3 −1 0 ∥ 20
0 0 −1 3 −1 ∥ 20
0 0 0 −1 2 ∥ 20
4 −1 0 0 0 ∥ 220
0 11 −4 0 0 ∥ 300
𝑅3 → 11𝑅3 + 𝑅2: 0 0 29 −11 0 ∥ 520 2620
𝑇5 = = 21.30
0 0 −1 3 −1 ∥ 20 123
0 0 0 −1 2 ∥ 20
1100 + 29𝑇5
4 −1 0 0 0 ∥ 220 𝑇4 = = 22.60
76
0 11 −4 0 0 ∥ 300
0 0 29 −11 0 ∥ 520 520 + 11𝑇4
𝑅4 → 29𝑅4 + 𝑅3: 0 0 0 76 −29 ∥ 1100 𝑇3 = = 26.50
29
0 0 0 −1 2 ∥ 20
300 + 4𝑇3
4 −1 0 0 0 𝑇1 220 𝑇2 = = 36.91
0 11 −4 0 0 𝑇2 300 11
0 0 29 −11 0 𝑇3 = 520 220 + 𝑇2
0 0 0 76 −29 𝑇4 1100 𝑇1 = = 64.23
𝑅5 → 76𝑅5 + 𝑅4: 4
0 0 0 0 123 𝑇5 2620
Points to Note
E
e
P
x
x
dϕ ϕ𝐸 − ϕ𝑃
−Γ𝐴 ቤ → −(Γ𝐴)𝑒
d𝑥 𝑒 Δ𝑥
Discretising the Source Term
𝑠𝑜𝑢𝑟𝑐𝑒 = 𝑏𝑃 + 𝑠𝑃 ϕ𝑃 𝑠𝑃 ≤ 0
Examples:
𝑠𝑜𝑢𝑟𝑐𝑒 = 3 − 2ϕ 𝑏𝑝 = 3, 𝑠𝑝 = −2
2
𝑠𝑜𝑢𝑟𝑐𝑒 = 10 − 7ϕ3 𝑏𝑝 = 10, 𝑠𝑝 = −7ϕ∗
Solve iteratively
x
Example uN
(c) Using a finite-difference approximation for velocity gradient, find expressions for the viscous forces on
upper and lower faces of the jth cell in terms of the nodal velocities {𝑢𝑗 }. (Deal separately with interior
cells and the boundary cells 𝑗 = 1 and 𝑗 = 𝑁.)
(d) By balancing pressure and viscous forces set up the finite-volume equations for velocity.
(e) Solve for the nodal velocities in the case 𝑁 = 6, leaving your answers as multiples of 𝑈0 = 𝐺𝐻 2 /μ. (You
are advised to note the symmetry of the problem.)
(f) Using your numerical solution, find the volume flow rate (per unit span) 𝑞 in terms of 𝑈0 and 𝐻.
(h) Compare your answers to (e), (f), (g) with the exact solution for plane Poiseuille flow.
A 2-d finite-volume calculation is to be undertaken for fully-developed, laminar flow between stationary,
plane, parallel walls. A streamwise pressure gradient d𝑝/d𝑥 = −𝐺 is imposed and the fluid viscosity is μ.
The depth of the channel, 𝐻, is divided into 𝑁 equally-sized cells of dimension 𝑥 × 𝑦 × 1 as shown, with
the velocity 𝑢 stored at cell centres. x
(c) Using a finite-difference approximation for velocity gradient, find expressions for the viscous forces
on upper and lower faces of the jth cell in terms of the nodal velocities {𝑢𝑗 }.
d𝑢 𝑢𝑗+1 − 𝑢𝑗
Interior faces: 𝑣𝑖𝑠𝑐𝑜𝑢𝑠 𝑓𝑜𝑟𝑐𝑒 𝑜𝑛 𝑢𝑝𝑝𝑒𝑟 𝑓𝑎𝑐𝑒 = μ × (Δ𝑥 × 1) ≈ μ Δ𝑥
d𝑦 Δ𝑦
𝑢𝑗 − 𝑢𝑗−1
𝑣𝑖𝑠𝑐𝑜𝑢𝑠 𝑓𝑜𝑟𝑐𝑒 𝑜𝑛 𝑙𝑜𝑤𝑒𝑟 𝑓𝑎𝑐𝑒 ≈ −μ Δ𝑥
Δ𝑦
0 − 𝑢𝑗
Boundary faces: 𝑣𝑖𝑠𝑐𝑜𝑢𝑠 𝑓𝑜𝑟𝑐𝑒 𝑜𝑛 𝑢𝑝𝑝𝑒𝑟 𝑓𝑎𝑐𝑒 𝑜𝑓 𝑡𝑜𝑝 𝑐𝑒𝑙𝑙 ≈μ 1 Δ𝑥
2
Δ𝑦
𝑢𝑗 − 0
𝑣𝑖𝑠𝑐𝑜𝑢𝑠 𝑓𝑜𝑟𝑐𝑒 𝑜𝑛 𝑙𝑜𝑤𝑒𝑟 𝑓𝑎𝑐𝑒 𝑜𝑓 𝑏𝑜𝑡𝑡𝑜𝑚 𝑐𝑒𝑙𝑙 ≈ −μ Δ𝑥
1
2
Δ𝑦
A 2-d finite-volume calculation is to be undertaken for fully-developed, laminar flow between stationary,
plane, parallel walls. A streamwise pressure gradient d𝑝/d𝑥 = −𝐺 is imposed and the fluid viscosity is μ.
The depth of the channel, 𝐻, is divided into 𝑁 equally-sized cells of dimension 𝑥 × 𝑦 × 1 as shown, with
the velocity 𝑢 stored at cell centres.
(d) By balancing pressure and viscous forces set up the finite-volume equations for velocity.
x
𝑢𝑗+1 − 𝑢𝑗 𝑢𝑗 − 𝑢𝑗−1
Interior cell: 𝐺Δ𝑥Δ𝑦 + μ Δ𝑥 − μ Δ𝑥 = 0 uN
Δ𝑦 Δ𝑦
𝐺Δ𝑦 2
= −𝑢𝑗−1 + 2𝑢𝑗 − 𝑢𝑗+1 u j+1
μ
uj
y
0 − 𝑢𝑗 𝑢𝑗 − 𝑢𝑗−1 H
Top cell (𝑗 = 𝑁): 𝐺Δ𝑥Δ𝑦 + μ 1 Δ𝑥 − μ Δ𝑥 = 0 uj-1
2
Δ𝑦 Δ𝑦
𝐺Δ𝑦 2
= −𝑢𝑗−1 + 3𝑢𝑗 u1
μ
𝑢𝑗+1 − 𝑢𝑗 𝑢𝑗 − 0
Bottom cell (𝑗 = 1): 𝐺Δ𝑥Δ𝑦 + μ Δ𝑥 − μ 1 Δ𝑥 = 0
Δ𝑦 2
Δ𝑦
𝐺Δ𝑦 2
= 3𝑢𝑗 − 𝑢𝑗+1
μ
(e) Solve for the nodal velocities in the case 𝑁 = 6, leaving your answers as multiples of 𝑈0 = 𝐺𝐻 2 /μ.
Symmetry: 𝑢1 = 𝑢6 , 𝑢2 = 𝑢5 , 𝑢3 = 𝑢4 Consider just 𝑗 = 1,2,3
2
𝐺Δ𝑦 2 𝐺𝐻 2 Δ𝑦 1
= = 𝑈
μ μ 𝐻 36 0
A 2-d finite-volume calculation is to be undertaken for fully-developed, laminar flow between stationary,
plane, parallel walls. A streamwise pressure gradient d𝑝/d𝑥 = −𝐺 is imposed and the fluid viscosity is μ.
The depth of the channel, 𝐻, is divided into 𝑁 equally-sized cells of dimension 𝑥 × 𝑦 × 1 as shown, with
the velocity 𝑢 stored at cell centres.
(e) Solve for the nodal velocities in the case 𝑁 = 6, leaving your answers as multiples of 𝑈0 = 𝐺𝐻 2 /μ.
x
1 1 1
𝑗 = 1: 3𝑢1 − 𝑢2 = 𝑈 𝑢1 = (𝑢2 + 𝑈 ) uN
36 0 3 36 0
1
𝑗 = 2: −𝑢1 + 2𝑢2 − 𝑢3 = 𝑈
36 0 u j+1
uj
1 1 1
H y
𝑗 = 3: −𝑢2 + 2𝑢3 − 𝑢4 = 𝑈 −𝑢2 + 𝑢3 = 𝑈 𝑢3 = 𝑢2 + 𝑈 uj-1
36 0 36 0 36 0
u1
1 1 1 1
− (𝑢2 + 𝑈0 ) + 2𝑢2 − (𝑢2 + 𝑈0 ) = 𝑈
3 36 36 36 0
2 7 1
𝑢2 = × 𝑈0
3 3 36
7
𝑢2 = 𝑈
72 0
3 7 9
𝑢1 = 𝑢6 = 𝑈 𝑢2 = 𝑢5 = 𝑈 𝑢3 = 𝑢4 = 𝑈
72 0 72 0 72 0
A 2-d finite-volume calculation is to be undertaken for fully-developed, laminar flow between stationary,
plane, parallel walls. A streamwise pressure gradient d𝑝/d𝑥 = −𝐺 is imposed and the fluid viscosity is μ.
The depth of the channel, 𝐻, is divided into 𝑁 equally-sized cells of dimension 𝑥 × 𝑦 × 1 as shown, with
the velocity 𝑢 stored at cell centres.
(f) Using your numerical solution, find the volume flow rate (per unit span) 𝑞 in terms of 𝑈0 and 𝐻.
3 7 9 x
𝑢1 = 𝑢6 = 𝑈0 𝑢2 = 𝑢5 = 𝑈0 𝑢3 = 𝑢4 = 𝑈0
72 72 72 u N
6 3
𝐻 𝐻 3 7 9 19 u j+1
𝑞 = 𝑢𝑗 Δ𝑦 = 2 𝑢𝑗 = 𝑈0 ( + + ) = 𝑈 𝐻
𝑗=1 𝑗=1
6 3 72 72 72 216 0 H
uj
y
uj-1
u1
2 × τ𝑤 Δ𝑥 = (𝑝𝐿 − 𝑝𝑅 )𝐻
1 𝑝𝐿 − 𝑝𝑅 1
τ𝑤 = ( )𝐻 = 𝐺𝐻
2 Δ𝑥 2
A 2-d finite-volume calculation is to be undertaken for fully-developed, laminar flow between stationary,
plane, parallel walls. A streamwise pressure gradient d𝑝/d𝑥 = −𝐺 is imposed and the fluid viscosity is μ.
The depth of the channel, 𝐻, is divided into 𝑁 equally-sized cells of dimension 𝑥 × 𝑦 × 1 as shown, with
the velocity 𝑢 stored at cell centres.
(h) Compare your answers to (e), (f), (g) with the exact solution for plane Poiseuille flow.
x
𝑢 1𝑦 𝑦 𝐺𝐻 2
Exact solution: = 1− , 𝑈0 =
𝑈0 2 𝐻 𝐻 uN
μ
u j+1
Nodal values:
3 7 9 H
uj
y
(numerical) 𝑢1 = 𝑢6 = 𝑈 𝑢2 = 𝑢5 = 𝑈 𝑢3 = 𝑢4 = 𝑈
72 0 72 0 72 0 uj-1
Flow rate:
19
(numerical) 𝑞= 𝑈 𝐻
216 0
𝐻
18
(exact) 𝑞 = න 𝑢 d𝑦 = 𝑈 𝐻
0 216 0
Wall stress:
1
(numerical) 𝜏𝑤 = 𝐺𝐻
2
𝜕𝑢 1
(exact) τ𝑤 = μ ቤ 𝜏𝑤 = 𝐺𝐻
𝜕𝑦 𝑦=0 2
Discretising Advection (Part 1)
Example
=0 d
u =0
dx
x=0 L
point
source
A faulty valve introduces a reactive chemical into the pipe half-way along its length at a
rate of 0.01 kg s–1. The diffusivity of the chemical in water is Γ = 0.1 kg m−1 s−1 . The
chemical is subsequently broken down at a rate proportional to its concentration ϕ (mass
of chemical per unit mass of water), this rate amounting to – γϕ per metre, where γ =
0.5 kg m−1 s −1 .
point
source
Source
‒ point source 𝑆𝑝𝑡 at 𝑥 = 0.5 m
‒ loss by chemical breakdown −γϕ per unit length
Finite-Volume Decomposition
d
L = 0 1 2 3 4 5 6 7 =0
dx
S pt = 0.01 kg/s
Finite-Volume Discretisation
𝑓𝑙𝑢𝑥𝑒 − 𝑓𝑙𝑢𝑥𝑤 = 𝑠𝑜𝑢𝑟𝑐𝑒 W w
P e
E
𝑠𝑜𝑢𝑟𝑐𝑒 = 𝑆ด
𝑝𝑡 − 𝛾ϕ𝑃 Δ𝑥 𝑠𝑜𝑢𝑟𝑐𝑒 = 𝑏𝑃 + 𝑠𝑃 ϕ𝑃 𝑏𝑃 = 0.01 (cell 4)
𝑐𝑒𝑙𝑙 4 𝑠𝑃 = −0.071
P
e
E
P E
e
1
ϕ𝑒 = (ϕ𝑃 + ϕ𝐸 )
2
Finite-Volume Discretisation:
Central Differencing For Advection
1 1
Central differencing: 𝐶ϕ𝑒 − 𝐶ϕ𝑤 = 𝐶 (ϕ𝑃 + ϕ𝐸 ) − 𝐶 (ϕ𝑊 + ϕ𝑃 )
2 2
𝐶
= (ϕ𝐸 − ϕ𝑊 )
2
𝐶 𝐶
−( + 𝐷)ϕ𝑊 + (2𝐷 − 𝑠𝑃 )ϕ𝑃 − (− + 𝐷)ϕ𝐸 = 𝑏𝑃
2 2
0.592 0.493 0 0 0 0 0 ϕ1 0
−0.507 0.085 0.493 0 0 0 0 ϕ2 0
0 −0.507 0.085 0.493 0 0 0 ϕ3 0
0 0 −0.507 0.085 0.493 0 0 ϕ4 = 0.01
0 0 0 −0.507 0.085 0.493 0 ϕ5 0
0 0 0 0 −0.507 0.085 0.493 ϕ6 0
0 0 0 0 0 −0.507 0.578 ϕ7 0
Directional Bias
diffusion only
u advection
+
diffusion
Upwind Differencing
P e P
E e E
P E P E
e e
1.092 −0.007 0 0 0 0 0 ϕ1 0
−1.007 1.085 −0.007 0 0 0 0 ϕ2 0
0 −1.007 1.085 −0.007 0 0 0 ϕ3 0
0 0 −1.007 1.085 −0.007 0 0 ϕ4 = 0.01
0 0 0 −1.007 1.085 −0.007 0 ϕ5 0
0 0 0 0 −1.007 1.085 −0.007 ϕ6 0
0 0 0 0 0 −1.007 1.078 ϕ7 0
Simple Advection Schemes Compared
−𝑎𝑊 ϕ𝑊 + 𝑎𝑃 ϕ𝑃 − 𝑎𝐸 ϕ𝐸 = 𝑏𝑃
W w
P e
E
𝑎𝑊 = 12𝐶 + 𝐷 𝑎𝑊 = 𝐶 + 𝐷
𝑎𝐸 = −12𝐶 + 𝐷 𝑎𝐸 = 𝐷 (if 𝐶 > 0)
𝑎𝑃 = 2𝐷 − 𝑠𝑃 𝑎𝑃 = 𝐶 + 2𝐷 − 𝑠𝑃
No “wiggles” Pe ≤ 2
𝐶 ρ𝑢Δ𝑥
Pe = = Peclet number
𝐷 Γ
dϕ
𝑓𝑙𝑢𝑥 = 𝐶ϕ − Γ𝐴
d𝑥
W P E −𝑎𝑊 ϕ𝑊 + 𝑎𝑃 ϕ𝑃 − 𝑎𝐸 ϕ𝐸 = 𝑏𝑃
Discretisation:
=b AΦ = b
Finite-Volume Analysis: 2-d
fluxn
W P E −𝑎𝑆 ϕ𝑆 − 𝑎𝑊 ϕ𝑊 + 𝑎𝑃 ϕ𝑃 − 𝑎𝐸 ϕ𝐸 − 𝑎𝑁 ϕ𝑁 = 𝑏𝑃
Discretisation:
𝑎𝑃 ϕ𝑃 − 𝑎𝐹 ϕ𝐹 = 𝑏𝑃
S
=b AΦ = b
General Discretisation Properties
Discretisation Properties
• Consistency
• Conservativeness
• Transportiveness
• Boundedness
• Stability
• Accuracy (“order”)
Consistency
ϕ𝐸 − ϕ𝑃 dϕ
e.g. →
Δ𝑥 d𝑥
Conservativeness
flux
Definition: upstream-biased
P e
E
P E
e
Boundedness
Definition. For advection-diffusion without sources:
(1) ϕP must lie between minimum and maximum values at surrounding nodes
(2) ϕ = constant must be a possible solution (if the boundary conditions permit)
𝑎𝑃 ϕ𝑃 − 𝑎𝐹 ϕ𝐹 = 0 N
W P E
𝑎𝐹
If ϕ𝐹 is the only non-zero adjacent value, ϕ𝑃 = ϕ𝐹
𝑎𝑃
If ϕ is constant. (𝑎𝑃 − 𝑎𝐹 )ϕ = 0 S
Definition:
Requirement:
𝑠𝑜𝑢𝑟𝑐𝑒 = 𝑏𝑃 + 𝑠𝑃 ϕ𝑃 , 𝑠𝑃 ≤ 0
Summary of Conditions on Matrix Coefficients
N
𝑠𝑜𝑢𝑟𝑐𝑒 = 𝑏𝑃 + 𝑠𝑃 ϕ𝑃
W P E
𝑎𝑃 ϕ𝑃 − 𝑎𝐹 ϕ𝐹 = 𝑏𝑃
S
Positive coefficients:
𝑎𝐹 ≥ 0 for all 𝐹
𝑎𝑃 = 𝑎𝐹 − 𝑠𝑃
Accuracy (“Order”)
• General definition:
𝐨𝐫𝐝𝐞𝐫 𝒏 ⇔ 𝑒𝑟𝑟𝑜𝑟 ∝ Δ𝑥 𝑛 as Δ𝑥 → 0
P e E
2 3 4
dϕ Δ𝑥 1 d2 ϕ Δ𝑥 1 d3 ϕ Δ𝑥 1 d4 ϕ Δ𝑥
ϕ𝐸 = ϕ𝑒 + + + + + ⋯
d𝑥 𝑒
2 2! d𝑥 2 𝑒
2 3! d𝑥 3 𝑒
2 4! d𝑥 4 𝑒
2
2 3 4
dϕ Δ𝑥 1 d2 ϕ Δ𝑥 1 d3 ϕ Δ𝑥 1 d4 ϕ Δ𝑥
ϕ𝑃 = ϕ𝑒 − + − + + ⋯
d𝑥 𝑒
2 2! d𝑥 2 𝑒
2 3! d𝑥 3 𝑒
2 4! d𝑥 4 𝑒
2
Subtract:
dϕ 2 d3 ϕ Δ𝑥 ϕ𝐸 − ϕ𝑃 dϕ
ϕ𝐸 − ϕ𝑃 = 0 + Δ𝑥 + 0 + ( )3 + ⋯ = + O(Δ𝑥 2 )
d𝑥 3! d𝑥 3 2 Δ𝑥 d𝑥 𝑒
𝑒 𝑒
x
3 x
(b) Making use of the W and EE nodes also, find symmetric fourth-
order approximations for ϕ𝑒 and dϕ/d𝑥 𝑒 .
(b) Making use of the W and EE nodes also, find symmetric W P e E EE
Add:
2 d2 ϕ Δ𝑥 2 d4 ϕ Δ𝑥 4
ϕ𝑃 + ϕ𝐸 = 2ϕ𝑒 + 0 + ( ) +0 + ( ) +⋯
2! d𝑥 2 𝑒
2 d𝑥 4 𝑒
2
ϕ𝑃 + ϕ𝐸 1 d2 ϕ Δ𝑥 2
= ϕ𝑒 + ( ) + O(Δ𝑥)4
2 2! d𝑥 2 𝑒
2
ϕ𝑊 + ϕ𝐸𝐸 1 d2 ϕ 3Δ𝑥 2
= ϕ𝑒 + ( ) + O(Δ𝑥)4
2 2! d𝑥 2 𝑒
2
ϕ𝑃 + ϕ𝐸 ϕ𝑊 + ϕ𝐸𝐸 1 d2 ϕ Δ𝑥
α +β = (α + β)ϕ𝑒 + (α + 9β) ( )2 + O(Δ𝑥)4
2 2 2 d𝑥 2 𝑒
2
Require α + β = 1 8β = −1 9 ϕ𝑃 + ϕ𝐸 1 ϕ𝑊 + ϕ𝐸𝐸
1 9 − = ϕ𝑒 + O(Δ𝑥)4
α + 9β = 0 8 2 8 2
β=− α=
8 8
(b) Making use of the W and EE nodes also, find symmetric W P e E EE
Subtract:
dϕ 2 d3 ϕ Δ𝑥 3 2 d5 ϕ Δ𝑥
ϕ𝐸 − ϕ𝑃 = 0 + Δ𝑥 + 0 + ( ) +0+ ( )5 + ⋯
d𝑥 𝑒
3! d𝑥 3 𝑒
2 5! d𝑥 5 𝑒
2
ϕ𝐸 − ϕ𝑃 dϕ 1 d3 ϕ Δ𝑥 2
= + ( ) + O(Δ𝑥)4
Δ𝑥 d𝑥 𝑒
3! d𝑥 3 𝑒
2
ϕ𝐸𝐸 − ϕ𝑊 dϕ 1 d3 ϕ 3Δ𝑥 2
= + ( ) + O(Δ𝑥)4
3Δ𝑥 d𝑥 𝑒
3! d𝑥 3 𝑒
2
ϕ𝐸 − ϕ𝑃 ϕ𝐸𝐸 − ϕ𝑊 dϕ 1 d3 ϕ Δ𝑥
α +β = (α + β) + (α + 9β) 3
( )2 + O(Δ𝑥)4
Δ𝑥 3Δ𝑥 d𝑥 𝑒
3! d𝑥 𝑒
2
Require α + β = 1 8β = −1 9 ϕ𝐸 − ϕ𝑃 1 ϕ𝐸𝐸 − ϕ𝑊 dϕ
− = + O(Δ𝑥)4
1 9 8 Δ𝑥 8 3Δ𝑥 d𝑥
α + 9β = 0 β=− α= 𝑒
8 8
Discretising Advection (Part 2)
Exponential Scheme
Exact solution of the 1-d advection-diffusion equation
dϕ P E
𝑓𝑙𝑢𝑥 = 𝐶ϕ − Γ𝐴 = 𝑐𝑜𝑛𝑠𝑡𝑎𝑛𝑡 e
d𝑥
ePe ϕ𝑃 − ϕ𝐸 Γ𝐴 𝐶
𝑓𝑙𝑢𝑥𝑒 = 𝐶 𝐶 = ρ𝑢𝐴, 𝐷= , Pe =
ePe − 1 Δ𝑥 𝐷
𝐶ePe 𝐶
𝑎𝑊 = , 𝑎𝐸 =
ePe − 1 ePe − 1
𝑓𝑙𝑢𝑥𝑒 − 𝑓𝑙𝑢𝑥𝑤 = 𝑎𝑃 ϕ𝑃 − 𝑎𝐹 ϕ𝐹
𝑎𝑃 = 𝑎𝐸 + 𝑎𝑊
LUD (Linear Upwind Differencing)
P e E
face e
u>0
• Fits a quadratic through 3 nodes
ϕ𝑓𝑎𝑐𝑒 = −18ϕ𝑈𝑈 + 34ϕ𝑈 + 38ϕ𝐷 E EE
e
P
• 3rd-order accurate
P E EE
e
• Transportive, but not bounded u<0
Flux-Limited Schemes
ϕ𝑈 − ϕ𝑈𝑈
𝑟= monotonic non-monotonic
ϕ𝐷 − ϕ𝑈
● Non-linear ( iteration necessary)
● Total-Variation-Diminishing
Scheme 𝛙(𝒓) (for 𝒓 > 𝟎)
2𝑟
Harmonic Van Leer (1974)
1+𝑟
𝑟 + 𝑟2
Van Albada et al. Van Albada et al., (1982)
1 + 𝑟2
x
ϕ𝑊𝑊 = 1, ϕ𝑊 = 4, ϕ𝑃 = 5, ϕ𝐸 = 7, ϕ𝐸𝐸 = 3
The Van Leer harmonic advection scheme is defined (for the immediate upstream and
downstream nodes, U and D respectively) by:
1
ϕ𝑓𝑎𝑐𝑒 = ϕ𝑈 + ψ(𝑟)(ϕ𝐷 − ϕ𝑈 )
2
2𝑟
if 𝑟 > 0 ϕ𝑈 − ϕ𝑈𝑈
ψ(𝑟) = ቐ 1 + 𝑟 𝑟=
0 otherwise ϕ𝐷 − ϕ𝑈
Calculate the values of ϕ on the cell faces marked e and w in the figure using the Van Leer
advection scheme if the velocity component 𝑢 is:
(i) positive;
(ii) negative.
w e 1
WW W P E EE ϕ𝑓𝑎𝑐𝑒 = ϕ𝑈 + ψ(𝑟)(ϕ𝐷 − ϕ𝑈 )
2
x 2𝑟
if 𝑟 > 0 ϕ𝑈 − ϕ𝑈𝑈
ϕ𝑊𝑊 = 1, ϕ𝑊 = 4, ϕ𝑃 = 5, ϕ𝐸 = 7, ϕ𝐸𝐸 = 3 ψ(𝑟) = ቐ 1 + 𝑟 𝑟=
ϕ𝐷 − ϕ𝑈
0 otherwise
Calculate the values of ϕ on the cell faces marked e and w in the figure using the Van Leer advection
scheme if the velocity component 𝑢 is (i) positive; (ii) negative.
𝑢 positive 𝑢 negative
w: ϕ𝑈𝑈 = 1, ϕ𝑈 = 4, ϕ𝐷 = 5 w: ϕ𝑈𝑈 = 7, ϕ𝑈 = 5, ϕ𝐷 = 4
4−1 5−7
𝑟= =3 𝑟= =2
5−4 4−5
2×3 3 2×2 4
ψ= = ψ= =
1+3 2 1+2 3
1 3 1 4
ϕ𝑓 = 4 + × (5 − 4) = 4.75 ϕ𝑓 = 5 + × (4 − 5) = 4.333
2 2 2 3
e: ϕ𝑈𝑈 = 4, ϕ𝑈 = 5, ϕ𝐷 = 7 e: ϕ𝑈𝑈 = 3, ϕ𝑈 = 7, ϕ𝐷 = 5
5−4 1
𝑟= =
7−5 2
Non-monotonic
2 × (1/2) 2
ψ= =
1 + (1/2) 3
1 2 ϕ𝑓 = ϕ𝑈 =7
ϕ𝑓 = 5 + × (7 − 5) = 5.667
2 3
Implementation of Higher-Order Schemes
𝜕ϕ
( 𝑚𝑎𝑠𝑠 𝑓𝑙𝑢𝑥 × ϕ −Γ 𝐴 )= 𝑆
𝜕𝑛
𝑓𝑎𝑐𝑒𝑠
𝑎𝑑𝑣𝑒𝑐𝑡𝑖𝑜𝑛 𝑑𝑖𝑓𝑓𝑢𝑠𝑖𝑜𝑛 𝑠𝑜𝑢𝑟𝑐𝑒
P f F
[𝐶𝑓 ϕ𝑓 + 𝐷𝑓 (ϕ𝑃 − ϕ𝐹 )] = 𝑏𝑃 + 𝑠𝑃 ϕ𝑃
𝑓𝑎𝑐𝑒𝑠
The upwind part always gives positive coefficients and diagonal dominance
𝐶𝑓 (ϕ𝑓 − ϕ𝑃 ) = 𝐶𝑓 (ϕ𝑈 − ϕ𝑃 ) + 𝐶𝑓 (ϕ𝑓 − ϕ𝑈 )
𝑢𝑝𝑤𝑖𝑛𝑑 𝑐𝑜𝑟𝑟𝑒𝑐𝑡𝑖𝑜𝑛
= max( − 𝐶𝑓 , 0)(ϕ𝑃 − ϕ𝐹 ) +𝐶𝑓 (ϕ𝑓 − ϕ𝑈 )
The deferred correction is transferred to the source term and treated explicitly
(i.e. not updated until the next iteration):
𝑎𝐹 (ϕ𝑃 − ϕ𝐹 ) = 𝑏𝑃 + 𝑠𝑃 ϕ𝑃 − 𝐶𝑓 (ϕ𝑓 − ϕ𝑈 ) 𝑎𝐹 = max( − 𝐶𝑓 , 0) + 𝐷𝑓
𝐹 𝑓𝑎𝑐𝑒𝑠
𝑑𝑒𝑓𝑒𝑟𝑟𝑒𝑑 𝑐𝑜𝑟𝑟𝑒𝑐𝑡𝑖𝑜𝑛
Implementation of Boundary Conditions
boundary
boundary
𝑎𝑃 ϕ𝑃 − 𝑎𝐹 ϕ𝐹 = 𝑏𝑃 − 𝑓𝑙𝑢𝑥𝑏𝑜𝑢𝑛𝑑𝑎𝑟𝑦
𝑛𝑜𝑡
𝑏𝑜𝑢𝑛𝑑𝑎𝑟𝑦
Matrix Solution Algorithms
Form of the Matrix Equations
𝑎𝑃 ϕ𝑃 − 𝑎𝐹 ϕ𝐹 = 𝑏𝑃
𝐹
1-d 2-d
W P E W P E
−𝑎𝑊 ϕ𝑊 + 𝑎𝑃 ϕ𝑃 − 𝑎𝐸 ϕ𝐸 = 𝑏𝑃 −𝑎𝑆 ϕ𝑆 − 𝑎𝑊 ϕ𝑊 + 𝑎𝑃 ϕ𝑃 − 𝑎𝐸 ϕ𝐸 − 𝑎𝑁 ϕ𝑁 = 𝑏𝑃
=b =b
Characteristics of the Equations
• Fluid-flow equations:
‒ non-linear
‒ coupled
• Matrix equations:
‒ sparse
‒ banded (for structured meshes)
• Solution methods:
‒ iterative
Common Solution Methods
• Gaussian elimination
• Gauss-Seidel
• Line Gauss-Seidel
Gaussian Elimination
•
=b
Important exception: tri-diagonal systems
(basis of the tri-diagonal matrix algorithm)
Gauss-Seidel
−𝑎𝑆 ϕ𝑆 − 𝑎𝑊 ϕ𝑊 + 𝒂𝑷 𝛟𝑷 − 𝑎𝐸 ϕ𝐸 − 𝑎𝑁 ϕ𝑁 = 𝑏𝑃
1
𝛟𝑷 = (𝑏𝑃 + 𝑎𝑆 ϕ∗𝑆 + 𝑎𝑊 ϕ∗𝑊 + 𝑎𝐸 ϕ∗𝐸 + 𝑎𝑁 ϕ∗𝑁 )
𝑎𝑃
W P E
S
direction of sweep
being updated
already updated
not yet updated
Gauss-Seidel Example (i)
4 −1 0 0 𝐴 2
−1 4 −1 0 𝐵 4
=
0 −1 4 −1 𝐶 6
0 0 −1 4 𝐷 13
4 −1 0 0 𝐴 2
−1 4 −1 0 𝐵 4
=
0 −1 4 −1 𝐶 6
0 0 −1 4 𝐷 13
A B C D
2+𝐵
4𝐴 − 𝐵 = 2 𝐴= 0 0 0 0
4
4+𝐴+𝐶 0.500 1.125 1.781 3.695
−𝐴 + 4𝐵 − 𝐶 = 4 𝐵=
4
6+𝐵+𝐷 0.781 1.641 2.834 3.959
−𝐵 + 4𝐶 − 𝐷 = 6 𝐶=
4 0.910 1.936 2.974 3.994
13 + 𝐶
−𝐶 + 4𝐷 = 13 𝐷=
4 --- --- --- ---
DIVERGES!
Gauss-Seidel Overview
• Iterative
• Simple to code
−𝑎𝑆 ϕ𝑆 − 𝒂𝑾 𝛟𝑾 + 𝒂𝑷 𝛟𝑷 − 𝒂𝑬 𝛟𝑬 − 𝑎𝑁 ϕ𝑁 = 𝑏𝑃
=b -
*
of sweep
direction
W P E
S
Line Gauss-Seidel - Overview
• Iterative
Single-cell error:
residual: 𝑟𝑒𝑠 = 𝑎𝑃 ϕ𝑃 − 𝑎𝐹 ϕ𝐹 − 𝑏𝑃
𝐹
Global error:
sum of absolute residuals: 𝑟𝑒𝑠
𝑐𝑒𝑙𝑙𝑠
1
root-mean-square error: (𝑟𝑒𝑠)2
𝑁
𝑐𝑒𝑙𝑙𝑠
Convergence criteria:
error < tolerance
or
error < fraction of initial error
Under-Relaxation
σ 𝑎𝐹 ϕ𝐹 + 𝑏𝑃
Rearrange as the change in ϕ: ϕ𝑃 =
𝑎𝑃
𝑝𝑟𝑒𝑣 σ 𝑎𝐹 ϕ𝐹 + 𝑏𝑃 𝑝𝑟𝑒𝑣
ϕ𝑃 = ϕ𝑃 + − ϕ𝑃
𝑎𝑃
𝑝𝑟𝑒𝑣 σ 𝑎𝐹 ϕ𝐹 + 𝑏𝑃 𝑝𝑟𝑒𝑣
Under-relax the change: ϕ𝑃 = ϕ𝑃 +α − ϕ𝑃
𝑎𝑃
𝑝𝑟𝑒𝑣
Rearrange back: 𝑎𝑃 ϕ𝑃 − α𝑎𝐹 ϕ𝐹 = α𝑏𝑃 + (1 − α)𝑎𝑃 ϕ𝑃
𝑎𝑃 𝑎𝑃 𝑝𝑟𝑒𝑣
ϕ𝑃 − 𝑎𝐹 ϕ𝐹 = 𝑏𝑃 + (1 − α) ϕ𝑃
𝛼 𝛼
𝑎𝑃
Incorporate by modifying coefficients: 𝑎𝑃 → 𝑎𝑃′ =
α
𝑝𝑟𝑒𝑣
𝑏𝑃 → 𝑏𝑃′ = 𝑏𝑃 + (1 − α)𝑎𝑃′ ϕ𝑃
Summary (1)
• The generic scalar-transport equation for a control volume has the form
rate of change + net outward flux = source