Attribution Non-Commercial (BY-NC)

157 views

Attribution Non-Commercial (BY-NC)

- Application of the Shrinking Core Model for Copper Oxide Leaching
- cfd2
- cfd3
- cfd5
- cfd6
- LinAlg_Complete
- cfd7
- introcfd
- Ficks First Law
- Maths 2 Iit Kanpur Peeyush Chandra, A. K. Lal, V. Raghavendra, G. Santhanam
- HW Questions Midterm
- LinAlg Complete
- Iterative Techniques in Matrix Algebra
- LinAlg Complete
- LinAlg Complete
- CFD
- LinAlg Complete
- LinAlg Complete
- Linear Alg Complete
- Gaussian LU Eliminations Seidel

You are on page 1of 32

4.2 Control-volume notation

4.3 The steady-state 1-d advection-diffusion equation

4.4 Discretising diffusion

4.5 Discretising the source term

4.6 Assembling the algebraic equations

4.7 Extension to 2 and 3 dimensions

4.8 Discretising advection (part 1)

4.9 Discretisation properties

4.10 Discretising advection (part 2)

4.11 Implementation of advanced advection schemes

4.12 Implementation of boundary conditions

4.13 Solution of the algebraic equations

Summary

Examples

This is a generic equation for transported physical quantities (momentum, energy,...) For an

arbitrary control volume V:

RATE OF CHANGE + FLUX = SOURCE

inside V out of boundary inside V

The total flux comprises advection (transport with the flow) and diffusion (molecular, or due

to turbulent fluctuations). The resulting advection-diffusion equation for concentration φ may

be written, for each computational control volume (or “cell”) as: u

d ∂φ

( Vφ) + ∑( Cφ − A ) = SV V un

dt faces ∂n

rate of change advection diffusion source A

the source term.)

cell-centred cell-vertex

This course focuses on structured meshes using cell-centred storage. (Unstructured meshes

will be discussed briefly at the end of the course, but the 2nd edition of Versteeg and

Malalasekera’s book gives a much better description.)

to the cell centre (point P) the coordinate directions

are commonly denoted west, east, south, north,

bottom, top with: t

• lower case w, e, s, n, b, t used for cell faces; N

• upper case W, E, S, N, B, T for adjacent nodes. W w

n

For a Cartesian mesh these would usually correspond s P e

to ±x, ±y, ±z directions respectively. E

S

b

Cell-face areas will be denoted Aw, Ae, As, An, Ab, At. k

Cell volumes will be denoted V. In 2 dimensions one

j

can think of a single layer of cells with unit depth. B

i

When referring to the entire set of control volumes (as opposed to looking at a representative

one) it is common to switch between geographic and ijk notation, so that

φP ≡ φijk, φE ≡ φi+1 jk , etc.

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

j i,j-2

SS

i

4.3 The Steady-State 1-D Advection-Diffusion Equation

Consider first the steady-state, 1-d advection-diffusion equation. This is worthwhile because:

• it greatly simplifies the analysis;

• it permits a hand solution of the discretised equations;

• subsequent generalisation to 2 and 3 dimensions is straightforward;

• in practice, discretisation of fluxes is generally carried out coordinate-wise;

• many important theoretical problems are 1-d.

area A

fluxe − flux w = source (1)

where “flux” means the rate of transport through a cell face.

flux w source flux e

If φ is the amount per unit mass, then the total flux has

advective and diffusive parts: ∆ x

advection: ( uA)φ

dφ

diffusion: − A

dx

If S is the source per unit length then the advection-diffusion equation for φ is

dφ dφ

uAφ − A − uAφ − A = S x (2)

dx e dx w

d dφ

( uAφ − A ) = S (3)

dx dx

Mass conservation implies that uA = constant and hence (3) can also be written

dφ d dφ

uA − ( A ) = S (4)

dx dx dx

Note:

• This system is quasi-1-d in the sense that the cross-sectional area A may vary. To

solve a truly 1-d problem, set A = 1. The differential equation is then

d dφ

( uφ − )=S

dx dx

• In this instance, , u, and S are assumed to be known. In the general CFD problem,

u is itself the subject of a separate transport equation.

4.4 Discretising Diffusion

Classroom Example 1

o o

T=100 C T=500 C

Rod

x= 0 1

temperatures fixed at 100 ºC and 500 ºC as shown. The heat flux across any section of area

A is given by

dT

− kA

dx

where the conductivity k = 1000 W m–1 K–1.

(a) 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.

(b) Write down a differential equation for the temperature distribution along the rod. Solve

analytically and compare with (a).

dφ φ − φP

W w P e E

− A → − ( A) e E (5)

∆x

dx e x

or

dφ A

− A → − De (φ E − φ P ) where D≡ (6)

dx e x

D is a diffusive transfer coefficient

dφ

− A → − D w ( φ P − φW )

dx w

Note:

• In the finite-volume method, fluxes are required at cell faces, not nodes.

• This approximation for (dφ/dx)e is second-order accurate in x (see later).

• If the diffusivity varies then its cell-face value must be obtained by interpolation.

• Equal weighting is applied to the two nodes on either side of the cell face, consistent

with diffusion acting equally in all directions. Later on, we shall see that this contrasts

with advection, which has a directional bias.

4.5 Discretising the Source Term

Classroom Example 2

o

Too=20 C

o

T=100 C

dT

Rod dx =0

0 S=-c(T-Too) 1

The rod configuration is now changed such that the right-hand temperature is no longer fixed

and the rod is allowed to cool along its length at a rate proportional to its difference from the

ambient temperature (Newton’s law of cooling); i.e. the heat loss per unit length is:

S = −c(T − T∞ )

where the ambient temperature T = 20 ºC and the coefficient c = 2.5 W m–1 K–1.

When the source is proportional to the amount of fluid, the total source strength for the cell is

(source per unit volume) × (volume)

= S ×V

(In 1-d problems V is the cell length, x).

S may depend on the solution φ as in the example above. The source term is conveniently

broken down into solution-independent and solution-dependent parts in the linear form

source = bP + s P φ P , sP ≤ 0

(7)

The reason for this particular form will become apparent later.

As seen in the above classroom examples, when there is no flow (u = 0) the steady-state

diffusion problem discretises as follows.

flux e − flux w = source

