4. The Scalar-Transport Equation - University of Manchester · 2021. 1. 4. · Example A thin rod...

83
4. The Scalar-Transport Equation

Transcript of 4. The Scalar-Transport Equation - University of Manchester · 2021. 1. 4. · Example A thin rod...

  • 4. The Scalar-Transport Equation

  • Structured Grid; Cell-Centred Storage

    E

    W N

    S

    B

    T

    P e

    w

    t

    b

    ns

    j

    i

    k

  • Cell Indexing

    GlobalLocal

    i+1,ji-1,j i,j

    i,j-1

    i,j+1

    i+2,ji-2,j

    i,j-2

    i,j+2

    EW

    N

    S

    P

    n

    e

    s

    w EEWW

    NN

    SS

  • Generic Scalar-Transport Equation

    ϕ = concentration (amount per unit mass of fluid)

    d

    d𝑡(mass × ϕ) +

    faces

    ( mass flux × ϕ −Γ𝜕ϕ

    𝜕𝑛𝐴 ) = 𝑆

    time derivative advection diffusion source

    V

    A

    u

    un

    TIME DERIVATIVEof amount in 𝑉

    +ADVECTION + DIFFUSIONthrough boundary of 𝑉

    =SOURCEinside 𝑉

  • 1-d Advection-Diffusion Equation

    • Simple analysis

    • Hand solution

    • Straightforward generalisation to 2D/3D

    • Coordinate-wise discretisation in practice

    • Many important theoretical problems

  • Steady 1-d Advection-Diffusion Equation

    flux𝑒 − flux𝑤 = sourceConservation:

    Flux:

    d

    d𝑥(flux) = source per unit length

    d

    d𝑥(ρ𝑢𝐴ϕ − Γ𝐴

    d𝑥) = 𝑠

    Conservative differential equation:

    flux efluxw

    x

    area A

    source

    Source: 𝑠Δ𝑥

    flux = ρ𝑢𝐴 ϕadvection

    −Γ𝐴dϕ

    d𝑥diffusion

  • Discretising Diffusion and Source

  • Example

    A thin rod has length 1 m and cross-section1 cm 1 cm. The left-hand end is kept at 100 C, whilst the right-hand end is insulated.

    The heat flux across any section of area 𝐴 isgiven by

    −𝑘𝐴d𝑇

    d𝑥

    where the conductivity 𝑘 = 1000 Wm−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 Wm−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.

    x = 0 1

    T=100 Co

    RoddTdx

    =0

    T = 20 Co

    s = -c (T-T )

    8

    8

  • −𝑘𝐴d𝑇

    d𝑥𝑒

    − −𝑘𝐴d𝑇

    d𝑥𝑤

    = −𝑐(𝑇 − 𝑇∞)Δ𝑥

    d

    d𝑥( −𝑘𝐴

    d𝑇

    d𝑥) = −𝑐(𝑇 − 𝑇∞)

    flux𝑒 − flux𝑤 = source

    d2𝑇

    d𝑥2−

    𝑐

    𝑘𝐴𝑇 = −

    𝑐

    𝑘𝐴𝑇∞

    d2𝑇

    d𝑥2− 25𝑇 = −500

    𝑇 = 𝐴e5𝑥 + 𝐵e−5𝑥

    complementaryfunction

    + ด20particularintegral

    𝑇(0) = 100, 𝑇′(1) = 0

    𝐴 = 0.0036 , 𝐵 = 79.9964

    Differential Equation and Exact Solution

    flux efluxw source

    −𝑘𝐴d𝑇d𝑥 𝑒

    − −𝑘𝐴d𝑇d𝑥 𝑤

    Δ𝑥= −𝑐(𝑇 − 𝑇∞)

  • Finite-Volume Decomposition

    x = 0.2

    flux = 0T = 100L

    A = 10-4

    1 2 3 4 5R

  • Discretisation of Fluxes

    T TTw eP EW

    flux𝑒 = − ቤ𝑘𝐴d𝑇

    d𝑥𝑒

    −𝑘𝐴𝑇𝐸 − 𝑇𝑃Δ𝑥

    x

    T

    TP

    TE

    x

    e

    T

  • Finite-Volume Discretisation

    Fluxes:

    source = −𝑐(𝑇𝑃 − 𝑇∞)Δ𝑥

    𝑏𝑃 = 𝑐𝑇∞Δ𝑥 = 10 , 𝑠𝑃 = −𝑐Δ𝑥 = −0.5

    Source:

    flux𝑒 − flux𝑤 = sourceConservation:

    flux𝑒 = − ቤ𝑘𝐴d𝑇

    d𝑥𝑒

    interior faces:

    flux𝐿 = − ቤ𝑘𝐴d𝑇

    d𝑥𝐿

    left boundary:

    flux𝑅 = 0right boundary:

    𝐷 =𝑘𝐴

    Δ𝑥= 0.5

    flux efluxw source

    T TTw eP EW

    TPTL

    TPflux = 0R

    → −𝑘𝐴𝑇𝐸 − 𝑇𝑃Δ𝑥

    → −𝐷(𝑇𝐸 − 𝑇𝑃)

    → −𝑘𝐴𝑇𝑃 − 𝑇𝐿12Δ𝑥

    → −2𝐷(𝑇𝑃 − 𝑇𝐿)

    → 𝑏𝑃 + 𝑠𝑃𝑇𝑃

  • Finite-Volume Discretisation

    −0.5(𝑇𝐸 − 𝑇𝑃) + 0.5(𝑇𝑃 − 𝑇𝑊) = 10 − 0.5𝑇𝑃Interior cells:

    −0.5𝑇𝑊 + 1.5𝑇𝑃 − 0.5𝑇𝐸 = 10

    Left boundary: −0.5(𝑇𝐸 − 𝑇𝑃) + 1.0(𝑇𝑃 − 100) = 10 − 0.5𝑇𝑃

    2.0𝑇𝑃 − 0.5𝑇𝐸 = 110

    Right boundary: 0 + 0.5(𝑇𝑃 − 𝑇𝑊) = 10 − 0.5𝑇𝑃

    −0.5𝑇𝑊 + 1.0𝑇𝑃 = 10

    flux𝑒 − flux𝑤 = source flux efluxw source

    T TTw eP EW

  • Assembled Equations

    2 −0.5 0 0 0−0.5 1.5 −0.5 0 00 −0.5 1.5 −0.5 00 0 −0.5 1.5 −0.50 0 0 −0.5 1

    𝑇1𝑇2𝑇3𝑇4𝑇5

    =

    11010101010

    x = 0.2

    flux = 0T = 100L

    A = 10-4

    1 2 3 4 5R

  • 2 −0.5 0 0 0−0.5 1.5 −0.5 0 00 −0.5 1.5 −0.5 00 0 −0.5 1.5 −0.50 0 0 −0.5 1

    𝑇1𝑇2𝑇3𝑇4𝑇5

    =

    11010101010

    All 𝑅 × 2:

    4 −1 0 0 0 ∥ 220−1 3 −1 0 0 ∥ 200 −1 3 −1 0 ∥ 200 0 −1 3 −1 ∥ 200 0 0 −1 2 ∥ 20

    𝑅2 → 4𝑅2 + 𝑅1:

    𝑅3 → 11𝑅3 + 𝑅2:

    4 −1 0 0 0 ∥ 2200 11 −4 0 0 ∥ 3000 −1 3 −1 0 ∥ 200 0 −1 3 −1 ∥ 200 0 0 −1 2 ∥ 20

    4 −1 0 0 0 ∥ 2200 11 −4 0 0 ∥ 3000 0 29 −11 0 ∥ 5200 0 −1 3 −1 ∥ 200 0 0 −1 2 ∥ 20

    𝑅4 → 29𝑅4 + 𝑅3:

    4 −1 0 0 0 ∥ 2200 11 −4 0 0 ∥ 3000 0 29 −11 0 ∥ 5200 0 0 76 −29 ∥ 11000 0 0 −1 2 ∥ 20

    𝑅5 → 76𝑅5 + 𝑅4:

    4 −1 0 0 00 11 −4 0 00 0 29 −11 00 0 0 76 −290 0 0 0 123

    𝑇1𝑇2𝑇3𝑇4𝑇5

    =

    22030052011002620

    𝑇5 =2620

    123= 21.30

    𝑇4 =1100 + 29𝑇5

    76= 22.60

    𝑇3 =520 + 11𝑇4

    29= 26.50

    𝑇2 =300 + 4𝑇3

    11= 36.91

    𝑇1 =220 + 𝑇2

    4= 64.23

  • Points to Note

    • Each control volume gives one equation

    • Each equation is a linear equation connecting the central node and nodes on either side:

    −𝑎𝑤ϕ𝑊 + 𝑎𝑃ϕ𝑃 − 𝑎𝐸ϕ𝐸 = 𝑏𝑃

    • Boundary values are incorporated into the source term

    • The resulting matrix is tri-diagonal = b

  • Discretising Diffusion

    −Γ𝐴 ቤdϕ

    d𝑥𝑒

    → −(Γ𝐴)𝑒ϕ𝐸 −ϕ𝑃

    Δ𝑥

    x

    P

    E

    x

    e

  • Discretising the Source Term

    source = 𝑏𝑃 + 𝑠𝑃ϕ𝑃 𝑠𝑃 ≤ 0

    Examples:

    source = 3 − 2ϕ 𝑏𝑝 = 3, 𝑠𝑝 = −2

    source = 10 − 7ϕ3 𝑏𝑝 = 10, 𝑠𝑝 = −7ϕ∗2

    Solve iteratively

  • Example

    A 2-d finite-volume calculation is to be undertaken for fully-developed,laminar flow between stationary, plane, parallel walls. A streamwisepressure gradient d𝑝/d𝑥 = −𝐺 is imposed and the fluid viscosity is μ. Thedepth of the channel, 𝐻, is divided into 𝑁 equally-sized cells of dimension𝑥 × 𝑦 × 1 as shown, with the velocity 𝑢 stored at cell centres.

    (a) What are the boundary conditions on velocity?

    (b) What is the net pressure force on a single cell?

    (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 𝐻.

    (g) Find the wall shear stress, τ𝑤

    (h) Compare your answers to (e), (f), (g) with the exact solution for plane Poiseuille flow.

    u1

    j-1u

    ju

    j+1u

    Nu

    y

    x

    H

  • u1

    j-1u

    ju

    j+1u

    Nu

    y

    x

    H

    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.

    (a) What are the boundary conditions on velocity?

    (b) What is the net pressure force on a single cell?

    𝑢 = 0 on upper and lower walls

    Net pressure force = 𝑝𝐿 × Δ𝑦 × 1 − 𝑝𝑅 × Δ𝑦 × 1

    = (𝑝𝐿 − 𝑝𝑅) × Δ𝑦

    = −d𝑝

    d𝑥Δ𝑥 Δy = 𝐺Δ𝑥Δ𝑦

    Interior faces: ≈ μ𝑢𝑗+1 − 𝑢𝑗

    Δ𝑦Δ𝑥viscous force on upper face = μ

    d𝑢

    d𝑦× (Δ𝑥 × 1)

    viscous force on lower face ≈ −μ𝑢𝑗 − 𝑢𝑗−1

    Δ𝑦Δ𝑥

    viscous force on upper face of top cell ≈ μ0 − 𝑢𝑗12Δ𝑦

    Δ𝑥

    ≈ −μ𝑢𝑗 − 012Δ𝑦

    Δ𝑥

    Boundary faces:

    viscous force on lower face of bottom cell

    (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 {𝑢𝑗}.

  • u1

    j-1u

    ju

    j+1u

    Nu

    y

    x

    H

    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.

    Interior cell: 𝐺Δ𝑥Δ𝑦 + μ𝑢𝑗+1 − 𝑢𝑗

    Δ𝑦Δ𝑥 − μ

    𝑢𝑗 − 𝑢𝑗−1

    Δ𝑦Δ𝑥 = 0

    𝐺Δ𝑦2

    μ= −𝑢𝑗−1 + 2𝑢𝑗 − 𝑢𝑗+1

    Top cell (𝑗 = 𝑁): 𝐺Δ𝑥Δ𝑦 + μ0 − 𝑢𝑗12Δ𝑦

    Δ𝑥 − μ𝑢𝑗 − 𝑢𝑗−1

    Δ𝑦Δ𝑥 = 0

    𝐺Δ𝑦2

    μ= −𝑢𝑗−1 + 3𝑢𝑗

    Bottom cell (𝑗 = 1): 𝐺Δ𝑥Δ𝑦 + μ𝑢𝑗+1 − 𝑢𝑗

    Δ𝑦Δ𝑥 − μ

    𝑢𝑗 − 012Δ𝑦

    Δ𝑥 = 0

    𝐺Δ𝑦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

  • u1

    j-1u

    ju

    j+1u

    Nu

    y

    x

    H

    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/μ.

    𝑗 = 1: 3𝑢1 − 𝑢2 =1

    36𝑈0

    𝑗 = 2:

    𝑗 = 3:

    −𝑢1 + 2𝑢2 − 𝑢3 =1

    36𝑈0

    −𝑢2 + 2𝑢3 − 𝑢4 =1

    36𝑈0 −𝑢2 + 𝑢3 =

    1

    36𝑈0

    𝑢1 =1

    3(𝑢2 +

    1

    36𝑈0)

    𝑢3 = 𝑢2 +1

    36𝑈0

    2

    3𝑢2 =

    7

    1

    36𝑈0

    𝑢2 =7

    72𝑈0

    𝑢1 = 𝑢6 =3

    72𝑈0 𝑢2 = 𝑢5 =

    7

    72𝑈0 𝑢3 = 𝑢4 =

    9

    72𝑈0

    −1

    3(𝑢2 +

    1

    36𝑈0) + 2𝑢2 − (𝑢2 +

    1

    36𝑈0) =

    1

    36𝑈0

  • u1

    j-1u

    ju

    j+1u

    Nu

    y

    x

    H

    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.

    (g) Find the wall shear stress, τ𝑤

    (f) Using your numerical solution, find the volume flow rate (per unit span) 𝑞 in terms of 𝑈0 and 𝐻.

    𝑢1 = 𝑢6 =3

    72𝑈0 𝑢2 = 𝑢5 =

    7

    72𝑈0 𝑢3 = 𝑢4 =

    9

    72𝑈0

    𝑞 =

    𝑗=1

    6

    𝑢𝑗Δ𝑦 = 2

    𝑗=1

    3

    𝑢𝑗𝐻

    6=𝐻

    3𝑈0(

    3

    72+

    7

    72+

    9

    72) =

    19

    216𝑈0𝐻

    2 × τ𝑤Δ𝑥 = (𝑝𝐿 − 𝑝𝑅)𝐻

    τ𝑤 =1

    2(𝑝𝐿 − 𝑝𝑅Δ𝑥

    )𝐻 =1

    2𝐺𝐻

  • u1

    j-1u

    ju

    j+1u

    Nu

    y

    x

    H

    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.

    Exact solution:𝑢

    𝑈0=1

    2

    𝑦

    𝐻1 −

    𝑦

    𝐻, 𝑈0 =

    𝐺𝐻2

    μ

    𝑢1 = 𝑢6 =3

    72𝑈0 𝑢2 = 𝑢5 =

    7

    72𝑈0 𝑢3 = 𝑢4 =

    9

    72𝑈0

    Nodal values:

    (numerical)

    𝑢1 = 𝑢6 =2.75

    72𝑈0 𝑢2 = 𝑢5 =

    6.75

    72𝑈0 𝑢3 = 𝑢4 =

    8.75

    72𝑈0(exact)

    𝑞 = න0

    𝐻

    𝑢 d𝑦 =18

    216𝑈0𝐻

    (numerical) 𝑞 =19

    216𝑈0𝐻

    Flow rate:

    (exact)

    (numerical)

    Wall stress:

    (exact)

    𝜏𝑤 =1

    2𝐺𝐻

    τ𝑤 = μ ቤ𝜕𝑢

    𝜕𝑦𝑦=0

    𝜏𝑤 =1

    2𝐺𝐻

  • Discretising Advection (Part 1)

  • Example

    A pipe of cross-section 𝐴 = 0.01 m2 and length 𝐿 = 1 m carries water (density ρ =1000 kg m−3) at velocity 𝑢 = 0.1 m s−1.

    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−1s−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 .

    Approximating the downstream boundary condition by dϕ/d𝑥 = 0, set up a finite-volume calculation with 7 cells to estimate the concentration along the pipe using:(a) Central(b) Upwinddifferencing schemes for advection.

    x = 0 L

    pointsource

    u= 0

    = 0d

    dx

  • Fluxes and Sources

    Concentration ϕ (= mass of chemical per mass of water)

    Source

    ‒ point source 𝑆𝑝𝑡 at 𝑥 = 0.5 m

    ‒ loss by chemical breakdown −γϕ per unit length

    Flux (= rate of transport across a surface)

    ‒ diffusion: −Γ𝐴dϕ

    d𝑥

    ‒ advection: 𝐶ϕ 𝐶 = ρ𝑢𝐴 (mass flux)

    x = 0 L

    pointsource

    u= 0

    = 0d

    dx

  • Finite-Volume Decomposition

    loss - per metre

    S = 0.01 kg/spt

    1 2 3 4 5 6 7= 0Ld

    dx

    = 0

  • Finite-Volume Discretisation

    source = ด𝑆ptcell 4

    − 𝛾ϕ𝑃Δ𝑥 source = 𝑏𝑃 + 𝑠𝑃ϕ𝑃 𝑏𝑃 = 0.01 (cell 4)

    𝑠𝑃 = −0.071

    𝐶ϕ𝑒 − 𝐶ϕ𝑤advection

    −𝐷ϕ𝑊 + 2𝐷ϕ𝑃 − 𝐷ϕ𝐸diffusion

    = 𝑏𝑃 + 𝑠𝑃ϕ𝑃source

    An approximation for cell-face values ϕe and ϕw is called an advection scheme or advection-differencing scheme

    flux𝑒 − flux𝑤 = source

    flux𝑒 = 𝐶ϕ𝑒 − 𝐷(ϕ𝐸 − ϕ𝑃)𝐶 = ρ𝑢𝐴 = 1.0

    𝐷 =Γ𝐴

    Δ𝑥= 0.007

    flux = 𝐶ϕ − Γ𝐴dϕ

    d𝑥

    flux𝑤 = 𝐶ϕ𝑤 − 𝐷(ϕ𝑃 − ϕ𝑊)

    w eP EW

  • Central Differencing

    ϕ𝑒 =1

    2(ϕ𝑃 + ϕ𝐸)

    P Ee

    PE

    e

  • Finite-Volume Discretisation:Central Differencing For Advection

    𝐶ϕ𝑒 − 𝐶ϕ𝑤advection

    −𝐷ϕ𝑊 + 2𝐷ϕ𝑃 − 𝐷ϕ𝐸diffusion

    = 𝑏𝑃 + 𝑠𝑃ϕ𝑃source

    Central differencing:

    −(𝐶

    2+ 𝐷)ϕ𝑊 + (2𝐷 − 𝑠𝑃)ϕ𝑃 − (−

    𝐶

    2+ 𝐷)ϕ𝐸 = 𝑏𝑃

    −0.507ϕ𝑊 + 0.085ϕ𝑃 + 0.493ϕ𝐸 = ถ0.01cell 4 only

    𝐶ϕ𝑒 − 𝐶ϕ𝑤 = 𝐶1

    2(ϕ𝑃 + ϕ𝐸) − 𝐶

    1

    2(ϕ𝑊 + ϕ𝑃)

    w eP EW

    =𝐶

    2(ϕ𝐸 − ϕ𝑊)

  • Assembled EquationsCentral Advection Scheme

    0.592 0.493 0 0 0 0 0−0.507 0.085 0.493 0 0 0 0

    0 −0.507 0.085 0.493 0 0 00 0 −0.507 0.085 0.493 0 00 0 0 −0.507 0.085 0.493 00 0 0 0 −0.507 0.085 0.4930 0 0 0 0 −0.507 0.578

    ϕ1ϕ2ϕ3ϕ4ϕ5ϕ6ϕ7

    =

    000

    0.01000

  • Directional Bias

    u

    diffusion only

    advection +diffusion

  • Upwind Differencing

    ϕ𝑒 = ϕ𝑃 (if 𝑢 > 0) (if 𝑢 < 0)ϕ𝑒 = ϕ𝐸

    P E

    e

    PE

    e

    P E

    e

    PEe

  • Upwind Differencing

    Upwind differencing: 𝐶ϕ𝑒 − 𝐶ϕ𝑤 = 𝐶(ϕ𝑃 − ϕ𝑊)

    −(𝐶 + 𝐷)ϕ𝑊 + (𝐶 + 2𝐷 − 𝑠𝑃)ϕ𝑃 − 𝐷ϕ𝐸 = 𝑏𝑃

    −1.007ϕ𝑊 + 1.085ϕ𝑃 − 0.007ϕ𝐸 = ถ0.01cell 4 only

    𝐶ϕ𝑒 − 𝐶ϕ𝑤advection

    −𝐷ϕ𝑊 + 2𝐷ϕ𝑃 − 𝐷ϕ𝐸diffusion

    = 𝑏𝑃 + 𝑠𝑃ϕ𝑃source

    w eP EW

  • 1.092 −0.007 0 0 0 0 0−1.007 1.085 −0.007 0 0 0 0

    0 −1.007 1.085 −0.007 0 0 00 0 −1.007 1.085 −0.007 0 00 0 0 −1.007 1.085 −0.007 00 0 0 0 −1.007 1.085 −0.0070 0 0 0 0 −1.007 1.078

    ϕ1ϕ2ϕ3ϕ4ϕ5ϕ6ϕ7

    =

    000

    0.01000

    Assembled EquationsUpwind Advection Scheme

  • Simple Advection Schemes Compared

    −𝑎𝑊ϕ𝑊 + 𝑎𝑃ϕ𝑃 − 𝑎𝐸ϕ𝐸 = 𝑏𝑃

    (if 𝐶 > 0)

    No “wiggles” Pe ≤ 2

    Pe =𝐶

    𝐷=ρ𝑢Δ𝑥

    ΓPeclet number

    Theoretically, high accuracy ...... but unphysical “wiggles”

    Lower accuracy ...... but no “wiggles”

    Central differencing Upwind differencing

    w eP EW

    𝑎𝑊 =12𝐶 + 𝐷

    𝑎𝐸 = −12𝐶 + 𝐷

    𝑎𝑃 = 2𝐷 − 𝑠𝑃

    𝑎𝑊 = 𝐶 + 𝐷

    𝑎𝐸 = 𝐷

    𝑎𝑃 = 𝐶 + 2𝐷 − 𝑠𝑃

  • Finite-Volume Analysis: 1-d

    flux𝑒 − flux𝑤 = sourceConservation:

    flux = 𝐶ϕ − Γ𝐴dϕ

    d𝑥

    −𝑎𝑊ϕ𝑊 + 𝑎𝑃ϕ𝑃 − 𝑎𝐸ϕ𝐸 = 𝑏𝑃Discretisation:

    Assembled matrix equation:

    AΦ = b

    flux efluxw source

    W EP

    = b

  • Finite-Volume Analysis: 2-d

    flux𝑒 − flux𝑤 + flux𝑛 − flux𝑠 = sourceConservation:

    flux𝑒,𝑤 = (ρ𝑢𝐴ϕ − Γ𝐴𝜕ϕ

    𝜕𝑥)𝑒,𝑤

    flux𝑛,𝑠 = (ρ𝑣𝐴ϕ − Γ𝐴𝜕ϕ

    𝜕𝑦)𝑛,𝑠

    −𝑎𝑆ϕ𝑆 − 𝑎𝑊ϕ𝑊 + 𝑎𝑃ϕ𝑃 − 𝑎𝐸ϕ𝐸 − 𝑎𝑁ϕ𝑁 = 𝑏𝑃Discretisation:

    𝑎𝑃ϕ𝑃 −𝑎𝐹ϕ𝐹 = 𝑏𝑃

    Assembled matrix equation:

    AΦ = b

    fluxefluxw source

    fluxn

    sflux

    PW E

    N

    S

    = b

  • General Discretisation Properties

  • Discretisation Properties

    • Consistency

    • Conservativeness

    • Transportiveness

    • Boundedness

    • Stability

    • Accuracy (“order”)

  • Consistency

    Definition: an algebraic approximation is consistent if it tends to the exact governing equation as the mesh size tends to zero

    ϕ𝐸 −ϕ𝑃Δ𝑥

    →dϕ

    d𝑥e.g.

  • Conservativeness

    Definition: flux out of one cell = flux into adjacent cell

    • Fluxes are worked out by face, not by cell

    • Automatically built into the finite-volume method

    flux

  • Transportiveness

    Definition: upstream-biased

    P E

    e

    PE

    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)

    Requirements for boundedness:

    (1) Positive coefficients:

    (2) Sum of neighbouring coefficients:

    𝑎𝑃, 𝑎𝐹 ≥ 0

    𝑎𝑃ϕ𝑃 −𝑎𝐹ϕ𝐹 = 0

    PW E

    N

    S

    𝑎𝑃 =𝑎𝐹

    If ϕ𝐹 is the only non-zero adjacent value, ϕ𝑃 =𝑎𝐹𝑎𝑃

    ϕ𝐹

    If ϕ is constant. (𝑎𝑃−𝑎𝐹)ϕ = 0

  • Stability

    Definition:

    • Small errors do not grow in the course of the calculation

    source = 𝑏𝑃 + 𝑠𝑃ϕ𝑃, 𝑠𝑃 ≤ 0

    Requirement:

    • Negative-slope linearisation of the source term (“negative feedback”)

  • Summary of Conditions on Matrix Coefficients

    Negative-slope linearisation of the source term:

    𝑠𝑃 ≤ 0

    Positive coefficients:

    𝑎𝐹 ≥ 0 for all 𝐹

    Sum of neighbouring coefficients:

    𝑎𝑃 =𝑎𝐹 − 𝑠𝑃

    𝑎𝑃ϕ𝑃 −𝑎𝐹ϕ𝐹 = 𝑏𝑃

    source = 𝑏𝑃 + 𝑠𝑃ϕ𝑃 PW E

    N

    S

  • Accuracy (“Order”)

    • General definition:

    𝐨𝐫𝐝𝐞𝐫 𝒏 ⇔ error ∝ Δ𝑥 𝑛 as Δ𝑥 → 0

    • Determined by Taylor-series expansion (about a cell face)

    • Common advection schemes:

    ‒ Upwind: 1st order

    ‒ Central: 2nd order

    ‒ LUD: 2nd order

    ‒ QUICK: 3rd order

    P Ee

    x

  • Order of AccuracyP Ee

    x

    ϕ𝐸 = ϕ𝑒 +dϕ

    d𝑥𝑒

    Δ𝑥

    2+

    1

    2!

    d2ϕ

    d𝑥2𝑒

    Δ𝑥

    2

    2

    +1

    3!

    d3ϕ

    d𝑥3𝑒

    Δ𝑥

    2

    3

    +1

    4!

    d4ϕ

    d𝑥4𝑒

    Δ𝑥

    2

    4

    + ⋯

    ϕ𝐸 − ϕ𝑃 = 0 +dϕ

    d𝑥𝑒

    Δ𝑥 + 0 +2

    3!

    d3ϕ

    d𝑥3𝑒

    (Δ𝑥

    2)3 + ⋯

    Subtract:ϕ𝐸 − ϕ𝑃

    Δ𝑥=

    d𝑥𝑒

    + O(Δ𝑥2)

    Add:

    ϕ𝑃 + ϕ𝐸 = 2ϕ𝑒 + 0 +d2ϕ

    d𝑥2𝑒

    (Δ𝑥

    2)2 + ⋯ 1

    2(ϕ𝑃 + ϕ𝐸) = ϕ𝑒 + O(Δ𝑥2)

    2nd-order central differencing for diffusion

    2nd-order central differencing for advection

    ϕ𝑃 = ϕ𝑒 −dϕ

    d𝑥𝑒

    Δ𝑥

    2+

    1

    2!

    d2ϕ

    d𝑥2𝑒

    Δ𝑥

    2

    2

    −1

    3!

    d3ϕ

    d𝑥3𝑒

    Δ𝑥

    2

    3

    +1

    4!

    d4ϕ

    d𝑥4𝑒

    Δ𝑥

    2

    4

    + ⋯

    First term:

    ϕ𝑃 = ϕ𝑒 −dϕ

    d𝑥𝑒

    Δ𝑥

    2+ ⋯ ϕ𝑃 = ϕ𝑒 + O(Δ𝑥)

    1st-order upwind differencing for advection

  • Example

    Consider the uniform, one-dimensional arrangement of nodes shown. Face e lies half way between P and E nodes.

    (a) Show that the central-differencing schemes

    are second-order approximations for ϕ𝑒 and dϕ/d𝑥 𝑒respectively.

    (b) Making use of the W and EE nodes also, find symmetric fourth-order approximations for ϕ𝑒 and dϕ/d𝑥 𝑒.

    ϕ𝑒 ≈1

    2(ϕ𝑃 + ϕ𝐸) ቤ

    d𝑥𝑒

    ≈ϕ𝐸 −ϕ𝑃

    Δ𝑥

    W EP EEe

    x

    3 x

  • (b) Making use of the W and EE nodes also, find symmetric fourth-order approximations for ϕ𝑒 and dϕ/d𝑥 𝑒.

    W EP EEe

    x

    3 x

    ϕ𝐸 = ϕ𝑒 +dϕ

    d𝑥𝑒

    Δ𝑥

    2+

    1

    2!

    d2ϕ

    d𝑥2𝑒

    (Δ𝑥

    2)2 +

    1

    3!

    d3ϕ

    d𝑥3𝑒

    (Δ𝑥

    2)3 +

    1

    4!

    d4ϕ

    d𝑥4𝑒

    (Δ𝑥

    2)4 + ⋯

    ϕ𝑃 = ϕ𝑒 −dϕ

    d𝑥𝑒

    Δ𝑥

    2+

    1

    2!

    d2ϕ

    d𝑥2𝑒

    (Δ𝑥

    2)2 −

    1

    3!

    d3ϕ

    d𝑥3𝑒

    (Δ𝑥

    2)3 +

    1

    4!

    d4ϕ

    d𝑥4𝑒

    (Δ𝑥

    2)4 + ⋯

    Add:

    ϕ𝑃 + ϕ𝐸 = 2ϕ𝑒 + 0 +2

    2!

    d2ϕ

    d𝑥2𝑒

    (Δ𝑥

    2)2 + 0 +

    d4ϕ

    d𝑥4𝑒

    (Δ𝑥

    2)4 +⋯

    ϕ𝑃 + ϕ𝐸2

    = ϕ𝑒 +1

    2!

    d2ϕ

    d𝑥2𝑒

    (Δ𝑥

    2)2 + O(Δ𝑥)4

    ϕ𝑊 + ϕ𝐸𝐸2

    = ϕ𝑒 +1

    2!

    d2ϕ

    d𝑥2𝑒

    (3Δ𝑥

    2)2 + O(Δ𝑥)4

    αϕ𝑃 + ϕ𝐸

    2+ β

    ϕ𝑊 + ϕ𝐸𝐸2

    = (α + β)ϕ𝑒 + (α + 9β)1

    2

    d2ϕ

    d𝑥2𝑒

    (Δ𝑥

    2)2 + O(Δ𝑥)4

    Require α + β = 1

    α + 9β = 0

    8β = −1

    β = −1

    8α =

    9

    8

    9

    8

    ϕ𝑃 + ϕ𝐸2

    −1

    8

    ϕ𝑊 + ϕ𝐸𝐸2

    = ϕ𝑒 + O(Δ𝑥)4

  • (b) Making use of the W and EE nodes also, find symmetric fourth-order approximations for ϕ𝑒 and dϕ/d𝑥 𝑒.

    W EP EEe

    x

    3 x

    ϕ𝐸 = ϕ𝑒 +dϕ

    d𝑥𝑒

    Δ𝑥

    2+

    1

    2!

    d2ϕ

    d𝑥2𝑒

    (Δ𝑥

    2)2 +

    1

    3!

    d3ϕ

    d𝑥3𝑒

    (Δ𝑥

    2)3 +

    1

    4!

    d4ϕ

    d𝑥4𝑒

    (Δ𝑥

    2)4 + ⋯

    ϕ𝑃 = ϕ𝑒 −dϕ

    d𝑥𝑒

    Δ𝑥

    2+

    1

    2!

    d2ϕ

    d𝑥2𝑒

    (Δ𝑥

    2)2 −

    1

    3!

    d3ϕ

    d𝑥3𝑒

    (Δ𝑥

    2)3 +

    1

    4!

    d4ϕ

    d𝑥4𝑒

    (Δ𝑥

    2)4 + ⋯

    Subtract:

    ϕ𝐸 − ϕ𝑃Δ𝑥

    =dϕ

    d𝑥𝑒

    +1

    3!

    d3ϕ

    d𝑥3𝑒

    (Δ𝑥

    2)2 + O(Δ𝑥)4

    αϕ𝐸 − ϕ𝑃

    Δ𝑥+ β

    ϕ𝐸𝐸 − ϕ𝑊3Δ𝑥

    = (α + β)dϕ

    d𝑥𝑒

    + (α + 9β)1

    3!

    d3ϕ

    d𝑥3𝑒

    (Δ𝑥

    2)2 + O(Δ𝑥)4

    Require α + β = 1

    α + 9β = 0

    8β = −1

    β = −1

    8α =

    9

    8

    9

    8

    ϕ𝐸 − ϕ𝑃Δ𝑥

    −1

    8

    ϕ𝐸𝐸 − ϕ𝑊3Δ𝑥

    =dϕ

    d𝑥𝑒

    + O(Δ𝑥)4

    ϕ𝐸 − ϕ𝑃 = 0 +dϕ

    d𝑥𝑒

    Δ𝑥 + 0 +2

    3!

    d3ϕ

    d𝑥3𝑒

    (Δ𝑥

    2)3 + 0 +

    2

    5!

    d5ϕ

    d𝑥5𝑒

    (Δ𝑥

    2)5 + ⋯

    ϕ𝐸𝐸 − ϕ𝑊3Δ𝑥

    =dϕ

    d𝑥𝑒

    +1

    3!

    d3ϕ

    d𝑥3𝑒

    (3Δ𝑥

    2)2 + O(Δ𝑥)4

  • Discretising Advection (Part 2)

  • Exponential Scheme

    Exact solution of the 1-d advection-diffusion equation

    flux = 𝐶ϕ − Γ𝐴dϕ

    d𝑥= constant

    flux𝑒 = 𝐶ePeϕ𝑃 − ϕ𝐸

    ePe − 1𝐶 = ρ𝑢𝐴, 𝐷 =

    Γ𝐴

    Δ𝑥, Pe =

    𝐶

    𝐷

    flux𝑒 − flux𝑤 = 𝑎𝑃ϕ𝑃 −𝑎𝐹ϕ𝐹

    𝑎𝑊 =𝐶ePe

    ePe − 1, 𝑎𝐸 =

    𝐶

    ePe − 1

    𝑎𝑃 = 𝑎𝐸 + 𝑎𝑊

    (with constant coefficients and without sources)

    P Ee

  • LUD (Linear Upwind Differencing)

    • Extrapolates from the two upwind nodes

    • 2nd-order accurate

    • Transportive, but not bounded

    • Generalises to unstructured meshes:

    UU U D

    faceW P E

    P E EE

    e

    W

    P

    e

    E

    P

    e

    E

    EE

    u > 0

    u < 0

    e

    ϕface = ϕ𝑈 +1

    2(ϕ𝑈 − ϕ𝑈𝑈)

    ϕface =3

    2ϕ𝑈 −

    1

    2ϕ𝑈𝑈

    ϕface = ϕ𝑈 + (xface − x𝑈) • (∇ϕ)𝑈

  • • 3-point, upwind-biased scheme

    • Fits a quadratic through 3 nodes

    • 3rd-order accurate

    • Transportive, but not bounded

    QUICK

    W P E

    P E EE

    e

    W

    P

    e

    E

    P

    e

    E

    EE

    u > 0

    u < 0

    e

    UU U D

    face

    ϕface = −18ϕ𝑈𝑈 +

    34ϕ𝑈 +

    38ϕ𝐷

  • ● 3-point, upwind-biased schemes; solution-dependent limiters

    ● General form:

    ● Non-linear ( iteration necessary)

    ● Total-Variation-Diminishing

    Flux-Limited Schemes

    ϕface = function(ϕ𝑈𝑈, ϕ𝑈 , ϕ𝐷)

    ϕface = ቐϕ𝑈 +

    1

    2𝜓(𝑟)(ϕ𝐷 − ϕ𝑈) if monotonic

    ϕ𝑈 otherwise

    𝑟 =ϕ𝑈 − ϕ𝑈𝑈ϕ𝐷 − ϕ𝑈

    UU U D

    face

    UU U D

    monotonic

    non-monotonic

    UU U D

  • Scheme 𝛙(𝒓) (for 𝒓 > 𝟎)

    UMISTUpstream Monotonic Interpolationfor Scalar Transport (Lien andLeschziner, 1993)

    Harmonic Van Leer (1974)

    Min-mod Roe (1985)

    Van Albada et al. Van Albada et al., (1982)

    min{ 2, 2𝑟, 141 + 3𝑟 ,

    1

    4(3 + 𝑟)}

    2𝑟

    1 + 𝑟

    min{ 𝑟, 1}

    𝑟 + 𝑟2

    1 + 𝑟2

    In all cases ψ 𝑟 is taken as 0 if non-monotonic (𝑟 < 0)

  • Example

    The figure shows a single line of cells in a structured mesh. The values of a transported scalar ϕ at cell-centre nodes are given below the figure.

    The Van Leer harmonic advection scheme is defined (for the immediate upstream and downstream nodes, U and D respectively) by:

    ϕface = ϕ𝑈 +1

    2ψ(𝑟)(ϕ𝐷 − ϕ𝑈)

    ψ(𝑟) = ቐ2𝑟

    1 + 𝑟if 𝑟 > 0

    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.

    P E EEWWW

    ew

    x

    𝑟 =ϕ𝑈 − ϕ𝑈𝑈ϕ𝐷 − ϕ𝑈

    ϕ𝑊𝑊 = 1, ϕ𝑊= 4, ϕ𝑃= 5, ϕ𝐸= 7, ϕ𝐸𝐸= 3

  • 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.

    P E EEWWW

    ew

    x

    𝑟 =ϕ𝑈 − ϕ𝑈𝑈ϕ𝐷 − ϕ𝑈

    ϕ𝑊𝑊 = 1, ϕ𝑊= 4, ϕ𝑃= 5, ϕ𝐸= 7, ϕ𝐸𝐸= 3

    ϕface = ϕ𝑈 +1

    2ψ(𝑟)(ϕ𝐷 − ϕ𝑈)

    ψ(𝑟) = ቐ2𝑟

    1 + 𝑟if 𝑟 > 0

    0 otherwise

    𝑢 positive

    w: ϕ𝑈𝑈 = 1, ϕ𝑈 = 4, ϕ𝐷 = 5

    𝑟 =4 − 1

    5 − 4= 3

    ψ =2 × 3

    1 + 3=3

    2

    ϕ𝑓 = 4 +1

    2×3

    2(5 − 4) = 4.75

    e: ϕ𝑈𝑈 = 4, ϕ𝑈 = 5, ϕ𝐷 = 7

    𝑟 =5 − 4

    7 − 5=1

    2

    ψ =2 × (1/2)

    1 + (1/2)=2

    3

    ϕ𝑓 = 5 +1

    2×2

    3(7 − 5) = 5.667

    𝑢 negative

    w: ϕ𝑈𝑈 = 7, ϕ𝑈 = 5, ϕ𝐷 = 4

    𝑟 =5 − 7

    4 − 5= 2

    ψ =2 × 2

    1 + 2=4

    3

    ϕ𝑓 = 5 +1

    2×4

    3(4 − 5) = 4.333

    e: ϕ𝑈𝑈 = 3, ϕ𝑈 = 7, ϕ𝐷 = 5

    ϕ𝑓 = ϕ𝑈 = 7

    Non-monotonic

  • Implementation of Higher-Order Schemes

    The deferred correction is transferred to the source term and treated explicitly(i.e. not updated until the next iteration):

    Write the cell-face value as upwind + correction: ϕ𝑓 = ถϕ𝑈upwind

    + (ϕ𝑓 − ϕ𝑈)

    deferred correction

    faces

    ( mass flux × ϕ −Γ𝜕ϕ

    𝜕𝑛𝐴 ) = 𝑆

    advection diffusion source

    faces

    [𝐶𝑓ϕ𝑓 + 𝐷𝑓(ϕ𝑃 − ϕ𝐹)] = 𝑏𝑃 + 𝑠𝑃ϕ𝑃

    faces

    [𝐶𝑓(ϕ𝑓 − ϕ𝑃) + 𝐷𝑓(ϕ𝑃 − ϕ𝐹)] = 𝑏𝑃 + 𝑠𝑃ϕ𝑃

    𝐶𝑓(ϕ𝑓 − ϕ𝑃) = 𝐶𝑓(ϕ𝑈 − ϕ𝑃)

    upwind

    +𝐶𝑓(ϕ𝑓 − ϕ𝑈)

    correction

    = max( − 𝐶𝑓 , 0)(ϕ𝑃 − ϕ𝐹) +𝐶𝑓(ϕ𝑓 − ϕ𝑈)

    𝑎𝐹 = max( − 𝐶𝑓 , 0) + 𝐷𝑓

    𝐹

    𝑎𝐹(ϕ𝑃 − ϕ𝐹) = 𝑏𝑃 + 𝑠𝑃ϕ𝑃−

    faces

    𝐶𝑓(ϕ𝑓 − ϕ𝑈)

    deferred correction

    The upwind part always gives positive coefficients and diagonal dominance

    faces

    𝐶𝑓 = 0

    P Ff

  • Implementation of Boundary Conditions

    Boundary fluxes are transferred to the source term:

    notboundary

    flux + fluxboundary = source

    𝑎𝑃ϕ𝑃 −

    notboundary

    𝑎𝐹ϕ𝐹 = 𝑏𝑃 − fluxboundary

    2 3 4 NI-1NI-2NI-3

    boundary

    boundary

    P B

    boundary

  • Matrix Solution Algorithms

  • Form of the Matrix Equations

    𝑎𝑃ϕ𝑃 −

    𝐹

    𝑎𝐹ϕ𝐹 = 𝑏𝑃

    1-d

    −𝑎𝑊ϕ𝑊 + 𝑎𝑃ϕ𝑃 − 𝑎𝐸ϕ𝐸 = 𝑏𝑃

    2-d

    −𝑎𝑆ϕ𝑆 − 𝑎𝑊ϕ𝑊 + 𝑎𝑃ϕ𝑃 − 𝑎𝐸ϕ𝐸 − 𝑎𝑁ϕ𝑁 = 𝑏𝑃

    W EP PW E

    N

    S

    = 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

    • Direct, not iterative

    • Sequence of row operations aiming to produce an upper-triangular matrix

    • Tends to “fill in” sparse matrices

    • Important exception: tri-diagonal systems(basis of the tri-diagonal matrix algorithm) = b

  • Gauss-Seidel

    𝛟𝑷 =1

    𝑎𝑃(𝑏𝑃 + 𝑎𝑆ϕ𝑆

    ∗ + 𝑎𝑊ϕ𝑊∗ + 𝑎𝐸ϕ𝐸

    ∗ + 𝑎𝑁ϕ𝑁∗ )

    −𝑎𝑆ϕ𝑆 − 𝑎𝑊ϕ𝑊 + 𝒂𝑷𝛟𝑷 − 𝑎𝐸ϕ𝐸 − 𝑎𝑁ϕ𝑁 = 𝑏𝑃

    P

    N

    S

    W E

    direction of sweep

    being updated

    already updated

    not yet updated

  • Gauss-Seidel Example (i)

    4 −1 0 0−1 4 −1 00 −1 4 −10 0 −1 4

    𝐴𝐵𝐶𝐷

    =

    24613

  • 4 −1 0 0−1 4 −1 00 −1 4 −10 0 −1 4

    𝐴𝐵𝐶𝐷

    =

    24613

    4𝐴 − 𝐵 = 2

    −𝐴 + 4𝐵 − 𝐶 = 4

    −𝐵 + 4𝐶 − 𝐷 = 6

    −𝐶 + 4𝐷 = 13

    𝐴 =2 + 𝐵

    4

    𝐵 =4 + 𝐴 + 𝐶

    4

    𝐶 =6 + 𝐵 + 𝐷

    4

    𝐷 =13 + 𝐶

    4

    A B C D

    0 0 0 0

    0.500 1.125 1.781 3.695

    0.781 1.641 2.834 3.959

    0.910 1.936 2.974 3.994

    --- --- --- ---

    1.000 2.000 3.000 4.000

  • Gauss-Seidel Example (ii)

    1 −4 0 0−4 1 −4 00 −4 1 −40 0 −4 1

    𝐴𝐵𝐶𝐷

    =

    −7−14−21−8

    DIVERGES!

  • Gauss-Seidel Overview

    • Iterative

    • Simple to code

    • Minimal storage requirements

    • Can use for unstructured meshes

    • Convergence slow for large matrices

    • Constraints on matrix elements (e.g. diagonal dominance)

    𝑎𝑖𝑖 ≥

    𝑗≠𝑖

    𝑎𝑖𝑗

  • Line Gauss-Seidel(Line-Iterative Procedures, LIP)

    −𝒂𝑾𝛟𝑾 + 𝒂𝑷𝛟𝑷 − 𝒂𝑬𝛟𝑬 = 𝑏𝑃 + 𝑎𝑆ϕ𝑆∗ + 𝑎𝑁ϕ𝑁

    −𝑎𝑆ϕ𝑆 − 𝒂𝑾𝛟𝑾 + 𝒂𝑷𝛟𝑷 − 𝒂𝑬𝛟𝑬 − 𝑎𝑁ϕ𝑁 = 𝑏𝑃

    = b - *

    PW E

    S

    N

    direct

    ion

    of sw

    eep

  • Line Gauss-Seidel - Overview

    • Iterative

    • Repeated use of tri-diagonal solver:

    ‒ whole line updated in one go

    ‒ rapid propagation across domain

    • Applicable to structured meshes only

    • Basis of many research codes

  • Convergence Criteria

    res = 𝑎𝑃ϕ𝑃 −

    𝐹

    𝑎𝐹ϕ𝐹 − 𝑏𝑃

    Single-cell error:

    residual:

    cells

    res

    1

    𝑁

    cells

    (res)2

    sum of absolute residuals:

    root-mean-square error:

    Global error:

    Convergence criteria:

    error < toleranceor

    error < fraction of initial error

    𝑎𝑃ϕ𝑃 −

    𝐹

    𝑎𝐹ϕ𝐹 = 𝑏𝑃

  • Under-Relaxation

    • The governing equations are coupled and non-linear

    • The iterative solution method may be numerically unstable

    • Under-relaxation tries to stabilise an iterative procedure by reducing the change in variables at each iteration

  • Under-Relaxation in CFD

    𝑎𝑃ϕ𝑃 −𝑎𝐹ϕ𝐹 = 𝑏𝑃Standard linearised equation:

    ϕ𝑃 =σ𝑎𝐹ϕ𝐹 + 𝑏𝑃

    𝑎𝑃Rearrange as the change in ϕ:

    ϕ𝑃 = ϕ𝑃prev

    +σ𝑎𝐹ϕ𝐹 + 𝑏𝑃

    𝑎𝑃− ϕ𝑃

    prev

    ϕ𝑃 = ϕ𝑃prev

    + ασ𝑎𝐹ϕ𝐹 + 𝑏𝑃

    𝑎𝑃− ϕ𝑃

    prevUnder-relax the change:

    Rearrange back: 𝑎𝑃ϕ𝑃 −α𝑎𝐹ϕ𝐹 = α𝑏𝑃 + (1 − α)𝑎𝑃ϕ𝑃prev

    Incorporate by modifying coefficients: 𝑎𝑃 → 𝑎𝑃′ =

    𝑎𝑃α

    𝑏𝑃 → 𝑏𝑃′ = 𝑏𝑃 + (1 − α)𝑎𝑃

    ′ ϕ𝑃prev

    𝑎𝑃𝛼ϕ𝑃 −𝑎𝐹ϕ𝐹 = 𝑏𝑃 + (1 − α)

    𝑎𝑃𝛼ϕ𝑃prev

  • • The generic scalar-transport equation for a control volume has the formrate of change + net outward flux = source

    • Flux ≡ rate of transport through a surface and consists of:

    ‒ advection: transport with the flow (other authors prefer convection)

    ‒ diffusion: net transport by random molecular or turbulent fluctuations

    • Discretisation of the (steady) scalar-transport equation yields a linear equation

    𝑎𝑃ϕ𝑃 −

    𝐹

    𝑎𝐹ϕ𝐹 = 𝑏𝑃

    for each control volume.

    • The collection of these simultaneous equations on a structured mesh yields a matrix equation with limited bandwidth (i.e. few non-zero diagonals), typically solved by iterative methods such as Gauss-Seidel or line-Gauss-Seidel

    Summary (1)

  • Summary (2)

    • Source terms are linearised as

    𝑏𝑃 + 𝑠𝑃ϕ𝑃 , 𝑠𝑃 ≤ 0

    • Diffusive fluxes are usually discretised by central differencing; e.g.

    −Γ ቤ𝜕ϕ

    𝜕𝑥𝑒

    𝐴 → −Γ𝐴

    Δ𝑥(ϕ𝐸 − ϕ𝑃)

    • Advection schemes are means of approximating ϕ on cell faces in order to compute advective fluxes. They include Upwind, Central, Exponential, LUD, QUICK, and various flux-limited schemes

    • General desirable properties for a numerical scheme in CFD:

    ‒ consistency

    ‒ conservativeness

    ‒ transportiveness

    ‒ boundedness

    ‒ stability

    ‒ accuracy / order

  • ● Boundedness and stability impose certain constraints:

    𝑎𝐹 ≥ 0 (“positive coefficients”)

    𝑠𝑃 ≤ 0 (“negative feedback in the source term”)

    𝑎𝑃 = σ𝑎𝐹 − 𝑠𝑃 (“sum of the neighbouring coefficients”)

    ● To ensure positive coefficients (and implement non-linear schemes), advectivefluxes are often decomposed into

    upwind + deferred correction

    The latter is transferred to the source and treated explicitly

    ● Boundary conditions can be implemented by transferring boundary fluxes to the source term

    ● Under-relaxation is usually required to solve coupled and/or non-linear equations

    Summary (3)