− De (φ E − φ P ) + D w (φ P − φW ) = b P + s P φ p

or, collecting multiples of φP, φE and φW together:

− Dw φW + ( Dw + De − s p )φ P − De φ E = bP

− a w φW + a P φ P − a E φ E = b P

or, in a notation that generalises to 2 and 3 dimensions (and to the case with flow):

a P φ P − ∑ a F φ F = bP (8)

adjacent

nodes

(8) is a canonical form for the discretised scalar-transport equation.

There will be a discretised equation of this form for each variable and for each control

volume. For one variable φ, if the nodal values are assembled into a vector then the set of

algebraic equations takes the form

O O 0 M M

O O O M M

− aW a P − a E φ = b

P P

O O O M M

or

Φ b

0 O O M M

For a 1-d system this is tri-diagonal. If the coefficients are constants then it can be solved

directly by Gaussian elimination or very efficiently on a computer by the tri-diagonal matrix

algorithm (see the Appendix). If the elements of the matrix are dependent on the solution

then it must be solved iteratively.

flux n

For a multi-dimensional flow the net flux out of a cell can be

obtained by summing the outward fluxes through all faces.

flux w source flux e

For quadrilateral elements (in 2d) or hexahedral elements (in

3d) then the net flux out of a cell is simply the sum of the net

fluxes through opposing sides and the general conservation flux s

equation may be written:

( flux e − flux w ) + ( flux n − flux s ) + ( fluxt − fluxb ) = source (9)

The discretised equations are still assembled in the same matrix form

a P φ P − ∑ a F φ F = bP (10)

F

with the summation extended to include nodes in the other directions.

volumes gives a matrix equation for the set of nodal values. In

two dimensions this gives the banded matrix system shown.

Φ b

Further bands appear in three dimensions.

Thus, (8) or (10) has the same form in 1-, 2- or 3-d problems, but in multiple dimensions the

summation is extended to the other (S, N, B, T) nodes and there is a corresponding increase in

the number of non-zero diagonals in the assembled matrix equation. This makes the matrix

equation much harder to solve (see Section 4.13).

Equation (10) formally describes the discretisation for a single control volume in an

unstructured mesh. However, since the nodes do not have a simple ijk indexing, the resulting

matrix and solution method for unstructured meshes are much more complex.

4.8 Discretising Advection (Part 1)

Purely diffusive problems (u = 0) are of passing interest only. In typical engineering flow

problems, advection fluxes far exceed diffusive fluxes because the Reynolds number

(Re UL/ = ratio of inertial forces [mass × acceleration] to viscous forces) is very large.

fluxe − flux w = source

where, with mass flux C (= uA): W w P e E

dφ

flux = Cφ − A

dx

.

Discretising the diffusion and source terms as before, the equation becomes

[C e φ e − C w φ w ] − [ De (φ E − φ P ) − Dw (φ P − φW )] = bP + s P φ P

(11)

advection diffusion source

φe and φw have yet to be approximated. The problem is … how to approximate these face

values in terms of the values at adjacent nodes. A method of specifying these face values in

order to calculate advective fluxes is called an advection scheme or advection-differencing

scheme.

Classroom Example 3.

φ=0 u dφ

dx =0

x= 0 L

point

source

= 1000 kg m–3) at velocity u = 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–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.

calculation with 7 cells to estimate the concentration along the pipe using:

(a) Central

(b) Upwind

differencing schemes for advection.

φP

φe

4.8.1 Central Differencing

φE

In central differencing the cell-face value is approximated by

the average of values at the nodes on either side: P E

φ e = 12 (φ P + φ E ) e

This is second-order accurate for φe in terms of ∆x (see later).

Substituting into (11) (with a similar expression for φw) gives

2 C e (φ P + φ E ) − 2 C w (φW + φ P ) − De (φ E − φ P ) + Dw (φ P − φW ) = bP + s P φ P

1 1

− ( 12 C w + Dw )φW + ( 12 C e − 12 C w + De + Dw − s P )φ P − (− 12 C e + De )φ E = bP

a P φ P − ∑ a F φ F = bP

F

where, in one dimension:

aW = 12 C w + Dw

a E = − 12 C e + De (12)

a P = a E + aW − s P + (C e − C w )

(By mass conservation, Ce – Cw = 0, so that the expression for aP can be simplified.)

The graphs below show the solution of an advection-diffusion problem with no sources and

constant diffusivity for the two combinations

Pe = 1/2 (advection « diffusion) (equation: − 54 φW + 2φ P − 34 φ E = 0 )

Pe = 4 (advection » diffusion) (equation: − 3φW + 2φ P + φ E = 0 )

where the Peclet number Pe is defined by

C advection u x

Pe = i.e. = (13)

D diffusion

Pe = 1/2 Pe = 4

In the first case the solution is good (consistent with second-order accuracy).

In the second case there are pronounced “wiggles” in what should be a perfectly smooth

solution. What is wrong?

Mathematically, when the cell Peclet number Pe is

bigger than 2, the aE coefficient becomes negative,

meaning that, for example, an increase in φE would diffusion only

lead to a decrease in φP. This is impossible for a

quantity that is simply advected and diffused.

transports properties only in the direction of the flow. u advection

+

However, the central-differencing formula assigns diffusion

equal weight to both upwind and downwind nodes.

whichever is the upwind node; i.e. in one dimension:

φP φe

φ

φe = P

(if u > 0) φE

φ E (if u < 0)

P E

This is only first-order accurate in x (see later) but

acknowledges the directional nature of advection. The

alternatives can be summarised as e

φ face = φU

where subscript U denotes whichever is the upwind node for that face.

With this scheme, the algebraic equation for each control volume takes the canonical form

a P φ P − ∑ a F φ F = bP

F

where:

a E = max(−C e ,0) + De

aW = max(C w ,0) + Dw (14)

a P = a E + aW − s P

If the “max” bit confuses you, consider separately the two cases where the mass flux is

positive (flow from left to right) or negative (flow from right to left).

is found that:

• when Pe = ½ the upwind-differencing scheme is not as accurate as central

differencing; this is to be expected from its order of accuracy;

• when Pe = 4 the upwind-differencing solution is not particularly accurate, but the

“wiggles” have disappeared.

In all cases, however, both aW and aE are unconditionally positive.

So there is a pay-off – accuracy versus boundedness (absence of wiggles). The next sections

examine the desirable properties of discretisation schemes, the constraints that they impose

upon the matrix coefficients and more advanced advection schemes that are both accurate and

bounded.

4.9 Discretisation Properties

(i) Consistency

equations in the limit as the grid size tends to zero. e.g., by the definition of a derivative,

φE − φP ∂φ

is a consistent approximation for .

x ∂x

(ii) Conservativeness

A scheme is conservative if fluxes are associated with faces, not particular flux

cells, so that what goes out of one cell goes into the adjacent cell;

(iii) Transportiveness

weighting to nodes on the upstream side of a face.

(iv) Boundedness

• the value of φ at a node always lies between the maximum and minimum values at

surrounding nodes;

• φ = constant is a possible solution.

This imposes conditions on the matrix coefficients aP, aW, aE, ... If there are no sources then

aP φ P − ∑ aF φ F = 0 (15)

Suppose that φ is only non-zero at one adjacent node, F. Then

a

aP φ P − aF φ F = 0 or φP = F φF

aP

Since φP must lie between 0 and φF, this requires that

a

0 ≤ F ≤1

aP

Hence, aF and aP must have the same sign (invariably positive in practice). Thus, we require:

a F ≥ 0 for all F (“positive coefficients”) (16)

(It is the contravening of the positivity condition that leads the central-differencing scheme to

produce “wiggles”. If the Peclet number is greater than 2 then a small increase in φF would

produce a large decrease in the value of φP, a situation which is completely unphysical.)

If (15) is also to admit the solution φ = constant then this can be divided out to yield

aP = ∑ aF (“sum of neighbouring coefficients”) (17)

(v) Stability

A solution method (not advection scheme) is stable if small errors do not grow in the course

of the calculation. This determines whether it is possible to obtain a converged solution – it

says nothing about its accuracy or whether it contains wiggles. Stability is heavily influenced

by how the source term is discretised.

Any source term should be linearised as bP + s P φ P ; the complete equation for one cell is then

a P φ P − ∑ a F φ F = bP + s P φ P

If the solution-dependent part of the source (sPφP) is transferred to the LHS then the diagonal

coefficient is modified to read

aP = ∑ aF − sP

Numerical stability requires negative feedback; otherwise, an increase in φ would lead to an

increase in the source, which would lead to a further increase in φ and so on. Thus:

sP ≤ 0 (“negative-slope linearisation of the source term”)

If this condition and the positivity of the aF is maintained then

aP ≥ ∑ aF (“diagonal dominance”)

The last condition is, in fact, a necessary requirement of many matrix solution algorithms.

In summary, boundedness and stability place the following constraints on the discretisation of

flux and source terms:

negative-slope linearisation of the source term: source = bP + s P φ P , s P ≤ 0

sum of neighbouring coefficients: aP = ∑ aF − sP

F

(vi) Order

Order is a measure of accuracy. Formally, it defines how fast the error in a numerical

approximation diminishes as the grid spacing gets smaller.

that scheme is said to be of order n.

Order can be established formally by a Taylor-series expansion about a cell face. e.g. for the

nodes either side of the east face:

∂φ x 1 ∂ 2φ x 2 1 ∂ 3φ x

φ E = φe + ( ) +

2

( ) + 3 ( ) 3 + L (18)(a)

∂x e 2 2! ∂x e 2 3! ∂x e 2

∂φ x 1 ∂ 2φ x 1 ∂ 3φ x

φ P = φe − ( ) + 2 ( ) 2 − 3 ( ) 3 + L (18)(b)

∂x e 2 2! ∂x e 2 3! ∂x e 2

∆x

∂φ 1 ∂ 3φ x

φE − φP = 0 + x + 0 + 3 ( ) 3 + L

∂x e 3 ∂x e 2

whence, dividing by x:

φ E − φ P ∂φ

= + O( x 2 )

x ∂x e

φ − φP ∂φ

As the leading error term is O(∆x2), E is a second-order approximation for .

x ∂x e

∂ 2φ x

φ P + φ E = 2φ e + 0 + 2 ( ) 2 + L

∂x e 2

whence:

2 (φ P + φ E ) = φ e + O ( x )

1 2

approximation for φe. On the other hand, the Upwind-differencing approximations φP or φE

(depending on the direction of the flow) are formally first-order accurate.

Higher accuracy can be obtained by using more nodes in an approximation – one node

permits schemes of at most first-order accuracy, two permit second-order accuracy and so on.

and 3-d calculations when the velocity vector is not aligned with the grid lines.

Notes.

(1) Order is an asymptotic concept; i.e. it refers to behaviour as x 0. In this limit only

the first non-zero truncation term in the Taylor series is important. However, the full

expansion includes terms of higher order which may be non-negligible for finite x.

(2) Order refers to the theoretical truncation error in the approximation, not the

computer’s round-off error (the accuracy with which it can store floating-point

numbers).

(3) The more accurate a scheme then, in principle, the greater the reduction in numerical

error as the grid is made finer or, conversely, the less nodes required for a given

accuracy. However, high-order schemes tend to require more computational

calculations and often have boundedness or stability problems. Also, the law of

diminishing returns applies when the truncation error becomes of similar size to the

floating-point round-off error.

4.10 Discretising Advection (Part 2)

possible to examine more advanced schemes.

The 1-d advection diffusion equation is

fluxe − flux w ≡ source flux w source flux e

or, equivalently,

∆x

d dφ

( uAφ − A ) = S (19)

dx dx

If there are no sources (S = 0) then the total flux must be constant:

dφ

flux = uAφ − A = constant

dx

If , u, A and are constant this equation can be solved exactly, with boundary conditions

φ = φP and φ = φE at adjacent nodes, to give (see the Examples):

e Pe φ P − φ E

fluxe = C

e −1

Pe

where

C = uA = mass flux

A

D = = diffusive transfer coefficient

x

C u x

Pe = =

D

.

With a similar expression for the west face, one obtains

fluxe − flux w = a P φ P − ∑ a F φ F

where:

Ce Pe C

aW = Pe , a E = Pe , a P = a E + aW (20)

e −1 e −1

Assessment

• Conservative by construction.

• Transportive, because there is a larger weighting on the upwind node.

• Bounded: all aF are positive and aP is the sum of the neighbouring coefficients.

To see the last two of these you will have to consider separately the cases C > 0 (for which

ePe > 1) and C < 0 (for which ePe < 1).

This scheme – by construction – gives the exact solution for zero sources and constant

velocity and diffusivity, but this is something we could have found analytically anyway. The

scheme has never really found favour because:

• the scheme isn’t exact when u or vary, or if there are sources, or in 2-d or 3-d flow;

• exponentials are extremely expensive to compute.

4.10.2 Hybrid Scheme (Spalding (1972)

• central differencing if Pe ≤ 2 ;

• upwind differencing (with zero diffusion!) if Pe > 2 .

fluxe − flux w = a P φ P − ∑ a F φ F

where (if u > 0 and the mass flux C and diffusive transport coefficient D are constant):

aW = 12 C + D , a E = − 12 C + D if Pe ≡ C/D ≤ 2

aW = C , aE = 0 if Pe > 2 (21)

a P = a E + aW

Assessment

The scheme is conservative, transportive and bounded.

The hybrid scheme remained extremely popular in commercial codes for a long time because

it was stable and robust. However, most flows of interest operate in the high-advection/low-

diffusion regime, where this scheme amounts to first-order upwinding (with no diffusion).

Modern CFD practitioners seek much higher accuracy.

the heavy-handed switch-off of diffusion at Pe = 2. However, “powers” are as

computationally expensive as exponentials.

1979)

φW

Fits a quadratic polynomial through 3 nodes to get 3rd-order

accuracy.

φP φ

e φE

For each cell face, QUICK uses the nodes either side of the

cell face, plus a further upwind node depending on the W P E

direction of the flow as shown right.

e

property which associates

fluxes with cell faces, not

face nodes, we shall, in future, for φP

all such three-point schemes use the notation φD, φU and φUU φe

φE

for the Downwind, Upwind and Upwind-Upwind nodes at φEE

any particular face.

P E EE

By fitting a quadratic polynomial to these nodes (see the e

Examples) the QUICK scheme gives:

φ face = − 18 φUU + 34 φU + 83 φ D u<0 (22)

For example, if u > 0 on the east face then:

φ e = − 18 φW + 34 φ P + 83 φ E WW W P E EE

whereas, if u < 0: w e

φ e = − 18 φ E + 34 φ E + 83 φ P

Assessment

• 3rd-order accurate.

• Conservative by construction.

• Transportive (upwind bias in the selection of the third node and relative weightings).

• Not bounded; (for example, if u > 0 then aE is negative – see the Examples).

Despite boundedness not being guaranteed (which can be a major problem in turbulent flows,

where k and ε are required to be positive – see later) the high-order accuracy of the QUICK

scheme make it popular and widely-used.

Hitherto we have only seen schemes where the matrix coefficients aF are constants (i.e.

independent of the solution φ). The only unconditionally-bounded scheme of this type is first-

order upwind differencing. Schemes such as QUICK, which fit a polynomial through several

points, are prone to generate cell-face values which lie outside the interpolating values φD, φU,

φUU. To prevent this, modern schemes employ solution-dependent limiters, which enforce

boundedness whilst trying to retain high-order accuracy wherever possible.

φ

monotonic increasing if φUU < φU < φ D ,

monotonic decreasing if φUU > φU > φ D .

UU U D UU U D

A necessary condition for boundedness is that

the schemes must default to first-order

upwinding (i.e. φface = φU) if φ is not locally

monotonic non-monotonic

monotonic (either increasing or decreasing).

pairs of nodes have the same sign; i.e.

monotonic ⇔ (φ D − φU )(φU − φUU ) > 0

Such schemes can then be written (in the notation of Versteeg and Malalasakera) as the sum

of the upstream value (φU) and a solution-dependent fraction of the difference between

downstream and upstream nodal values:

φ + 1 (r )(φ D − φU ) if monotone

φ face = U 2

φU otherwise

where r is the ratio of successive differences (>0 where monotonic): UU U D

φ − φUU

r= U

φ D − φU face

The limiter (r) is given below for various schemes used at the University of Manchester.

Upstream Monotonic Interpolation for Scalar

min{2, 2r , 14 (1 + 3r ), 14 (3 + r )} Transport (Lien and Leschziner, 1993). A limited

UMIST

variant of QUICK, this is 3rd-order accurate where

monotone.

2r Van Leer (1974).

Harmonic Second-order accurate where monotone.

1+ r

The choice of these examples is (obviously!) parochial. Many other equally-good schemes

exist (see Versteeg and Malalasekera, 2nd edition, for a list). The important points about these

schemes are that they are (a) bounded, and (b) non-linear (i.e. the resulting matrix elements

depend on, and hence change with, the solution φ). The last property means that an iterative

numerical solution is inevitable.

∂φ

∑

faces

( Cφ −

∂n

A ) = SV

(23)

advection diffusion source

If C and D are the outward mass flux and diffusive transport coefficient on each cell face,

then, with the standard discretisation for diffusion and sources, (23) becomes

∑ [Cφ face + D(φ P − φ F )] = bP + s P φ P

faces

where F denotes an adjacent node and P is the index of the cell-centre node. Since ∑C = 0

by mass conservation, it is convenient to subtract ∑ Cφ P (which is 0) from both sides:

∑ [C (φ

faces

face − φ P ) + D(φ P − φ F )] = bP + s P φ P (24)

An advection scheme (Upwind, Central, QUICK, …) is needed to specify the cell-face value

φface. Because many matrix-solution algorithms require positive coefficients and diagonal

dominance, it is common practice to separate φface into the Upwind part plus a correction; i.e.

φ face = φU + (φ face − φU )

C (φ face − φ P ) = C (φU − φ P ) + C (φ face − φU )

14243 14 4244 3

upwind correction (25)

= max(−C ,0)(φ P − φ F ) + C (φ face − φU )

a F = max(−C ,0) + D

whilst the latter part is transferred to the RHS of the equation as what is called a deferred

correction; (“deferred” because it won’t be updated until the next iteration):

∑F a F (φ P − φ F ) = bP + s P φ P − faces

∑ C (φ face − φU )

144 42444 3

deferred correction

• value φ specified (Dirichlet boundary conditions);

e.g. φ = 0: velocity at a wall, or temperature fixed at some surface;

• gradient ∂φ/∂n specified (Neumann boundary conditions).

e.g. ∂φ/∂n = 0 on a symmetry plane, or at an outflow boundary.

boundary

both types of boundary

boundary

by transferring the boundary

flux to the source term.

∑ flux + fluxboundary = source

not

boundary

⇓ P B

aP φ P − ∑

not

a F φ F = bP − fluxboundary

boundary

• the aF coefficient in the direction of the boundary is set to zero;

• the outward boundary flux is subtracted from the source terms.

If flux(φ) is specified on the boundary, then this is immediate. If φ itself is fixed on the

boundary node B then, with x the width of the cell:

φ − φP

flux(φ) = − A B1 = −2 D ( φ B − φ P )

2 x

To subtract this flux from the source term requires a simple change of coefficients:

bP → bP + 2 Dφ B , sP → sP − 2D (26)

(You should revisit the classroom examples of Sections 4.4 and 4.5 to see this in action.)

4.13 Solution of the Algebraic Equations

The discretisation of a single scalar-transport equation over a single control volume produces

an algebraic equation of the form

a P φ P − ∑ a F φ F = bP

where the summation is over adjacent nodes. Combining the equations for all control

volumes produces a set of simultaneous equations, i.e. a matrix equation

AΦ = b

where Φ is the vector of nodal values. Matrix A is sparse (i.e. has only a few non-zero

elements). Many algebraic methods have been used to tackle this problem; a few that are

suitable for structured grids are mentioned below.

Gaussian Elimination

obtain zeros below the main diagonal (upper-triangular matrix), followed by back-

substitution.

In general, it is inefficient because it tends to fill in sparse matrices (tridiagonal systems are

an important exception), whilst for fluid-flow problems the matrix elements vary with the

solution, so that an iterative solution is necessary anyway.

Gaussian elimination is OK for small hand calculations, but not recommended for large

systems of equations.

Gauss-Seidel

N each control volume as an

iterative update for the

W P E central node:

1

φP = (bP + ∑ a F φ*F )

aP

S

(the asterisk * denotes the

current value). Then

repeatedly cycle through the entire set of equations direction of sweep

until convergence is achieved.

Gauss-Seidel is very simple to code and is often used for unstructured grids. However, it

tends to converge slowly for large matrices and may require substantial under-relaxation (see

below).

Classroom Example 4.

(a) Show how Gauss-Seidel can be used to solve the following matrix equation iteratively,

and conduct 3 Gauss-Seidel sweeps.

4 −1 0 0 A 2

−1 4 −1 0 B 4

0 − 1 4 − 1 C = 6

0 0 − 1 4 D 13

Write a computer program (using any programming language or application of your choice)

to solve this problem iteratively.

(b) Now try to do the same for the matrix equation (which actually has the same solution):

1 −4 0 0 A − 7

− 4 1 − 4 0 B − 14

0 − 4 1 − 4 C = − 21

0 − D − 8

0 4 1

Why does Gauss-Seidel not converge in this case?

diagonal; e.g. in the i-direction: φ b- φ*

− a φ + a φ − a φ = b − a φ*

W W P P E E P ∑

not

F F

W ,E

N

line can be updated at one go and information can of sweep

direction

rather than (as in Gauss-Seidel) one node at a time. A

typical single iteration would consist of applying the S

update for each successive i line, then for each

successive j line, then (if 3-d) for each successive k line.

This is probably the most popular method for block-structured grids, and is the basis of most

of our in-house research codes. Note, however, that it doesn’t work for unstructured grids.

4.13.2 Convergence Criteria

Iteration is stopped when the total residual error becomes less than some small, pre-defined

tolerance. The total residual error is a suitably-weighted sum over the errors for all cells; e.g.

sum of absolute residuals: Error = ∑ res

cells

1

root-mean-square (rms) error: Error = ∑

N cells

(res ) 2

where the residual is the error in satisfying the algebraic equations for any one cell:

res = a P φ P − ∑ a F φ F − bP

F

The tolerance is usually set to some small fraction (e.g. 10–4) of the error at the first iteration.

4.13.3 Under-Relaxation

If the algebraic methods described above are applied to the non-linear, coupled equations of

fluid flow then the change in variables at each iteration may be large enough to cause

numerical instability. To overcome this, under-relaxation reduces the change at each iteration

(without affecting the final, converged, solution).

a P φ P − ∑ a F φ F = bP

can be rearranged as

φP =

∑ a F φ F + bP

aP

and then written in terms of the change in φ by adding and subtracting the previous value:

∑ a F φ F + bP

φ P = φ old

P +

− φ old

P

a P

∑ a F φ F + bP

φ P = φ old

P +

− φ old

P

a P

is called an under-relaxation factor.

a P φ P − ∑ a F φ F = bP + (1 − )a P φ old

P

aF → aF

(27)

bP → bP + (1 − )a P φ old

P

This has the advantage of making the matrix equations more diagonally dominant, which

improves stability. Since φ P = φ old

P in the converged solution, the final solution is unaffected

by under-relaxation.

Summary

• The generic scalar-transport equation for a particular control volume has the form

rate of change + net outward flux = source

advection – transport with the flow (other authors prefer convection);

diffusion – net transport by random molecular or turbulent fluctuations.

a P φ P − ∑ a F φ F = bP

F

for each control volume, where the summation is over adjacent nodes.

equation with limited bandwidth (i.e. few non-zero diagonals), typically solved by

iterative methods such as Gauss-Seidel or line-Gauss-Seidel.

bP + s P φ P , s P ≤ 0 .

∂φ A

− A → − (φ E − φ P )

∂x x

advective fluxes. They include Upwind, Central, Exponential, Hybrid, QUICK, and

various flux-limited schemes.

consistent

conservative

bounded

stable

transportive

accuracy / high-order

a F ≥ 0 for all F (“positive coefficients”)

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

aP = ∑ aF − sP (“sum of the neighbouring coefficients”)

F

are often decomposed into

“Upwind” + “deferred correction”

with the latter being transferred to the source term and treated explicitly (i.e. fixed for

this iteration).

• Boundary conditions can be implemented by transferring boundary fluxes to the

source terms.

b1 − c1 0 O 0 φ1 d1

System of equations:

− ai φ i −1 + bi φ i − ci φ i +1 = d i , i = 1,K, N O O O 0 O M M

0 −a b −c 0 φi = d i

i i i

Either φ 0 and φ N +1 are given, or a1 = cN = 0. O 0 O O O M M

0 O 0 −a bN φ N d N

N

Forward pass:

P0 = 0, Q0 = φ 0

ci d i + ai Qi −1

Pi = , Qi = , i = 1, K, N

bi − ai Pi −1 bi − ai Pi −1

Backward pass:

φ i = Pi φ i +1 + Qi , i = N , K, 1

ai 0, ci 0, ai + ci bi for all i

except in the degenerate case where zero ai or ci allow successive rows to be multiples of

each other and the matrix is consequently singular (rank < N).

Exercise: Code your own solver as a subroutine and test it on one of the classroom examples.

Examples

Q1.

The central-differencing scheme for diffusion using cell- W P E EE

centred storage uses the approximation

dφ φ − φP

≈ E

dx e x

Show that this is second-order accurate. Making use of the W and EE nodes also, find a

symmetric fourth-order-accurate scheme for the derivative on the cell face.

Q2.

(a) Show that a quadratic function fitted to values UU , U and D at locations − 32 x ,

− 12 x , and 12 x takes the value

− 18 φUU + 34 φU + 83 φ D

at x = 0. (This is the basis of the QUICK advection scheme).

(b) Show that the QUICK advection scheme is 3rd-order accurate (on a uniform mesh).

Q3. UU U D

The QUICK scheme fits a quadratic function to three nodal values

to estimate the value of a scalar at a cell face, according to

φ face = − 18 φUU + 34 φU + 83 φ D face

φe, φw, φn, φs

in terms of the values at neighbouring nodes, assuming that velocity components u

and v are known, constant and positive.

(b) Neglecting diffusion, and assuming a uniform source S per unit volume, derive an

algebraic discretisation of the conservation equation

∑ (outward fluxes) = source

in the form

a P φ P − ∑ a F φ F = bP

where the sum is over local nodes. (Assume the cell to be Cartesian, with unit depth in

the z direction, face areas Ae, Aw, An, As and volume V).

(d) Which of the following properties does the QUICK scheme satisfy:

transportiveness;

boundedness.

“Upwind differencing” + “deferred correction”

Why is this decomposition used?

Q4.

Consider the advection-diffusion equation with no sources:

d dφ

( uφ − )=0

dx dx

where ρ, u, Γ are constants. If φ = φP at x = 0 and φ = φE at x = x, find the value of the flux

dφ

uφ −

dx

at any point between x = 0 and x. (This is the basis of the exponential differencing scheme).

Q5.

If the continuity (mass-conservation) equation were to be regarded as a special case of the

general scalar-transport equation, what would be the expressions for φ, and S?

The source term for a dependent variable φ is given by 2 − 3 φ P φ P . If this term is to be

linearised as bP + s P φ P , comment on the following practices ( φ*P denotes the value from the

previous iteration):

(a) bP = 2 − 3 φ *P φ *P , s P = 0

2

(b) bP = 2 − 3φ*P , s P = 0

(c) bP = 2 − 4 φ*P φ*P , s P = φ*P

(d) bP = 2 , s P = −3 φ *P

(Ref: notes, Section 4.5).

Q7.

A 2-d finite-volume calculation is to be undertaken for fully-developed, laminar flow

between plane, parallel walls. The upper wall is moving at speed U0, whilst the lower wall is

stationary. A streamwise pressure gradient dp/dx = −G is also imposed.

shown, with the velocity u stored at the centre of each cell.

∆x

U0

uN

u j+1

H

uj ∆y

uj-1

u1

(a) What are the boundary conditions on upper and lower walls?

(c) Write down a second-order approximation for the shear stress on the upper face of

the jth internal cell, in terms of the velocities uj and uj+1.

(d) Write down similar approximations for on upper and lower walls.

(e) By balancing pressure and viscous forces set up the finite-volume equations for

velocity. (Separate equations are required for internal and boundary cells).

(f) Solve your equations for the nodal velocities in the case

GH 2

N = 4, =2

U0

leaving your answers in terms of U0.

(g) Using your answer to part (f), find the volume flow rate per unit span (leaving your

answer as a multiple of U0H).

(h) Solve the Navier-Stokes equation analytically for this case and compare with your

answers in parts (f) and (g).

Q8. (Computational Hydraulics Exam, June 2009)

A 2-d finite-volume calculation is to be undertaken for fully-developed, laminar flow

between stationary, plane, parallel walls. A streamwise pressure gradient dp/dx = −G is

imposed and the fluid viscosity is . The depth of the channel, H, is divided into N equally-

sized cells of dimension x × y × 1 as shown in the figure below, with the velocity u stored

at the centre of each cell.

uN

u j+1

uj

H ∆y

uj-1

u1

∆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

{uj}. (You will need to deal separately with interior cells and the boundary cells j = 1

and j = N.)

(d) By balancing pressure and viscous forces set up the finite-volume equations for the

velocity field.

(e) Solve for the nodal velocities in the case N = 6, leaving your answers as multiples of

U 0 = GH 2 / . (You are advised to note the symmetry of the problem.)

(f) Using your numerical solution, find the volume flow rate (per unit span) Q in terms of

U0 and H.

Q9. (Computational Hydraulics Exam, May 2008)

The local arrangement of nodes and faces in a 1-d finite-volume mesh with standard

geographical notation and uniform mesh spacing x is shown in the figure below.

w e

WW W P E EE

∆x

d dφ

uφ − =S,

dx dx

where is density, u is velocity, is diffusivity, S is the source density. Write this in

a corresponding integral form for the shaded cell in Figure 2.1.

(c) Write expressions for φ on w and e faces of the shaded cell if u is positive for (i) first-

order upwind; and (ii) central advection schemes.

(d) Define the term bounded when applied to flux-differencing schemes and deduce a

condition on , u, and x for the central scheme to be bounded.

φ P − φW

φ e = φ P + 12 (r )(φ E − φ P ) where r=

φE − φP

(e) Write the (constant) values of for (i) first-order upwind; and (ii) central advection

schemes.

2r

if r > 0

(r ) = 1 + r

0 otherwise

In a particular case, = 1, u = 1, = 0.02 and x = 0.1 in consistent units. In a

solution with the Van Leer advection scheme, φ takes the following values:

φWW = 1, φW = 2, φP = 4, φE = 2, φEE = 3,

Find the values of φ and dφ/dx on w and e faces, and hence the mean source density S

for cell P.

(**** Remaining questions for MSc Course only ****)

Q10. (MSc exam, May 2008 – part)

The general three-point scheme for the cell-face value of a transported scalar φ is

φ − φUU UU U D

φ face = φU + 12 (r )(φ D − φU ) , r= U

φ D − φU

where upstream (U) and downstream (D) are defined by flow direction face

(a) The linear upwind differencing (LUD) and QUICK schemes are:

LUD: φ face = 32 φU − 12 φUU

QUICK: φ face = − 18 φUU + 34 φU + 83 φ D

Identify the functional form of (r) for each of these schemes.

=0 if r ≤ 0

≤ min(2r ,2) if r ≥ 0

Show that LUD and QUICK both contravene these conditions for some r 0.

0, if r ≤ 0

(r ) = r + r 2

1 + r 2 , if r ≥ 0

Show that this satisfies Sweby’s criteria and also the symmetry property

(r ) 1

= ( ) for r > 0

r r

The discretisation of a 1-d scalar-transport equation results in a set of simultaneous equations

for the nodal values {φi} of the form

− 2φ i −1 + 6φ i − φ i +1 = 2 − 2 φ i φ i , i = 1,2,K, N

where φ0 and φN+1 are given. Use the Gauss-Seidel method to solve this iteratively for the

case N = 3 with boundary conditions φ 0 = φ 4 = 0 .

The linear system of equations

− ai φ i −1 + bi φ i − ci φ i +1 = d i , i = 1,2,K, N

(where ai, bi, ci and di are constants, and φ0 and φN are fixed) can be solved by the tri-diagonal

matrix algorithm as

φ i = Pi φ i +1 + Qi , i = N ,K,1

where {Pi} and {Qi}are determined from an initial forward pass. Show that

ci

Pi = , i = 1,K, N ; P0 = 0

bi − ai Pi −1

and derive a similar recurrence relation for the {Qi}.

(You may assume here that ai > 0, ci > 0, ai + ci bi for all i.)

Selected Answers

Classroom Example 1

(a) T1 = 140, T2 = 220, T3 = 300, T4 = 380, T5 = 460

d dT

(b) ( −kA ) = 0 ; solution T = 400 x + 100

dx dx

Classroom Example 2

(a) T1 = 64.23, T2 = 36.91, T3 = 26.50, T4 = 22.60, T5 = 21.30

d dT e 5 x + e10 −5 x

(b) ( − kA ) = −c (T − T∞ ) ; solution T = 80( ) + 20

dx dx 1 + e10

Classroom Example 3

(a) Central:

Cell 1: 0.592φ P + 0.493φ E = 0

0.01 in cell 4

Cells 2 – 6: − 0.507φW + 0.085φ P + 0.493φ E =

0 otherwise

Cell 7: − 0.507φW + 0.578φ P = 0

(b) Upwind:

Cell 1: 1.092φ P − 0.007φ E = 0

0.01 in cell 4

Cells 2 – 6: − 1.007φW + 1.085φ P − 0.007φ E =

0 otherwise

Cell 7: − 1.007φW + 1.078φ P = 0

Classroom Example 4

A = 1, B = 2, C = 3, D = 4

− φ EE + 27φ E − 27φ P + φW

Q1.

24 x

Q3. (a)

φe = − 18 φW + 34 φ P + 83 φ E

φw = − 18 φWW + 34 φW + 83 φ P

φn = − 18 φ S + 34 φ P + 83 φ N

φs = − 18 φ SS + 34 φ S + 83 φ P

(b) a P φ P − ∑ a F φ F = bP

where:

aE = − 83 C e aN = − 83 C n

aW = 34 C w + 18 C e aS = 34 C s + 18 C n

aWW = − 18 C w a SS = − 18 C s

a P = aWW + aW + a E + a SS + a S + a N + (C e − C w + C n − C s )

144424443

= 0 by mass conservation

bP = SV

and

C e = uAe , C n = vAn , etc.

(c)

φe = − 18 φ EE + 34 φ E + 83 φ P

φw = − 18 φ E + 34 φ P + 83 φW

(e)

φ face = − 18 φUU + 34 φU + 83 φ D

= φU + {− 18 φUU − 14 φU + 83 φ D }

1444 424444 3

deferred correction

φ e Pe − φ E

Q4. F = u P Pe

e −1

Q5. φ = 1, = 0, S = 0

Q6. (a) Not very efficient (and would fail for positive-definite quantities)

(b) Wrong source if φP < 0.

(c) Unstable, because sP > 0.

(d) This is the best method.

Q7 (a) on the lower wall: u = 0; on the upper wall: u = U0

(b) G x y

u j +1 − u j

(c) ( north )

≈

y

U 0 − uN

(d) On the upper wall: ≈ 1

2 y

u −0

On the lower wall: ≈ 11

2 y

G y2

(e) Internal cells: − u j −1 + 2u j − u j +1 =

G y2

Top cell: − u N −1 + 3u N = + 2U 0

G y2

Bottom cell: 3u1 − u 2 =

(f) u1 = 14 U 0 , u 2 = 58 U 0 , u 3 = 78 U 0 , u 4 = U 0 ,

(g) q = 16

11

U0H

u y y y

(h) Analytical solution: = (1 − ) +

U0 H H H

u1 = 64 U 0 , u 2 = 64 U 0 , u 3 = 64 U 0 , u 4 = 64

15 39 55 63

U0

q = 3U0H

2

(b) G x y

x

(c) viscous force on upper face = (u j +1 − u j )

y

x

viscous force on lower face = − (u j − u j −1 )

y

x

viscous force on upper face of top cell = −2 uN

y

x

viscous force on lower face of bottom cell = −2 u1

y

G y2

(d) Internal cells: − u j −1 + 2u j − u j +1 =

G y2

Top cell: − u N −1 + 3u N =

G y2

Bottom cell: 3u1 − u 2 =

(e) u1 = u 6 = 723 U 0 , u 2 = u 5 = 7

72 U0 , u3 = u 4 = 9

72 U0

(f) Q = 216

19

U0H

w = 2 GH

1

(g)

dφ dφ

e

Q9. (a) ( uφ − ) e − ( uφ − )w = ⌠ S dx

dx dx ⌡w

dφ φ − φP dφ φ − φW

(b) ≈ E ; ≈ P

dx e x dx w x

(c) (i) First-order upwind: φ e = φ P , φ w = φW

(ii) Central: φ e = 12 (φ P + φ E ) , φ w = 12 (φW + φ P )

u x

(d) ≤2

(e) (i) first-order upwind: = 0;

(ii) central: = 1.

8 dφ dφ 64

(f) φ e = 4 , φ w = , = −20 , = 20 , S =

3 dx e dx w 3

QUICK : (r ) = 14 (r + 3)

- Application of the Shrinking Core Model for Copper Oxide LeachingUploaded byLuis La Torre
- cfd2Uploaded bycamaradiya
- cfd3Uploaded bycamaradiya
- cfd5Uploaded bycamaradiya
- cfd6Uploaded bycamaradiya
- LinAlg_CompleteUploaded bys0uiz
- cfd7Uploaded bycamaradiya
- introcfdUploaded bycamaradiya
- Ficks First LawUploaded byRikudō Sennin
- Maths 2 Iit Kanpur Peeyush Chandra, A. K. Lal, V. Raghavendra, G. SanthanamUploaded bymilind
- HW Questions MidtermUploaded byOnur Yalçınkaya
- LinAlg CompleteUploaded bynikas65
- Iterative Techniques in Matrix AlgebraUploaded byJuan Juan
- LinAlg CompleteUploaded byAidana Shaniyeva
- LinAlg CompleteUploaded byToni Alfian
- CFDUploaded byPriya Patankar
- LinAlg CompleteUploaded bymasyati
- LinAlg CompleteUploaded byGuo Sheng Khor
- Linear Alg CompleteUploaded byXeni Inter
- Gaussian LU Eliminations SeidelUploaded byHarris Anches
- LinAlg CompleteUploaded byAys Kwim
- digest_TWave High-Order Analysis of Functional MRIUploaded byJie Fu
- 05411803Uploaded byganadim9795
- Cornell Linear AlgebraUploaded bychiquicik
- e_057_02_0459Uploaded byFredrick Mutunga
- 2. CFD Study Spreadsheets UseUploaded bychemsac2
- ControlDraw3 Training - 2017.pptxUploaded bycramerps2084
- Disha Publication Shortcut on Coding Decoding (1)Uploaded byJanaki Krishnan
- Design IssuesUploaded byMauro Krad
- atigo cimUploaded byVictor

- 04 Heat Transfer From Extended SurfacesUploaded bycamaradiya
- Automobile Heat TransferUploaded bycamaradiya
- Mechanical Engg. Sem -VI Teaching SchemeUploaded byShivam Purohit
- Control EngineeringUploaded byhotnili
- 2 Pipe FricitionUploaded bycamaradiya
- OHPUploaded bycamaradiya
- R 12Uploaded bycamaradiya
- IDP UDP Reporting SheetUploaded bycamaradiya
- bio mass 1Uploaded bycamaradiya
- 2-_FriedeUploaded bycamaradiya
- PM Lecture 7Uploaded bycamaradiya
- PLC'SUploaded bycamaradiya
- 1Uploaded bynaruto20254663
- Thesis 1Uploaded bycamaradiya
- introcfdUploaded bycamaradiya
- cfd7Uploaded bycamaradiya

- PATRAM2013-Linnemann-Et-Al-paper Methodological Aspects for Numerical Analysis of Lid Systems for SNF and HLW Transport PackagesUploaded byhamadani
- 2014 Course CatalogUploaded byTimur Istemirov
- ReporthuehuehueheuhuhuheeUploaded byAnonymous GV18teQO8O
- Generation of shape functions for straight beam elementsUploaded bythai230293
- A. L. Kuhl, J. B. Bell and V. E. Beckner- Turbulent Combustion in SDF ExplosionsUploaded byMfdrr
- Roky 12 qns 2006Uploaded byKaminikanta Das
- EAMCET 2012 Cut OffsUploaded byaglasem
- HW ch5_2019Uploaded byJoker9987
- Liu_BUploaded byHannah Bee Sordilla
- Chapter_4_08 (1).pdfUploaded byShoshAlmazroeui
- Requirement for Branch Connection at Flare HeaderUploaded bygpskumar22
- Chapter 26 - SoundUploaded byPiyumi Gallage
- MIT8 09F14 Chapter 7Uploaded byMadhava Dathan Bhattathiripad
- SynopsisUploaded byAakash Bhardwaj
- Finite Element Method (2)Uploaded byVivek Patel
- 2 SnowflakesUploaded byRizki Mufidayanti
- Lattice Energy LLC-Index to Concepts and Documents-Sept 2009Uploaded bylewisglarsen
- 7 VA for Fault DiagnosisUploaded byJam Bab
- Capacitor Banks in Power System Part 2Uploaded byamit
- 333546_SOLUTION MANUAL BRADY CHEMISTRY 6TH EDITION.pdfUploaded byJeremy Gavriel
- API MPMS Chapter 5.3 (2005) Measurement of Liquid Hydrocarbons by Turbine Meters.pdfUploaded byEsteban Calderón Navarro
- Physics SeaUploaded byMaheshwar Kumar
- Lactose characteristics and.pdfUploaded byahmedsidala
- MOSI CE119v3Uploaded byAwais Ahmed
- hggfvUploaded byhemavathyrajasekaran
- A1054-16 3.07Uploaded bysomad
- AIR QUALITY AND POLLUTION (TKA 3301) LECTURE NOTES 4-Chemistry of Air Pollution n Ideal Gas LawUploaded bymamat88
- ESI_ionSource Mass SpectrometryUploaded bykapilpareek
- Trashrack DesignUploaded byAnonymous b9DIaPTq6B
- Presentation 1Uploaded bySrinivas Voggu

## Much more than documents.

Discover everything Scribd has to offer, including books and audiobooks from major publishers.

Cancel anytime.