0% found this document useful (0 votes)
61 views

QuickerSim CFD Course Notes

This document outlines lecture material on modeling heat and fluid flow. It discusses repeating basic models for conduction, diffusion and convection. For conduction, Fourier's law relates heat flux to thermal conductivity and temperature gradient. Fick's law describes diffusion using a diffusion coefficient and concentration gradient. Convection involves transport of thermal energy or momentum by a moving fluid. The document also covers boundary conditions, fluid flow models including channel flow, turbulence and porous media flow, and conductivity heat transfer.

Uploaded by

aainaaaaa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

QuickerSim CFD Course Notes

This document outlines lecture material on modeling heat and fluid flow. It discusses repeating basic models for conduction, diffusion and convection. For conduction, Fourier's law relates heat flux to thermal conductivity and temperature gradient. Fick's law describes diffusion using a diffusion coefficient and concentration gradient. Convection involves transport of thermal energy or momentum by a moving fluid. The document also covers boundary conditions, fluid flow models including channel flow, turbulence and porous media flow, and conductivity heat transfer.

Uploaded by

aainaaaaa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 70

Lecture Course

Bartosz Górecki, PhD

QuickerSim Sp.z o.o.


Contents

1 Basic flow and heat transfer models 5

1.1 Repetition of different models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

1.2 Boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

1.3 Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

1.3.1 Channel and pipe flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

1.3.2 Turbulence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

1.3.3 Porous Media Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

1.4 Conductivity heat transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

2 Lecture 2 12

2.1 Convective heat transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2.2 Radiative heat transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2.3 Heat transfer in porous media . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2.4 Chemical reactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

2.5 Numerical never-forgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.5.1 Discretisation of space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.5.2 Discretisation of time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

2.5.3 Discretization of equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3 Lecture 3 17

3.1 Approximation of derivatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

3.2 Convergence plots, method’s order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

3.3 Mesh sensitivity/independency study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

3.4 Heat convection calculation in anisotropic materials . . . . . . . . . . . . . . . . . . . . . . . 20

1
3.5 1D FDM discretization and implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

3.6 FDM: Stability of the schemes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

4 Lecture 4 24

4.1 Approximation in discretization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

4.2 Steady-state advection-diffusion equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

4.3 Differential equation in 2D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

4.4 FINITE VOLUME METHOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

4.4.1 How to store a cell volume? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

4.4.2 How to find neighbouring cells? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

4.4.3 Interpolation in FVM? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

5 Lecture 5 33

5.1 Advection-Diffusion (upwind, implicit) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

5.2 Gradient calculation and reconstruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

5.2.1 Gauss Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

5.2.2 Least Squares Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

5.3 Checkerboard pressure problem and staggered grid concept . . . . . . . . . . . . . . . . . . . 35

5.4 Properties of the FVM matrix for Navier Stokes discretization . . . . . . . . . . . . . . . . . 36

5.5 SIMPLE algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

5.6 Finite Element Method: Intuitive introduction to the idea of Finite Element . . . . . . . . . . 39

5.7 Weak formulation of a scalar transport equation . . . . . . . . . . . . . . . . . . . . . . . . . 39

6 Lecture 6 40

6.1 Galerkin 1-D elements, local matrix derivation . . . . . . . . . . . . . . . . . . . . . . . . . 40

6.2 Global matrix assembly process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

2
6.3 Reference elements and geometry transformation . . . . . . . . . . . . . . . . . . . . . . . . 43

6.3.1 2D linear triangular element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

6.3.2 2D linear quad element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

6.4 Gauss quadratures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

6.5 Boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

6.5.1 Neumann Boundary condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

6.5.2 Dirichlet boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

6.5.3 Robin boundary condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

7 Lecture 7 47

7.1 Reference elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

7.1.1 Linear quad element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

7.1.2 Linear triangular element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

7.1.3 Higher order elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

7.2 Geometry transformation in 2D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

7.3 Incompressible Navier Stokes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

7.3.1 Checkerboard problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

7.3.2 Stabilization of highly convective problems . . . . . . . . . . . . . . . . . . . . . . . 51

7.3.3 Navier Stokes equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

7.3.4 Open boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

7.3.5 Vector notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

7.3.6 Nonlinearity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

7.4 Boundary Element Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

7.5 Other numerical techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

7.5.1 Timestepping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

3
7.5.2 Linearization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

7.5.3 Limiters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

8 Heat Transfer - Michał Kurzynka 57

8.1 Conduction and convection equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

8.2 Some dimensionless numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

8.3 Analogy with electrical current . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

8.4 How to calculate the thermal conductivity at the interface? . . . . . . . . . . . . . . . . . . . 65

4
1 Basic flow and heat transfer models

1.1 Repetition of different models

Transfer heat conduction is described by Fourier law (1.1),

~q = −λ · ∇T (1.1)

where:

• ~q - heat flux

• λ - thermal conductivity of material

• ∇T - gradient of temperature field

Diffusion is described by different, Fick’s law (1.2),

q = −D · ∇c (1.2)

where:

• q - heat

• D - coefficient that describes intensity of diffusive mixing

• ∇c - gradient of concentration

For convection, it means that you have some quantity like thermal energy or mechanical momentum, and it is
transported with moving fluid(1.3),
φ = ~u · ~n · e (1.3)
where:

• ~u - velocity

• ~n - unit normal vector

• e = ρ · cp · T -thermal energy

Equation (1.3) can be also written for momentum and than we get another equation (1.4)
~ = (~u · ~n) · (ρ~u)
φ (1.4)

5
We want to calculate how quickly particular quantity change inside of the volume From equations (1.1), (1.2)
and (1.4) we can construct a typical conservation law(1.8).
Z Z Z Z

udΩ = − (~u · ~n) · udΓ + λ∇u · ~ndΓ + qv dΩ (1.5)
∂t Ω Γ Γ Ω
Where Γ = ∂Ω is boundary of some domain Ω. Using Gaussian theorem for scalar quantity (1.6) and vector
quantity (1.7). Z Z
p · ~ndΓ = ∇pdΩ (1.6)
Γ Ω
Z Z
~v · ~ndΓ = (∇ · ~v ) dΩ (1.7)
Γ Ω
Substituting equations (1.6) and (1.7) to the typical conservation law (1.8) give us:
Z Z Z Z

udΩ = − ∇ (~v · u) · dΩ + ∇ (λ∇u) · dΩ + qv dΩ (1.8)
∂t Ω Ω Ω Ω
Transforming equation (1.8).
Z   Z
∂u
+ ∇ (~v · u) dΩ = [∇(λ∇u) + qv ] dΩ (1.9)
Ω ∂t Ω
If domain Ω is chosen arbitrary than equation (1.9) will change into differential equation (skip integrals).
∂u
+ ∇ (~v · u) = ∇(λ · ∇u) + qv (1.10)
∂t
In equation (1.10) particular elements are:

∂u
• ∂t - time derivative
• ∇ (~v · u) - convection derivative
• ∇(λ∇u) - diffusion term
• qv - source term

Assuming that λ = const we get divergence of gradient which can be called Laplacian(∆).
∇(λ∇u) = λ∇ · (∇u) = λ∆u
When we are considering stationary flow without any source we get Advection-Diffusion equation (1.11).
~v · ∇u = λ∆u (1.11)
Considering 1-D case Advection-Diffusion equation (1.11) transform into:
∂u ∂2u
a
=λ 2
∂x ∂x
Often, when we are considering incompressible fluid we know that ∇~v = 0. This lead us to Laplace equation.
−λ∆u = 0 (1.12)
When we add source term on the right side of Laplace equation (1.12 )we will get Poisson equation.
−λ∆u = f (1.13)

6
1.2 Boundary conditions

• first type boundary condition (Dirichlet Boundary Condition) - value

u|boundary = w

• second type boundary condition (Neumann Boundary Condition) - flux

−~n · ∇u|boundary = q

• third type (Robin Boundary Condition) - NOT MIXED!!!

−~n · ∇u + cu = f

Very often Robin boundary condition is represented by

~q = −α(T − T∞ )

Mixed boundary condition is when in some place of boundary we set different type of boundary condition than
in other.

1.3 Flow

∂u
+ ∇ (~v · u) = ∇(λ · ∇u) + qv
∂t
When in typical conservation law (1.10) we replace u with density ρ and we skipped mass diffusion and mass
source term (not physical) we will get mass conservation law (continuity equation)
∂ρ
+ ∇ · (ρ~v ) = 0 (1.14)
∂t
After adding assumption that density is constant ρ = const (almost all liquids and gasses with Mach number
less than 0.3) we get:
∇ · ~v = 0 (1.15)
When in typical conservation law (1.10) we replace u with ρ~v we will get momentum conservation equation.
In which diffusion of momentum is cause by internal forces given by Stress-Strain Correlation (1.16).

T = −pI + 2µḊ (1.16)

 
1 ∂ui ∂uj
Ḋij = + (1.17)
2 ∂xj ∂xi
∂ρ~v  
+ ∇ · (~v × ρ~v ) = −∇ · (pI) + ∇ · 2µḊ + f~0 (1.18)
∂t

7
where µ[P a · s] is dynamic viscosity.

    
ρv1 ρv1 v1 ρv1 v2 ρv1 v3
∇ · (~v × ρ~v ) = ∇ [v1 , v2 , v3 ] ×  ρv2  = ∇  ρv2 v1 ρv2 v2 ρv2 v3  =
ρv3 ρv3 v1 ρv3 v3 ρv3 v3
∂ ∂ ∂ ∂ ∂ ∂ (1.19)
= (ρv1 v1 ) + (ρv1 v2 ) + (ρv1 v3 ) + (ρv2 v1 ) + (ρv2 v2 ) + (ρv2 v3 )+
∂x1 ∂x2 ∂x3 ∂x1 ∂x2 ∂x3
∂ ∂ ∂
+ (ρv3 v1 ) + (ρv3 v2 ) + (ρv3 v3 )
∂x1 ∂x2 ∂x3
Let’s consider equation (1.19 for x-direction.

∂v1 ∂v1 ∂v2 ∂v1 ∂v3 ∂v1


ρv1 + ρv1 + ρv1 + ρv2 + ρv1 + ρv3 =
∂x1 ∂x1 ∂x2 ∂x2 ∂x3 ∂x3
  (1.20)
∂v1 ∂v2 ∂v3 ∂v1 ∂v1 ∂v1
= ρv2 + + + ρv1 + ρv2 + ρv3
∂x1 ∂x2 ∂x3 ∂x1 ∂x2 ∂x3

If density is constant ρ = const we can transform equation (1.18) into:

∂~v  
ρ + ρ~v · ∇~v = −∇ · (pI) + ∇ · 2µḊ + ρF~0 (1.21)
∂t
Sometimes we use equation (1.21) in other form(1.22.)

∂~v 1  
+ ~v · ∇~v = − ∇ · (pI) + ∇ · 2ν Ḋ + F~0 (1.22)
∂t ρ
where ν is kinematic viscosity.
µ m2
 
ν= (1.23)
ρ s
Finally we have 4 equation written bellow:
 2 
∂ 2 vx ∂ 2 vx

∂p
ρ ∂v
∂t
x
+ ρv x
∂vx
∂x + ρv y
∂vx
∂y + ρv z
∂vx
∂z = − ∂x + µ ∂ vx
2 + 2 + 2 + fx
 ∂v ∂vy ∂vz 

x


 ∂v ∂v ∂v ∂v ∂ 2v ∂ 2v ∂ 2v
y y y y ∂p y y y
∂t + ρvx ∂x + ρvy ∂y + ρvz ∂z = − ∂y + µ  ∂vx2 + ∂vy2 + ∂vz2  + fy

ρ
(1.24)
∂vy ∂v ∂v ∂v ∂p ∂2v ∂2v ∂2v


 ρ ∂t + ρvx ∂xy + ρvy ∂yy + ρvz ∂zy = − ∂y + µ ∂v2y + ∂v2y + ∂v2y + fy
 x y z
 ∂vx ∂vy
 ∂vz
∂x + ∂y + ∂z = 0

8
1.3.1 Channel and pipe flow

Figure 1: Channel flow

Boundary condition for channel flow:

• no slip condition, velocity vector at the wall is equal to 0

• velocity inlet, pressure outlet (numerically most most stable pair of boundary conditions)

In channel flow, system of equation (1.24) can be written as:


 2 
∂p ∂ vx
0=− +µ + fx (1.25)
∂x ∂vy2

Sometimes in order to accelerate flow, external force term can be used to introduce fluid acceleration in channel.
Friction losses can be calculate with using equation (1.26)

F~wall = −~n · (2µḊ) (1.26)

Amount of friction on the wall is defined by equation (1.27).


∂vx
τ = −µ (1.27)
∂y
Friction coefficient is defined as:
Fwall
cf = 1 2
(1.28)
2 ρv∞
where v∞ is free stream velocity. For example typical friction coefficient for channel and flat plate is given by
equation (1.29).
−1
cf = 0, 0592 · Rex 5 (1.29)
Where Rex is Reynolds number based on the x-coordinates (1.30).
v∞ · x
Rex = (1.30)
ν

9
1.3.2 Turbulence
(
∂~v
∂t + (~v · ∇) ~v = − ρ1 ∇p + ν∆~v + f~
(1.31)
∇ · ~v = 0
In turbulence modelling we are using average velocity and pressure. Additionally to simulate turbulence we
add turbulent viscosity µT to physical one µ. So as to model turbulence viscosity we can use for example k − ω
model or any other.
∂~v 1  
+ ~v · ∇ ~v = − ∇p + ∇ · 2(µ + µT )Ḋ + f~

(1.32)
∂t ρ

1.3.3 Porous Media Flow

The flow in porous media is often described by Darcy’s Law (1.33).


K
~q = − · ∇p (1.33)
µ
where:

• µ - dynamic viscosity

• K m2 - permeability (order of magnitude ∼ 10−12 )


 

• ∇p - pressure gradient

• q=Q
m
A s - instantaneous flux, discharge per unit area, superficial velocity

Porosity ϕ is defined as:


Vporous
ϕ= (1.34)
Vtotal
Physical velocity is:
~q
~v = (1.35)
ϕ
For flows with higher velocity we apply Darcy’s Forchheimer law.

µ ρ ~q
∇p = − ~q − · q2 · (1.36)
K K2 ||~q||

ϕ = const (1.37)

∇ · ~v = 0 (1.38)

10
When we put Darcy’s law (1.33) into equation (1.35) and apply divergence for both side we get:
1K
∇~v = − · ∇ · (∇p) = 0 (1.39)
ϕµ
Permeability doesn’t need to be a scalar value. It can also be a tensor for materials which have different perme-
ability in different direction (i.e. wood - diagonal terms).
 
K11 K12 K13
K =  K21 K22 K23  (1.40)
K31 K32 K33
In porous media flow there aren’t any significant numeric issues. For interface tracking we can use:

• PLIC
• level set function

1.4 Conductivity heat transfer

Fourier law that gather conductive heat transfer.

~q = −λ∇T (1.41)

Transport equation for thermal energy.


∂T
ρcp = ∇ · (λ∇T ) + qv (1.42)
∂t
For heat transfer we can apply all 3 types of boundary condition.

• 1st type Boundary Condition (Dirichlet Boundary Condition)

T = T (~x, t) (1.43)

• 2nd type Boundary Condition (Neumann Boundary Condition)

− (λ∇T ) · ~n|Γ = q (1.44)

• 3rd type Boundary Condition (Robin Boundary Condition)

− (λ∇T ) · ~n + C · T |Γ = f −→ q = α (T − T∞ ) (1.45)

Thermal diffusivity, which is material parameter, is given by:


λ m2
 
a= (1.46)
ρcp s

11
2 Lecture 2

2.1 Convective heat transfer

Let’s remind the conservation of the momentum law


∂u
+ ∇ (~v · u) = ∇(k · ∇u) + qv (2.1)
∂t
Now, if we substitute u with thermal energy u = eT = ρcp T we will obtain convection-diffusion equation.

∂ρcp T
+ ∇ (~v · ρcp T ) = ∇(k · ∇ρcp T ) + qv (2.2)
∂t
λ
where k = ρcp .

In most cases the equation can be simplified, as ρ = const and cp = const, and solved for T. However, if those
values are not constant, one should follow the following scheme:

1. write equation for eT

2. solve for eT

3. solve for T = f1 (eT )

4. calculate cp = f2 (T )

Let’s assume we are given a coupled problem of a solid and a fluid. In such cases always remember to apply
boundary conditions to the boundaries of the domain, not between the solid and the fluid. The interaction
between those two bodies will be represented in the equations.

2.2 Radiative heat transfer

Radiative heat transfer is described by Stefan Boltzmann law

qr = σST 4 (2.3)

where  = 5, 67 · 10−8 mW
2 K 4 is the Boltzmann constant.

This means that each body will radiate thermal energy in every direction. Now, let’s imagine the body radiates
on to the surface. The energy will either be absorbed or reflected or transmitted.

α+ρ+τ =1 (2.4)

12
2.3 Heat transfer in porous media

Let’s consider that fig.2.3 shows a section of a larger structure, for instance a radiator. Instead of calculating
heat transfer of the radiator, we want to simplify it by porous media. To do so, we need to calculate equivalent
coefficients.

Firstly, let’s calculate the porousity, which is given by the porous area to total area ratio. In our case ϕ = 14
24 .
Assume we apply Dirichlet boundary conditions equal to 1 on the right hand side and 0 on the right hand side
of the structure. Comparing real case with porous one we obtain

∂T 1
|Q̇| = λx · · S = λx · · 6 (2.5)
∂x 4

1
|Q̇| = 2 · λ · ·1 (2.6)
5
Hence
4
λx = λ (2.7)
15
Analogously, we can calculate λy coefficient, if we apply boundary conditions equal to 1 on the upside and 0
on the downside of the structure.
1
|Q̇| = λy · · 4 (2.8)
6
1
|Q̇| = 2 · λ · ·1 (2.9)
10
Hence
3
λy = λ (2.10)
30

13
In this case, fluid is treated as an external source. Therefore

q = αSv (Tf − Ts ) (2.11)

As a result, we obtain convection equation

∂T ∂T
−∇(λx + λy ) = αSv (Tf − Ts ) (2.12)
∂x ∂y

2.4 Chemical reactions

In general, chemical reactions are described by the following equation

aA + bB ⇐⇒ cC + dD (2.13)

where substrats are on the left hand side and products on the right hand side.

The rate of the reaction is described by the following

1 d[A] 1 d[B] 1 d[C] 1 d[D]


v=− =− = = (2.14)
a dt b dt c dt d dt
Also
v = k[A]α [B]β − kr [C]γ [D]δ (2.15)
where Arrhenius formula describes k and kr by
EA
k = Aexp(− ) (2.16)
RT
Coefficient EA and A can be found in Janof tables.

In CFD we usually have


dcC EA
= Aexp(− ) · cA cB − reverse (2.17)
dt RT
What set of equations is needed?

• mass conservation equation for the mixture

• advection-diffusion equation for n-1 substances


it’s good to set the most dominant substance as cn = 1 − n−1
P
i=1 ci
RT
• energy (entalpy) equation H = Tref ep (τ )dτ + Hf or is used to calculate T

• nonlinear source terms

14
For instance, advection-diffusion equation for evaporation
∂ρH2 O
+ ∇ (ρH2 O · ~v ) = ∇(D · ∇ρH2 O ) + sH2 O (2.18)
∂t
νT
Where, in the case of turbulent flows, D = DT + Sct .

Such equations are stiff, therefore have to be integrated by special functions (ode15s etc).

2.5 Numerical never-forgets

Discretisation splits into two different things: discretisation of space and time, and discretisation of equations.

2.5.1 Discretisation of space

1D:

2D:

Delaunay triangulation:

• for a set of points

• such that no point is in circumcircle of any triangle

• can always be generated

• Matlab command DT = delaunay(P)

3D:

15
• Delaunay triangulation works for 3D cases and generates tetra mesh
• mesh can be created with either tetra or bricks or everything
• everithing can be consistently subdivided into tetra

2.5.2 Discretisation of time

Not necessarily uniform (constant time step size).

2.5.3 Discretization of equations

The main idea of the discretization is to switch from infinite dimensional function space to a finite set of algebraic
equations, which are computable for a computer.
du un+1 − un
= −λu −→ = −λun (2.19)
dt ∆t
A scheme that is

• stable
• consistent

is also convergent!!!

It’s essential to properly set mesh size where gradients are supposedly high. Otherwise we can get some devia-
tions from the solution, for example while calculating heat flux or friction force.

16
3 Lecture 3

3.1 Approximation of derivatives

In numerical methods it is necessary to calculate approximate values of function derivatives using values of
functions in some arbitrary chosen points in space. In order to obtain the most accurate approximation one
assumes that derivative of the function can be calculated as linear combination of values of analysed function
in certain points in space and uses Taylor series expansion to derive the proper coefficients. The procedure of
deriving that formula is as follows:

• Discretize space into set of points: xi = x0 + ij=1 ∆xi . The simplest discretization pattern assumes
P
regular spacing ∀i ∆xi = h. This spacing will be used in all further equations.

• Choose finite subset of points which you want to use to create the approximation scheme (for example
{xi−1 , xi , xi+1 }).

• Expand function in Taylor series in selected points:

fi+1 = fi + hfi0 + 12 h2 fi00 + 16 h3 fi000 + ...


fi = fi
fi−1 = fi − hfi0 + 12 h2 fi00 − 16 h3 fi000 + ...

• Calculate the coefficients of linear combination

fi00 ≈ afi−1 + bfi + cfi+1

by substituting Taylor series expansion into the equation written above. System of equations to solve is
obtained from comparison of the lowest order terms.

a + b + c = 0

−ha + hc = 0

1 2 1 2
2h a + 2h c = 1

The most frequently used approximations of derivatives obtained from that scheme:

• First derivative forward scheme:


df fi+1 − fi
=
dx i h
• First derivative backward scheme:
df fi − fi−1
=
dx i h

17
• First derivative central scheme:
df fi+1 − fi−1
=
dx i 2h
• Second derivative scheme:
d2 f fi+1 − 2fi + fi−1
2 =
dx i h2

3.2 Convergence plots, method’s order

In order to test implemented numerical method rigorously one should create convergence plots. Convergence
plot presents the dependence between the discretization described by parameter h (it’s often the time step size
or spatial mesh spacing) and the error norm ε. The most often used norms are:

• L2 − norm: sZ
ε = ||u − ū||2 = |u − ū|2 dΩ

• Maximum norm:
ε = ||u − ū||max = max(|u − ū|)

where u and ū denote numerical solution and exact solution respectively. As it can be seen from the equations
above in order to create convergence plots one needs the exact solution of the problem. Therefore convergence
plots are based on data form numerical solutions of problems that have well known analytic solution.

Figure 2: Example convergence plot

18
The order of numerical method is the number p for which:

ε ≤ Chp

where C is a constant number. According to that definition it’s possible to read the order of numerical method
from logarithmic convergence plot:

Figure 3: Example logarithmic convergence plot

The order of numerical method is the slope of the line on that plot.

3.3 Mesh sensitivity/independency study

A good practice after creating a new geometry and a new mesh is conducting the mesh sensitivity/independency
study. It is analysis of dependency between some calculated values in your solution (for example forces, strains,
fluxes etc.) and parameters characterizing created mesh (for example cell sizes, spacing etc.). For enough
refined mesh computed values should not differ to much, but when the mesh is too coarse it is possible to
observe change of calculated value.

19
Figure 4: Example dependency between calculated force and mesh spacing

Plots such as this one seen above give information about parameters of the mesh which should be used in
created model. If one obtains many different results using different meshes then he should refine the mesh until
he obtains similar values.

3.4 Heat convection calculation in anisotropic materials

Consider 2D heat flux in material which thermal conductivity is given by a tensor:


 
k1 0
K=
0 k2

The heat flux can be obtained form Fourier law:

q = K∇T

Term in heat convection equation is as follows:

d2 T d2 T
∇ · q = ∇ · (K∇T ) = k1 + k2 =0
dx2 dy 2
It’s possible to convert this equation to:
d2 T d2 T
+ =0
dξ 2 dη 2
by performing simple substitution:
x(ξ) = ξ
y(η) = αη

20
q
where ξ and η are new variables and α = kk12 is a scalar constant. Therefore it’s possible to solve that equation
using standard Laplace equation solver. It’s not necessary to implement new one which enables conductivity
matrix input. After solving Laplace equation results have to be scaled to obtain the solution of anisotropic heat
convection.

3.5 1D FDM discretization and implementation

Let’s consider the one dimensional diffusion problem:


∂2u
−ν =f
∂x2
Using finite differences scheme for the second derivative calculated on one dimensional uniformly disctretized
space the numerical representation of the equation above is:
ui+1 − 2ui + ui−1
−ν = fi : x ∈ [a, b]
h2
For the sake of example let’s assume that the boundary conditions are:

• Dirichlet boundary condition on the left edge of the domain:



u =5

x=a

• Neumann boundary condition on the right edge of the domain:


du
=0
dx x=b

The finite difference discretizations of that problems are:

• Dirichlet boundary condition discretization:


u1 = 5

• Neumann boundary condition discretization:


un − un−1
=0
h

In order to find the solution of that problem the matrix formulation has to be implemented:
  u   5 
1 0 0 0 ··· 0 1
 −ν2 2ν2 −ν2  u2   f2 
h h h
0 ··· 0     
 0 −ν2 2ν2 −ν2 0  ..   .. 
h h h  .   . 
  
..  =  .. 


0 . .. . .. . .. 0  

 .   . 
−ν −ν  
 2ν

 0 ··· 2 2 2 un−1
  
fn−1 
h h h   
0 ··· ··· 0 1 −1 un 0

21
The nonsingular linear system of equations with tridiagonal matrix has been created. It can be solved by tridi-
agolanl matrix algorithm or iterative solvers such as Gauss-Saidel method.

3.6 FDM: Stability of the schemes

In this paragraph the stability of the finite difference method will be analysed on the example of advection
equation:
∂u ∂u
=a
∂t ∂x
The following convention of the notation is adopted: unj denotes value of function from the advection equation
in the spatial node number i in the n-th time step. The simplest finite difference discretization of the advection
equation called the explicit Euler method is as follows:
un+1
j − unj unj+1 − unj−1
=a (3.1)
∆t 2h
That scheme can be illustrated by a stencil:

Figure 5: Explicit Euler discretization stencil

This numerical scheme and other possible finite difference schemes are consistent, because they are derived
form Taylor series expansions, however it is not guaranteed they are stable and convergent. In order to check
the stability of numerical schemes it is necessary to conduct von Neumann stability analysis. At first assume
that exists decomposition of numerical solution:

unj = Njn + εnj (3.2)

Njn denotes the exact analytical solution in the discretization node and the εnj is the numerical error. Plugging
the decomposition [3.2] into [3.4] leads to conclusion that the numerical error satisfies the same equation [3.4]:

εn+1
j − εnj εnj+1 − εnj−1
=a (3.3)
∆t 2h
The numerical scheme is stable if and only if the error decreases in each iteration. The numerical error can be
decomposed using the Fourier’s function decomposition:

εnj = E(t)eikxj

22
where xj denotes the x coordinate of the j-th node. Assuming uniformly spaced nodes there hold equalities:
xj+1 = xj + h, xj−1 = xj − h. After substituting that decomposition into [3.3] the relation between εn+1
j and
εnj is as follows:
εn+1
j a∆t ikh a∆t
=1+ (e − e−ikh ) = 1 + i sin (kh)
εnj 2h h
εn+1
The scheme is stable if and ony if || jεn || < 1. Because ||1 + i a∆t
h sin (kh)|| ≥ 1 the explicit Euler scheme
j
is unconditionally unstable. The next possible scheme of discretization of advection equation is Implicit Euler
method:
un+1
j − unj un+1
j+1 − uj−1
n+1
=a (3.4)
∆t 2h
which can be represented graphically as:

Figure 6: Implicit Euler discretization stencil

Using the same procedure it is possible to prove that by contrast to Explicit Euler scheme the Implicit Euler
scheme is unconditionally stable. However in Implicit Euler scheme it is necessary to solve system of linear
equations to calculate the solution in the next time step. The other discretization scheme is the upwind scheme.
Assuming that a < 0 the upwind scheme is given by:

un+1
j − unj unj − unj−1
=a
∆t h
and can be represented by a stencil:

Figure 7: Upwind discretization stencil

23
In case of a > 0 the upwind scheme has to be modified:

un+1
j − unj unj+1 − unj
=a
∆t h
The procedure of von Neumann stability analysis gives the condition of stability of the upwind scheme. It’s
called the Courant-Friedrichs-Lewy condition:
a∆t
<1
h
Most of numerical schemes used to solve more complicated equations than the advection equation are condi-
tionally stable. Therefore it’s highly recomended to conduct von Neumann stability analysis of the implemented
numerical procedures to create discretization which satisfies received conditions.

4 Lecture 4

4.1 Approximation in discretization

The time and space Cauchy development

un+1 − uni ∂uni 1 ∂ 2 un 1 ∂ 3 un


i
= + ∆t 2i + (∆t)2 3i + ...
∆t ∂t 2 ∂t 6 ∂t

uni − uni−1 ∂un 1 ∂ 2 uni 1 3 n


2 ∂ ui
a = a i + a∆x + a(∆x) + ...
∆x ∂x 2 ∂x2 6 ∂x3

bring to the advection upwind discretization:

un+1 − uni un − uni−1


i
+a i ≈0
∆t ∆x

Note the approximation made when summing both Cauchy development to form the discretization. In order to
have a true equality, we should have:

∂uni 1 ∂ 2 un 1 ∂ 3 un ∂un 1 ∂ 2 uni 1 3 n


2 ∂ ui
+ ∆t 2i + (∆t)2 3i + a i + a∆x + a(∆x) + O((∆x)2 , (∆t)2 ) = 0
∂t 2 ∂t 6 ∂t ∂x 2 ∂x2 6 ∂x3

We can imagine that the second order coefficient (∆x)2 and (∆t)2 will converge quickly to zero when decreas-
ing the time and space steps, so we will neglect them. By rearranging it, we got:

24
∂uni ∂un 1 ∂ 2 uni 1 ∂ 2 uni
+a i + ∆t 2 + a∆x 2
+O((∆x), (∆t)) = 0
|∂t {z ∂x} |2 {z∂t } |2 {z ∂x }
advection equation dynamical response diffusive term

We observe that the non-neglected terms produce space diffusion or a dynamical response. The dynamical
response will be observed by numerically-created oscillations.

If this problem is just a test problem, you can solve the equation below instead to neutralize the diffusion term.

∂uni ∂un a ∂ 2 uni


+ a i = ∆x
∂t ∂x 2 ∂x2

4.2 Steady-state advection-diffusion equation

∂u ∂2u
a =ν 2
∂x ∂x

In the upwind scheme, we’ll use the direction of the information (± x) to choose whether we’ll use the element
on the right hand side or on the left hand side (figure 8). The dircretization becomes:

ui − ui−1 ui+1 − ui ui+1 − 2ui + ui−1


max(a, 0) + min(a, 0) −ν =0
∆x ∆t (∆x)2

Figure 8: Space discretization with the information propagation direction a.

We got the solution in the figure 9 herebelow:

25
Figure 9: Different solutions of the advection-diffusion equation.

a∆x
The use of the central scheme for this equation requires P e = ν ≤ 2. Otherwise, it will create wiggles,
depicted on the figure 10 below.

Figure 10: Wiggles created by the central scheme in red and the real solution in black.

Because this condition is very hard to be satisfied, we better us the upwind scheme. However, the upwind
scheme produces numerical diffusion as we saw previously.

Let’s see now how the matrix looks like. If a > 0, then:

26
   
ν a 2ν a 2ν
− ui+1 + + ui − + ui−1 = 0
(∆x)2 ∆x (∆x)2 ∆x (∆x)2
| {z } | {z } | {z }
B A A

    
u1 1

1 0 0 0 ··· 0
−A A  u2  0
B 0 ··· 0    

 ...   ... 

 .. .. .. .. ..     
 0 . . . . .· ..  =  .. 
  
 ..

.. .. .. ..  
. 
 . . . . . 0  .
  
B   ..   ... 
.
  
 0 ··· 0 −A A
   
0 ··· 0 0 0 1 un 0

with BCs: u(x = 0) = 1 and u(x = 1) = 0.

4.3 Differential equation in 2D

Let’s take the 2D differential equation on a 5 × 5 nodes grid (figure 11).

Figure 11: 2D mesh.

We obtain the matrice shown in figure 12.

27
Figure 12: Matrice for the differencial equation.

   
−4 1 0 ··· 0 1 0 ··· ··· 0
 1 −4 1 0 0 ···
0 1 0 0
 
 
with D = 
 0 1 −4 1 0  and I = 0 0
  1 0 0.
0 0 1 −4 1  0 · · · 0 1 0
0 ··· 0 1 −4 0 ··· ··· 0 1

4.4 FINITE VOLUME METHOD

Let a cell-centered FVM mesh be. Let’s call Ωv the volume (or surface in 2D) of one cell of the mesh and Γv
its surface (or perimeter in 2D).

∂u
+ ∇ · (~v · u) = ∇ · (λ∇u) + f
Z Z ∂t Z Z
∂u
dΩ + ∇ · (~v · u) dΩ = ∇ · (λ∇u) dΩ + f dΩ
Ωv ∂t Ωv Ωv Ωv

R
Let be |V | = Ωv dΩ. Then

Z
∂u ∂
dΩ = ū |V |
Ωv ∂t ∂t
Z
f dΩ = f¯ |V |
Ωv

According to the Gaussian theorem, with (f ) the faces or segments constituting Γv and |Af | the surface or
length of the face or segment f , we can write:

28
Z I
∇ · (~v · u) dΩ = ~n · (~v · u) dΓ — the convective flux
Ωv Γv
X
= n~f · v~f · uf |Af |
(f )
Z I
∇ · (λ∇u) dΩ = ~n · (λ∇u) dΓ — the diffusive flux
Ωv Γv

X ∂u
= λf · |Af |
∂n f
(f )

4.4.1 How to store a cell volume?

1. Nodes (coordinates)

2. Cells (connectivity matrix): link the node to the cells they belong

3. Neighbours: creating a matrix with each row i listing the neighbours of the cell i

4. BCs: listing all the boundary cells

OR

1. Nodes (coordinates)

2. Faces: link the node to the faces they belong

3. Ids of the cells

With infinite precision, the FVM is conservative: the fluxes from one cell always goes to other (neighbouring)
cells.

4.4.2 How to find neighbouring cells?

We already have the node coordinates. Let’s take as example the mesh shown in the figure 13.

29
Figure 13: Example of a hexahedron mesh.

We create a table showing the cells sharing the same nodes:

Node id Cells id
1 1
2 1 2 3
3 3 5
4 2 3 4 5
5 1 2 4
6 4
7 5
8 5

Table 1: Caption

For instance, in row 3 and 4, the cells that share those points have the id 3 and 5; the cells number 3 and 5 are
neighbours. In the same way, we observe that the nodes 2 and 4 are shared by the cells 2 and 3, which mean
they are neighbours. It is interesting to note that the points which are part of one cell only are useless in this
process and we can already count them in the boundary.

4.4.3 Interpolation in FVM?

Let us take an example of two cells which have different thermal conductivity. Cell 1 has a thermal conductivity
of λlow and cell 2 λhigh (figure 14).

30
Figure 14: Two cells made of two different materials.

Our aim is to define the thermal conductivity on the shared face. A first intuition could be to interpolate by
assigning an average value:
λlow + λhigh
λf ace =
2
But this does not reflect the reality. Take a look to the example in figure 15.

Figure 15: Two cells made of two different materials.

Let set λ1 = 1 and λ1 = 5. Because the FVM is conservative, the heat flux through the shared face (Qf ) must
be equal to the one in the cell 1 (Q1 ) and 2 (Q2 ); the temperature distribution respects this conservation law.
With the interpolation, we would have:

31
∆T1 −5
Q1 = −λ1 = −1 =5
∆x 1
∆T2 −1
Q2 = −λ2 = −5 =5
∆x 1
λ1 + λ2 ∆Tf
Qf = − = −3 × −3 = 9
2 ∆x

We have to find another formula for the thermal conductivity at the face. Back to the general case presented in
figure 14, we’ll find:

Tf − T1 Q1 ∆x
Q1 = −λlow |Af | ⇒ Tf − T1 =
∆x/2 2|Af |λlow
T2 − Tf Q2 ∆x
Q2 = −λhigh |Af | ⇒ T2 − Tf =
∆x/2 2|Af |λhigh
T2 − T1 Qf ∆x
Qf = −λf |Af | ⇒ T2 − T1 =
∆x |Af |λf

T2 − T1 = (T2 − Tf ) + (Tf − T1 )
Qf ∆x Q2 ∆x Q1 ∆x
⇒− =− −
|Af |λf 2|Af |λhigh 2|Af |λlow
 
1 1 1 1
⇒ = +
λf 2 λhigh λlow

If we verify this new formula on the example depicted on figure 15, we got:

 
1 1 1 1 3 5
= + = 0.6 = λf =
λf 2 λ2 λ1 5 3

∆Tf 5
Qf = −λf = − (0.5 − 3.5) = 5
∆x 3

We finally found an expression for the thermal conductivity on the face which satisfies the conservation law
Q1 = Q2 = Qf .

32
5 Lecture 5

5.1 Advection-Diffusion (upwind, implicit)

We will use Advection-Diffusion equation with implicit and upwind scheme of discretization.

Figure 16: Portion of the grid with chosen cell

Z Z
~nf ~vf uf dΓ − ~nλ∇uf dΓ = 0 (5.1)
Γv Γv
After applying discretization, we get:

X X ∂u
~nf ~vf uf |Af | − λf |Af | = 0 (5.2)
∂n f
(f ) (f )

In order to apply implicit upwind scheme into equation (5.2) we need to make sure that.


X X X uN,f − ui
max(0, ~np~vp )ui |Af | + min(0, ~np~vp )uN,f |Af | − λf |Af | = 0 (5.3)
d~N,f

(f ) (f ) (f )
f

Where uN,f is the value from the neighboring cell on a certain face, and d~N,f is the distance to the neighboring
centroid.
     
max(0, ~np~vp ) + λ  |Af | ui + min(0, ~np~vp ) − λ  |Af | uN,f = 0
X X
~ ~ (5.4)
(f ) dN,f (f ) dN,f

33
5.2 Gradient calculation and reconstruction

di,N

Figure 17: Portion of the grid with centroid

There are two popular ways to calculate gradient:

• Gauss Procedure

• Least Squares Procedure

5.2.1 Gauss Procedure


Z Z
∇pdΩ = p · ~ndΓ (5.5)
Ωv Γv

In finite volume method equation (5.5) can be written as (5.6):


X
∇p · |v| = pf · ~nf |Af | (5.6)
(f )

5.2.2 Least Squares Procedure

We can represent uN,f as:


uN,f = ui + ∇ui · d~i,N + ... (5.7)
Several higher-order methods take into account not only the value at the neighbors’ cell but also its gradient.

• Higher-Order Upwind Schemes

• QUICK Scheme

34
5.3 Checkerboard pressure problem and staggered grid concept

Figure 18: 1-D Mesh

Discretized Navier-Stokes equation for 1-D case.

∂vi ∂vi 1 ∂2u


+ vi · = − ∇p + ν 2 − kvi (5.8)
∂t ∂x ρ ∂x

div ~v = 0 (5.9)
In most cases, when discretizing pressure, we would store it at the same point as velocity. However, it would
cause a singularity in the problem which means an algorithm is wrongly defined.

Figure 19: Checkerboard pressure pattern

Typically we would transfer the place of storing velocity creating a staggered grid.

Figure 20: Staggered Grid 1-D

35
Figure 21: Staggered Grid 2-D

5.4 Properties of the FVM matrix for Navier Stokes discretization

Let’s look at the Navier Stokes equation in the 2D case.

∂ 2 vx ∂ 2 vx
 
∂vx ∂vx ∂vx 1 ∂p
+ vx + vy =− +ν + (5.10)
∂t ∂x ∂y ρ ∂x ∂x2 ∂y 2

Each equation for a specific direction can be written as:

M · vx + C · vx = −Sx · p − D · vx (5.11)

Where:

• M - mass, inertia matrix

• C - convection matrix

36
• S - matrix applied to pressure

• D - diffusion matrix

    
M +C +D 0 Sx vx Fx
 0 M + C + D Sy   vy  =  Fy  (5.12)
SxT SyT 0 p 0

5.5 SIMPLE algorithms

For simplicity, let’s assume that there are three matrices.


 
M +C +D 0
A= (5.13)
0 M +C +D

 
Sx
B= (5.14)
Sy

C = BT (5.15)
Now formula (5.12) is written as:     
A S u F
= (5.16)
C 0 p 0

(
Au + Bp = F
(5.17)
Cu = 0
We can use the first equation from (5.16) to analytically calculate what is u.

u = A−1 (F − Bp) (5.18)

When we already have u we can plug it into the second equation from (5.16).

CA−1 F − CA−1 Bp = 0 (5.19)

CA−1 Bp = CA−1 F (5.20)


Knowing that the (5.15), we can transform it into (5.21).

B T A−1 Bp = CA−1 F (5.21)

37
Let’s make an initial guess of pressure p∗ , and then we will calculate the initial guess of velocity u∗ . We will
constantly improve these guesses.
u∗ = A−1 (F − Bp∗ ) (5.22)
We will assume that the correct physical value is the sum of the initial guess and some correction marked with
the upper index 0 .
u = u∗ + u0 (5.23)

p = p∗ + p0 (5.24)

(
Au0 + Bp0 = 0
(5.25)
C(u∗ + u0 ) = 0
Now let’s introduce the most important approximation in the SIMPLE scheme. This approximation replaces
matrix A with matrix D where D = diag(A).

Du0 + Bp0 = 0 (5.26)

Physical interpretation of this approximation in the finite volume method is that it neglects some portion of
diffusion from neighboring cells.
u0 = −D −1 Bp0 (5.27)

C(u∗ − D −1 Bp0 ) = 0 (5.28)

CD −1 Bp0 = Cu∗ (5.29)


The final step in the SIMPLE method is updating pressure and velocity with under relaxation coefficient α and
β.
p = p ∗ +αp0 (5.30)

u = u∗ + βu0 (5.31)

38
5.6 Finite Element Method: Intuitive introduction to the idea of Finite Element

Figure 22: Subdivided domain into the subdomains

Figure 23: Element with exactly known values at nodes

4
X
u(x, y) = Ui Ni (x, y) (5.32)
i=1

The Ni (x, y) is called shape functions.

5.7 Weak formulation of a scalar transport equation

~a · ∇u = ν∆u + f (5.33)

39
We will multiply the equation (5.33) by any arbitrary function v.

~a · ∇u · v = ν∆u · v + f · v (5.34)

Now, we will integrate the equation (5.34) over the whole domain.
Z Z Z
~a · ∇u · vdΩ = ν∆u · vdΩ + f · vdΩ (5.35)
Ω Ω Ω

v = const (5.36)

∇ · (∇u · v) = ∆u · v + ∇u · ∇v (5.37)
After applying the equation (5.37), we get:
Z Z Z
ν ∆u · vdΩ = ν ∇ · (∇u · v)dΩ − ν ∇u · ∇vdΩ (5.38)
Ω Ω Ω

Now we can put the formula (5.38) into the equation (5.35).
Z Z Z Z
~a∇u · vdΩ + ν ∇u · ∇vdΩ = f · vdΩ + ν ~n · ∇u · vdΓ (5.39)
Ω Ω Ω Γ

In the 1-D case, the equation (5.39) would look like this.
L L L
Z Z Z
∂u ∂u ∂v ∂u ∂u
a · vdx + ν · dx = f · vdx + ν ·v −ν ·v (5.40)
0 ∂x 0 ∂x ∂x 0 ∂x x=L ∂x x=0

The most important advantage of this formulation (5.39) - weak form, is that the second derivative in our
equation disappeared.is that the second derivative in our equation disappeared.

6 Lecture 6

6.1 Galerkin 1-D elements, local matrix derivation

For the sake of example we consider one-dimensional Poisson equation in weak form. The method of trans-
forming differential equations into the weak form was presented in the previous chapter.

Z Z
∂u ∂v ∂u x=L
dΩ = f v dΩ + v (6.1)
Ω ∂x ∂x Ω ∂x x=0
In order to derive finite elements method the solution domain has to be discretized into n elements and n + 1
nodes:

40
We assume that the x coordinate of the left boundary is xa = 0, the right x coordinate is xb = L and the sizes
of elements are all equal to ∆x = Ln . In the next step a set of test functions (also called shape functions) has to
be defined. The most common choice of test functions is defined as follows:


 0 if x < (j − 1)∆x
 x

∆x − (j − 1) if (j − 1)∆x ≤ x < j∆x
ϕj (x) = x (6.2)
 − ∆x + (j + 1) if j∆x ≤ x < (j + 1)∆x

0 if x ≥ (j + 1)∆x

where j = 1, 2, ..., n + 1 denotes the number of node.

Figure 24: Numeration of element nodes

The plot of that shape function for node number j = 4 is presented below:

Figure 25: Shape function for the 4th node

The other sets of test functions can be chosen, but they have to be the partition of unity. The numerical solution
is represented via nodal values uj and the test functions ϕj (x):
N
X
u(x) = uj ϕj (x)
j=1

41
The set of discretized equations is obtained by evaluating integrals in equation [6.1] with test functions plugged
as v into that equation and numerical solution plugged as u:
Z X N Z X N
∂ϕj ∂ϕi
uj dΩ = Fj ϕj ϕi dΩ (6.3)
Ω ∂x ∂x Ω
j=1 j=1

In the equation above Fj denotes the value of source term in j-th node. When test functions defined in [6.2]
are used the boundary term in the discretized equation cancels out. In most cases the values of Fj are known
explicitly. Thus the [6.3] is a system of linear equations where the uknowns are uj . In order to solve that problem
R ∂ϕ
the diffusion matrix with coefficients Dij = Ωi ∂xj ∂ϕ i
∂x dΩ has to be assembled. When local test functions are
used the only test functions which supports have nonzero measure intersection with the i-th element are test
function of the nodes adjacent to that element. Therefore the easiest way to assemble diffusion matrix is creating
the local matrices for each element separately and then assembling them into the global diffusion matrix. The
local matrices represent the components of the global diffusion matrix ensuing from integration of right hand
side of [6.3] over the i-th element: Z
∂ϕi ∂ϕi
d11 = dΩ
Ωi ∂x ∂x
Z
∂ϕi ∂ϕi+1
d12 = dΩ
Ωi ∂x ∂x
Z
∂ϕi+1 ∂ϕi+1
d22 = dΩ
Ωi ∂x ∂x
As it comes form the equations above the local diffusion matrices are symmetric.

6.2 Global matrix assembly process

After local diffusion matrices are created they have to be assembled into global diffusion matrix. In order to do
that elements of all local matrices have to be added to the initially all zero global matrix. Elements of i-th local
matrix are added to the global matrix following the scheme:
Dii = Dii + d11
Di,i+1 = Di,i+1 + d12
Di+1,i = Di+1,i + d21
Dii = Dii + d22
This scheme hold if the nodes and elements numbering scheme is consistent with this presented on figure 24.

Figure 26: General numeration of element nodes

42
Otherwise if the elements are not numbered ascendingly, but they belong to the set of indexes I = {i1 , ..., in }
for elements and J = {j1 , ..., jn+1 } for nodes, the local matrix for ik -th element are defined as:
Z
∂ϕjk ∂ϕjk
d11 = dΩ
Ωi ∂x ∂x
k

∂ϕjk ∂ϕjk+1
Z
d12 = dΩ
Ωik ∂x ∂x
∂ϕjk+1 ∂ϕjk+1
Z
d22 = dΩ
Ωik ∂x ∂x
Elements of ik -th local matrix have added to the global matrix following the scheme:

Djk ,jk = Djk ,jk + d11


Djk ,jk+1 = Djk ,jk+1 + d12
Djk+1 ,jk = Djk+1 ,jk + d21
Djk+1 ,jk+1 = Djk+1 ,jk+1 + d22

6.3 Reference elements and geometry transformation

The derivation of FEM in previous two chapters was done using equaivalently spaced subdivisions of the do-
main. In general the subdivisions in 1D and the shapes of elements in 2D or 3D are not identical. Thus the
different shape functions have to be defined in each element. It’s not efficient to store data of different shape
functions in each element. Therefore the other idea is employed. The one reference element and it’s shape
functions are defined. Then the shape function in each element are calculated using the mapping from reference
element to real element from mesh. The equation defining that mapping is the same for all elements and it
depends on coordinates of element points. The general formula for that mapping is:

→ −

x =−

x(ξ ) (6.4)


where −→
x denotes the coordinates of the element form mesh and ξ denote the coordinates of reference element.
The mappings from the equations above are defined via coordinates of the nodes of elements {Xi , Yi , Zi } and
the shape functions of reference element.
X −

x= Xj ϕj ( ξ )
(j)
X −

y= Yj ϕj ( ξ )
(j)
X −

z= Zj ϕj ( ξ )
(j)

43


That transformation is easy to perform if reference coordinates ξ = (ξ, η, ζ) are known. However if it’s
necessary to calculate −→
x = (x, y, z) coordinates the set of equations has to be solved. In case of nonlinear
shape functions this system of equations is nonlinear. The derivatives of shape functions that occur for example
in diffusion matrix derivation are then calculated via chain rule:
∂ϕi ∂ϕi ∂ξ ∂ϕi ∂η ∂ϕi ∂ζ
= + +
∂x ∂ξ ∂x ∂η ∂x ∂ζ ∂x
∂ϕi ∂ϕi ∂ξ ∂ϕi ∂η ∂ϕi ∂ζ
= + +
∂y ∂ξ ∂y ∂η ∂y ∂ζ ∂y
∂ϕi ∂ϕi ∂ξ ∂ϕi ∂η ∂ϕi ∂ζ
= + +
∂z ∂ξ ∂z ∂η ∂z ∂ζ ∂z
In order to compute integrals from [6.3] after transformation of shape functions and their derivatives to coordi-
nates ξ, η, ζ of reference element also volume element has to be transformed. That transformation is multipli-
cation of volume element by Jacobian of transformation [6.4].

∂xi
dΩ = dx dy dz = det( ) dξ dη dζ
∂ξj

The general formula for weak form of Poisson equation in case of one dimensional transformation is:
Z N Z N
X ∂ϕj ∂ξ ∂ϕi ∂ξ ∂xi X ∂xi
uj ( )( ) det( ) dΩ = Fj ϕj ϕi det( ) dΩ
Ωref j=1 ∂ξ ∂x ∂ξ ∂x ∂ξj Ωref j=1 ∂ξj

6.3.1 2D linear triangular element

6.3.2 2D linear quad element

6.4 Gauss quadratures

The matrix coefficients in FEM are obtained via calculation of integrals of shape functions and their derivatives.
It’s clear that the accuracy of that method strongly depends on chosen numerical scheme for approximation of
integrals. The most accurate and computationally efficient algorithm is the Gaussian integration. It approxi-
mates the integral by:
Z b p

X
f (x) dx = wi f (xi )
a i=1
 
where xi denote set of points in the interval a, b and (wi ) denote respective coefficients defined for that
interval. The gaussian quadratures are derived in a way that quadratures using p points should integrate with
infinite accuracy polynomials with degree up to 2p − 1. Therefore if shape functions are polynomialsgaussian

quadratures allow
 to integrate
 them with accuracy of computers finite arithmetic error. Each interval a, b can
be mapped into − 1, 1 . Thus it’s possible to evaluate any integral on that standard interval. The coefficients

44
wi for integral on standard interval can be found in engineering tables. Analogously surface and volumetric
gaussian quadratures are defined on standardized ploygons and polyhedra.
Z p
f (~x) dΩ ∼
X
= wi f (x~i )
Ω i=1

6.5 Boundary conditions

6.5.1 Neumann Boundary condition

The finite elements method is the discretization of the weak form of partial differential equation problem. In
the Poisson equation is analysed. In two dimensions the weak form of that equation is:
Z Z Z
∇u · ∇v dΩ = f v dΩ + ν ∇u · ~nv dΓ (6.5)
Ω Ω Γ

The Neumann boundary condition is given by equation:



ν∇u · ~n = q

Γ

where q is given function. After substitution of that boundary condition into [] the weak formulation of the
Poisson equation is: Z Z Z
∇u · ∇v dΩ = f v dΩ + qv dΓ
Ω Ω Γ
if the boundary integral is omitted it means that the zero Neumann condition is implemented (in case of q ≡ 0
that boundary integral is equal to zero). The general form of the discretized equation can be written as:
X
Dij uj = fi i = 1, ..., n (6.6)
j
R
where Dij denotes the diffusion matrix, uj denotes the nodal values of searched function and fi = Ω f ϕi dΩ
is the right hand side of discretized equation. The nonzero Neumann boundary condition is imposed by adding
to each element of right hand size vector fi the value of boundary integral:
Z
qϕi dΓ
ΓN

where ΓN denotes the subset of boundary Γ where Neumann boundary condition is imposed. Because the shape
functions are local the integration form expression above has to be done only on boundary surfaces (in 2D on
boundary sections) which are adjacent to the i-th node.

45
6.5.2 Dirichlet boundary conditions

The Dirichlet boundary condition imposes value of demanded function u in certain subsets of the domain. In
terms of discretized solution it means that values of the function u have to be fixed in some nodes. Thus the
values in the certain subset of m chosen nodes labeled with global indexes: K = {k1 , ..., km } are no longer the
unknowns. The modifications of diffusion matrix and right hand side vector from [6.6] that imply numerical
Dirichlet condition on nodes with indexes from K are as follows:

• Values in rows with numbers kl where l ∈ 1, ..., m and kl ∈ K = {k1 , ..., km } which are initially
Dkl ,j : j ∈ 1, ..., n have to be replaced with δkl ,j : j = 1, ..., n where δkl ,j denotes the Kronecker delta.

• Values in right hand side vector indexed with numbers kl where l ∈ 1, ..., m and kl ∈ K = {k1 , ..., km }
which are initially fkl : j ∈ 1, ..., n have to be replaced with imposed Dirichlet boundary condition values
ukl : l ∈ 1, ..., m : kl ∈ K = {k1 , ..., km }.

It’s worth noting that despite the modified diffusion matrix is no longer symmetric the Krylov subspace solvers
such as Conjugate Gradient Methods still converge to the desired solution.

6.5.3 Robin boundary condition

The Robin boundary condition is given by the equation:



−ν∇ · ~n = c(u ± u∞ ) (6.7)

ΓR

In the equation above u∞ is the constant value and ΓR is the subset of the domain’s boundary on which the
Robin’s boundary condition is imposed. The implementation of Robin boundary condition is similar to imple-
mentation of Neumann boundary condition. The equation [6.5.1] can be transformed by substitution of [6.7]
into: Z Z Z Z
∇u · ∇v dΩ = f v dΩ − c uv dΓ + c u∞ v dΓ (6.8)
Ω Ω ΓR ΓR
Pn
The discretization of second term on the right hand side of the equation above using the u = i=1 ui ϕi and
v = ϕi can be expressed as:
Z X n
ϕi ϕj uj dΓ
ΓR j=1

and by defining the matrix M as: Z


Mij = ϕi ϕj dΓ
ΓR

it equals:
n
X
Mij uj
j=1

46
Therefore it means that numerical Robin boundary condition modifies diffusion matrix by adding to it the matrix
M.
Dmodif ied = D + M
The discretization of third term in the equation [6.8] is:
Z
hi = c u∞ ϕi dΓ
ΓR

The right hand side vector of equation [6.6] has to be modified as follows:

fmodif ied = f + h

7 Lecture 7

7.1 Reference elements

In reference elements Gaussian quadratures are defined, so it’s more convenient to integrate inside them.

7.1.1 Linear quad element

Figure 27: Reference quad element

A quad element extends from -1 to 1 in both xi and eta directions. The local numbering of nodes is counter-
clockwise, starting from the node in (-1, -1). The following shape functions are given for the reference quad
element:
1
ψ1 = (1 − ξ)(1 − η)
4

47
1
ψ2 = (1 + ξ)(1 − η)
4
1
ψ3 = (1 + ξ)(1 + η)
4
1
ψ4 = (1 − ξ)(1 + η)
4

7.1.2 Linear triangular element

Figure 28: Reference triangular element

A triangular element extends from 0 to 1 in both xi and eta directions. Similarly to quad element, the numbering
of local nodes is counterclockwise, starting from the node in (0, 0). The following shape functions are given for
the reference triangular element:
ψ1 = 1 − ξ − η
ψ2 = ξ
ψ3 = η

7.1.3 Higher order elements

In order to develop higher order elements, additional shape functions associated with midnodes are added.
Previously calculated shape functions do not hold anymore, so new ones have to be derived. As linear functions
are no longer desired, we have to add components with η 2 , η · ξ, ξ 2 . The general form of a shape function is:

ψ = a + bξ + cη + dξ 2 + eξη + f η 2 (7.1)

48
Obviously, the coefficient a,b,c,d,e,f are the unknowns, and we have to find them in such a way, that for each
node, the shape function is 1 in the node and 0 in the other nodes. So what we come up with is a linear system
of equations, which should be solved for each node.

ψi (ξ~j ) = δij (7.2)

7.2 Geometry transformation in 2D

Let’s go back to the assembly of the global matrix for a diffusion problem in 2D and let’s see what happened
to the transformation of the geometry and the transformation of the gradient to the reference domain. What we
need to discretise is something like that
Z Z
∇u · ∇vdΩ = ∇u · ∇v|J|dΩref (7.3)
Ωe Ωref
P
Remind that u = (j) Uj ψj (ξ, η) The gradient of u:
h ∂u ∂u i h ∂u ∂ξ ∂u ∂η ∂u ∂ξ ∂u ∂η i
∇u = , = + , + (7.4)
∂x ∂y ∂ξ ∂x ∂η ∂x ∂ξ ∂y ∂η ∂y
Gradient of v can be calculated analogically. Now, what we have to calculate is ∇u∇v.

∂u ∂ξ ∂v ∂ξ ∂u ∂η ∂v ∂ξ
∇u · ∇v = · + · +
∂ξ ∂x ∂ξ ∂x ∂η ∂x ∂ξ ∂x
∂u ∂ξ ∂v ∂η ∂u ∂η ∂v ∂η
+ · + · +
∂ξ ∂x ∂η ∂x ∂η ∂x ∂η ∂x
∂u ∂ξ ∂v ∂ξ ∂u ∂η ∂v ∂ξ
+ · + · +
∂ξ ∂y ∂ξ ∂y ∂η ∂y ∂ξ ∂y
∂u ∂ξ ∂v ∂η ∂u ∂η ∂v ∂η
+ · + · =
∂ξ ∂y ∂η ∂y ∂η ∂y ∂η ∂y
(7.5)
∂u ∂v  ∂ξ ∂ξ ∂ξ ∂ξ 
= + +
∂ξ ∂ξ ∂x ∂x ∂y ∂y
∂u ∂v  ∂ξ ∂η ∂ξ ∂η 
+ + +
∂ξ ∂η ∂x ∂x ∂y ∂y
∂u ∂v  ∂η ∂ξ ∂η ∂ξ 
+ + +
∂η ∂ξ ∂x ∂x ∂y ∂y
∂u ∂v  ∂η ∂η ∂η ∂η
+ +
∂η ∂η ∂x ∂x ∂y ∂y
Let’s substitute
∂ξ
= λ11
∂x
∂ξ
= λ12
∂y

49
∂η
= λ21
∂x
∂η
= λ22
∂y
 
λ11 λ12
The matrix is the Jacobi of the transformation from the physical space to the reference. In general
λ21 λ22
it’s not easy to compute, as there is a nonlinear relationship between the spaces. Jacobi matrix of the inverse
transformation is the inverse of the matrix of the origin transformation.

Now the integral is the following


Z XZ h ∂ψ ∂ψ
j i  ∂ψj ∂ψi
λ211 + λ212 +

∇u · ∇v|J| = λ11 λ21 + λ12 λ22 +
Ωref ∂ξ ∂ξ ∂ξ ∂η
(j) Ωref
(7.6)
∂ψj ∂ψi  ∂ψj ∂ψi 2 i
+ λ11 λ21 + λ12 λ22 + λ21 + λ222 |J|dΩref Uj
∂η ∂ξ ∂η ∂η
Now, in order to calculate the global matrix, one has to loop over the elements, calculate the local matrix using
quadrature points, and then assemble it to the global matrix.

Figure 29: Calculation of the global matrix

7.3 Incompressible Navier Stokes

7.3.1 Checkerboard problem

Working only with linear elements for solving Navier Stokes equation will always be unstable. The most
common solution for this issue is to define two different function spaces for the representation of velocity and

50
pressure. Many different pairs have been investigated in terms of their stability, and the most common one is
to have linear elements for pressure field and second order elements for velocity field (Q2P1, see fig. 30).

Figure 30: Triangular and quad elements for Q2P1 scheme

The condition, which tells whether a given pair will be stable, is called LBB condition or inf-sup condition.

7.3.2 Stabilization of highly convective problems

Let’s consider the following equation


Z Z Z
·∇u · ∇vdΩ + ν ∇u · ∇vdΩ = ν ~n · ∇u · vdΓ (7.7)
Ω Ω Γ

In the upwind scheme in finite difference and finite volume methods, all information downstream the node
is neglected, and only the information upstream is considered. We want to do the same in FEM. The most
popular approach is to add some constant to the shape function upstream the node, and subtract the same value
downstream. Such test functions can be easily calculated.

ṽ = v + τ~a · ∇v (7.8)

Similarly to the FVM. the upwind scheme adds some diffusion, thus we want to keep the τ coefficient low, but
on the other hand high enough to keep the calculations stable.

51
Figure 31: SUPG method

Methods such that different shape and test functions are used are called Petrov-Galerkin methods (Streamline
Upwind Petrov Galerkin method is presented in the fig. 31).

If you want to implement 7.8 into 7.7 equation, additional terms are generated, so you should probably use
more gaussian quadrature points. The approach in which all v are replaced with ṽ is called Consistent SUPG.
However, replacing v only in the convective term also stabilises the equation.

7.3.3 Navier Stokes equation

Let’s consider the strong form of the Navier Stokes equation

∂~u 1
+ ~u · ∇~u = − ∇p + ν∆~u (7.9)
∂t ρ
In order to obtain the weak form we have to add v function.
Z Z Z Z
∂~u 1
· ~v + ~u · ∇~u · ~v = − ∇p · ~v + ν ∆~u · ~v (7.10)
Ω ∂t Ω ρ Ω Ω

The last term can be divided into


Z Z Z
ν ∆~u · ~v = −ν ∇~u · ∇~v + ν ~n · ∇~u · v (7.11)
Ω Ω Γ

The convective term is nonlinear. Nonlinear equations are typically solved by dividing them into a set of linear
subproblems. Assembling the matrix for Navier Stokes equation one has to assume some advection velocity,
usually it is the velocity from the previous iteration. Now the convection term looks like the following
Z
˜ · ~v
~u · ∇~u (7.12)

52
The first term will generate mass matrix in the following way
Z XZ
∂~u
· ~v = (ψj ψi )U~j (7.13)
Ω ∂t (j)Ω

In FEM, we want to transform the pressure term, because linear interpolation is used, which means that cal-
culating the gradient of pressure would yield constant gradient across the element. However, since we have
second order elements for velocity, we also work with second order test functions, so calculating the gradient
of v would give us a linear function. So the following thing is done
Z Z Z Z Z
1 1 1 1 1
∇p · ~v = ∇(p · ~v ) − p · ∇~v = ~n · p · v − p · ∇~v (7.14)
ρ Ω ρ Ω ρ Ω ρ Γ ρ Ω
So finally we obtain
Z Z Z Z Z Z
∂~u ˜
· ~v + ~u · ∇~u · ~v + ν ∇~u · ∇~v − p · ∇~v = − ~n · p · v + ν ~n · ∇~u · v (7.15)
Ω ∂t Ω Ω Ω Γ Γ

The scheme is always implicit, as the mass matrix is 3x3 with ψj ψi at every place. What has been come up
with is called matrix lumping, which means that all elements of the row are added to the main diagonal. Then,
one can use explicit formulas. Matrix lumping is used for some preconditioners.

7.3.4 Open boundary conditions

What boundary conditions should be given for the following problem?

Figure 32: Example boundary conditions

Usually, we apply zero velocity at the walls, zero pressure at the outlet and some given velocity at the intlet.
For open boundary condition we apply
1
− p~n + ν∇ · ~u · ~n = p(t)~n (7.16)
ρ
Which is exactly the same as the last two terms of the equation 7.15. The right hand side is the average pressure
at the boundary, so if you want to implement outlet boundary condition, you don’t have to implement anything
at the rhs of 7.15.

53
7.3.5 Vector notation

We are given the following matrix and vector of the unknowns

M+D+C px ux
M+D+C py uy
p

Once we have the equation Z Z


∇u · ∇v = f ·v (7.17)
Ω Ω
We have no problem, as we can simply substitute v = ψi .
Now, how to deal with vector problems in FEM? We are interested in obtaining a scalar equation for the first
component and a scalar equation for the second component. What’s usually done is that ~v is replaced by such
test function that ~v = [ψ, 0] for x component and ~v = [0, ψ] for y component.

7.3.6 Nonlinearity

˜ and solve the equation, then replace


For a steady-state problem, one can choose an arbitrary advection velocity ~u
it with a newly calculated one and repeat the process until it converges. However, if it varies too quickly, one
needs to apply underrelaxation.
˜ = α~un + (1 − α)~un−1
~u (7.18)
Where α ∈ (0, 1). In general, this approach is safer and converges faster.
Let’s assume we deal with unsteady problem. The naive way is to consider ~u from the previous time step. If we
have a higher order of timestepping, we can use two previous velocities and interpolate them in order to obtain
advection velocity in the next time step. Another approach is to do subiterations inside every time step.

7.4 Boundary Element Method

Problem with potential field ∆u = 0 can easily be solved using Boundary Element Method. Let’s assume we
don’t have a prescribed domain and let’s write Laplace equation in polar coordinates for 2D.
∂2f 1 ∂f 1 ∂2f
∆u = + + (7.19)
∂r2 r ∂r r2 ∂θ2
Harmonic functions are basically functions that fulfull this equation everywhere. There are many such func-
tions. In 3D one can easily prove that Φ = 1r satisfies the Laplace equation. In 2D case Φ = ln |r| is a harmonic
function.
The idea of the Boundary Element Method is the following. Let’s assume we are given some geometry with
a hole inside and we are interested in solving the Laplace problem everywhere inside. First we need to intro-
duce space discretisation (see fig. 34), which in this case is introducing the boundary elements. Now we have

54
to associate some source functions, for example Φ = ln |r| in 2D. If you draw ’streamlines’ of such a func-
tion, it generates flux radially. It satisfies the Laplace equation because the flux is extremely high where the
circumference is extremely low, and the other way around.

Figure 33: BEM source function

It conserves well, with one singularity exactly at the center. That’s why we don’t want the center of those
functions inside our domain. So the Boundary Element Method assumes that the source function ought to be
located a bit away of the panels. The next step is to introduce control points, which can lay on the boundary.

Figure 34: BEM discretisation

Then we will have Φj (~r = Aj · ln |~r − r~js | assuming that j is the index of the panel. We can apply dirichlet
boundary conditions v. The solution will the be following.
X
u(~r) = Aj Φj (~r) (7.20)
(j)

55
The matrix generated in such a way will always be full, as you couple every boundary elements with all other
elements. The nice thing is that domain discretisation is not necessary, so you have massively fewer elements.
The simplest choice is to write the equation this way
X
Aj Φj (xi , yi ) = vi (7.21)
(j)

Where i are boundary control points and j are source points.


In order to solve unsteady problems, some additional functions need to be added. So as to implement Neumann
∂Φ
boundary condition you need to calculate ∂nj |j and regard that in your matrix.
Nonconforming mesh is possible.
What kind of data structures do we need? Let’s assume we know the analytical representation of the curves of
the geometry. Now we can use natural parametrisation si (ξ) → (x, y) to generate the mesh. Also, it’s easy
to generate the location of the source and control points. Therefore, the natural parametrisation and boundary
conditions are all that’s necessary to solve the Laplace equation.

7.5 Other numerical techniques

7.5.1 Timestepping

Instead of using Implicit Euler method


un+1 − un
= f n+1 (7.22)
∆t
it is strongly recommended to use second order scheme.
3 n+1
2u − 2un + 12 un−1
= f n+1 (7.23)
∆t

7.5.2 Linearization

One of the techniques is called Picard linearization and is based on using the term from the previous time step.

Another technique is Newton-Raphson method. It takes some approximate solution, then it uses Taylor expan-
sion f (x + h) = f (x) + h · f 0 (x). Now the idea is to move in the f 0 direction by h such that the result will be
0. So h = − ff0(x i)
(xi ) and the new xi+1 = xi + h. The method should converge really quickly, however, it may
also diverge.
In the case of vector functions, you have to solve ∇F~ (~x) · ~h = −F~ (~x), where ∇F~ (~x) is the Jacobi matrix.
~ = x~i + ~h.
Then xi+1

In CFD it is common to have some problematic source terms. For instance, you may want to solve such a
problem,
∆u = u5 (7.24)

56
where the source term is associated with the function and highly nonlinear. Some of the ideas about how to deal
with this issue

• prevoius time steps

• underrelaxation

• linearize u5 = u4 · u and then the equation will be (∇ + u4 ) · u. Obviously, the u is some approximation,
for which we can use the solution from the previous time step, but this approach is far more stable than
having it on the right hand side. You can also use underrelaxation here.

• Newton-Raphson

The Newton-Raphson method will converge faster, but underrelaxation will have better convergence radius.

7.5.3 Limiters

Sometimes you deal with physical problems that you know that the solution must be within certain limits. One
of the naive ways is, for instance, if the solution should not be below 0, let’s assign 0 or 1e-10. The main
drawback of that is that it’s not conservative.
Another option is to apply flux limiters, so that everything that comes out of the calculations is within the limits.

8 Heat Transfer - Michał Kurzynka

Some heat transfer theory and practice will be discussed hereafter. The radiation however will not be described.

8.1 Conduction and convection equations

Conduction:

~q = −λ∇T


λ = λ(T, X
|{z} )
if anisotropic

with ~q the heat flux in [W ], λ the thermal conductivity in [W.m−1 .K −1 ] and T the temperature in [K]. It is
interesting to have some reference value in mind for the thermal conductivity since it varies a lot between the
materials (figure 35) and as a function of temperature (36).

57
Figure 35: Thermal conductivity as a function of materials

Figure 36: Thermal conductivity as a function of the temperature

Boundary conditions (BC):

58
• Dirichlet: TBC = V alue
∂T

• Neumann: ∂X BC
= V alue
∂T
= α(T − T∞ ), with α the thermal conductivity of the interface in [W.m−1 .K −1 ] and

• Robin: λ ∂X BC
Tinf ty the reference temperature

Convection:

q = α(Tw − T∞ )
α = α(ρf , cp,f , νf , λf , Re, Tf , ...)

with α the convective heat transfer coefficient [W.m−1 .K −1 ], Tw the temperature of the wall, ρf the density
of the fluid [kg.m−3 ], cp,f its specific heat capacity [J.kg −1 .K −1 ], νf its kinematic viscosity [m2 .s−1 ], λf its
thermal diffusivity [m2 .s−1 ], Re the Reynolds number of the fluid flow [∅].

8.2 Some dimensionless numbers

• Reynolds: Re = u.L
ν with u the velocity [m.s−1 ], L the reference length [m]
[convection] αf .L
• Nusselt: N u = [conduction] =
λf , with αf the convective heat transfer coefficient of the fluid [W.m−1 .K −1 ]
and λf its conductivity [W.m−2 .K −1 ]

• Prandtl: P r = νa , with a = λ
ρ.cp the thermal diffusivity [m2 .s−1]

[advection] u.L
• Peclet: P e = [dif f usion] = Re.P r = α

• Rayleigh: Ra = Re.P r
[buoyancy] g.L3 .β(Tinf ty −Tw ) 1
• Grashof: Gr = [viscosity] = ν2
, with β = Tf

α .L
• Biot: Bi = λf s , with αf the convective heat transfer coefficient of the fluid and λs the thermal conduc-
tivity of the solid (figure 37)

59
Figure 37: Temperature distribution (in green) as a function of the Biot number

8.3 Analogy with electrical current

We can do an analogy between heat transfer and electricity which will help us to calculate approximate solutions
and heat coefficients.

Electricity Heat transfer


voltage U temperature difference ∆T
intensity I heat flux Q
δ
resistance R λA

Table 2: Analogy between electrical and heat transfer variables.

Let us take a few examples to show the power of this point of view.

Parallel bodies / bodies in series

60
Figure 38: Two bodies in parallel in which the conserved heat flux q goes through can be compared to two
resistors in parallel in which a conserved intensity I goes through.

Figure 39: Two bodies in series in which the conserved heat flux q goes through can be compared to two resistors
in series in which a conserved intensity I goes through.

61
1 P 1 P 1
In the parallel case (figure 38), we have Rtot = i Ri = i δ . In the series case (figure 40), we’ve got
λi .Ai

Rtot = i Ri = i λi δ.Ai .
P P

Analogy electricity-heat: example 1

Figure 40: Example of the analogy between the heat transfer and the electric current.

Analogy electricity-heat: example 2

In this example, we consider a battery cell, surrounded by air, mounted on a cooling plate where a cooling
fluid flows in. There are two ways the heat can go from the cell (we consider the temperature of the cell being
stored in its center): the first one from the cell to the fluid through the cooling plate and two interfaces and the
second one from the cell to the surrounding air through one interface. Hereafter the scheme of the case and the
equivalent electrical circuit (figure 41).

62
Figure 41: Example of the analogy between the heat transfer and the electric current: a battery.

where:

• R1 = Rc2 + Rair is the equivalent resistance for the heat transfer from cell to air

• R2 = Rc1 + Rc−cp + Rcp + Rf is the equivalent resistance for the heat transfer from cell to cooling fluid

Let’s take some concrete values (table 8.3):

63
Parameter Value
A 2.10−3 m2
Xcp 0.02 m
Xc 0.05 m
λc 10 W.m−1 .K −1
λair 5 W.m−1 .K −1
λc−cp
αc−cp αc = 1050−4 = 5.105 W.m−2 .K −1
αcp 5.103 W.m−2 .K −1

We can now calculate the equivalent resistance for each heat transfer.

Xc 1
R1 = + = 41.67 K.W −1
λc .3A αair .3A
Xc 1 Xcp 1
R2 = + + + = 2.651 K.W −1
λc .A αc−cp .A λcp .A αf .A
1 1 1 R1 .R2
= + ⇒ RF U LL = = 2.492 K.W −1
RF U LL R1 R2 R1 + R2
RzRED = min{R1 , R2 } = 2.651 K.W −1

The resistance R1 being equal to 41.67 means that, in order to have a heat transfer of 1 W , we need to have
a temperature difference Tc − Tf equal to 41.67 K. The resistance RF U LL is resistance considering the two
resistance R1 and R2 being in parallel and considering a unique heat flux QF U LL from the cell to the outside.

Question: Can we simplify our model by omitting one heat transfer? Here, can neglect the cell-air transfer and
what would be the error?

R1
≈ 16
R2

The result of the previous fraction gives us the information that the resistance to the heat transfer between cell
and air is 16 times higher than the on to the heat transfer between cell and cooling fluid with a same temperature
difference. In other words, if Tf = T air, only 1 Watt would be transferred from the cell to the air while
there would be 16 Watts from the cell to the cooling fluid. The cooling fluid being even colder than the air,
we can choose not considering the heat transfer from cell to air which leads to adiabatic cell walls. With this
1
assumption, the error would therefore be  = 16 × 100 = 6.25%.

64
8.4 How to calculate the thermal conductivity at the interface?

Figure 42: Heat exchange between a pipe fluid flowing inside.

Let us take the example of a fluid flowing through a pipe and consider the heat transfer between both (figure
42). The values are the following (table 8.4):

Parameter Value
L 10 m
d 30.10−3 m
ṁ 0.5 kg.s−1
Tw 90 ◦ C
Tf,inlet 60 ◦ C

with Tf the temperature of the fluid near the wall. Now, to calculate the thermal conductivity at the interface,
we will loop over 3 steps:

1. Calculate Tf . For the initialization, let us assume Tf = 0.5 · (Tf,inlet + Tw ) = 75◦ C.


With a table in a book, we get ν(Tf ) = 3.9.10−5 m2 .s−1
u.d
2. Reynolds number: Re = ν = 5.58.104

3. Find the proper correlation: table in a book which corresponds to our case, Re, ...
 0.25
ν¯f = 0.021.Re0.8 .P r 0.43 . P rf .L = 201.08, with L a constant depending on Ld . Here, L ≈ 1.
f f P rw
N¯u .λ
ᾱ = f f
d = 4497.5 W.m−1 .K −1
This ᾱ means that, each square meter, for 1 Kelvin temperature difference between wall and fluid, there
will be 4497.5 Watts transferred from the wall to the fluid. But we have to keep in mind that the heat
capacity of the water is almost this value too, which means it has to receive this amount of energy to be
heated up by only one Celsius degree.

4. Return to the first step.

65
To calculate the average temperature of the stream, the following method can be used:

ᾱ.Scontact .∆Tln = ṁ.cp .(Toutlet − Tinlet )


(Tw − Tinlet ) − (Tw − Toutlet )
ᾱ.π.d.L.   = ṁ.cp .(Toutlet − Tinlet )
−Tinlet
ln TTww−T outlet
 
Tw − T inlet ᾱ.π.d.L
= exp
Tw − Toutlet ṁ.cp
Tw − Tinlet
Toutlet = Tw −  
exp ᾱ.π.d.L
ṁ.cp
1
⇒ Tf = (Tinlet − Toutlet )
2

Calculate the thermal conductivity of a wall - Example 1

A hot fluid is flowing inside this quencher of diameter d. Heat is transferring to the outside through the walls
of width δ (figure 43).

Figure 43: Heat exchange between a quencher and the outside.

The parameters and their values are described hereunder:

66
Parameter Value
uf 10 m/s
d 3m
δ 2.10−3 m
Tf −20 ◦ C
TR 90 ◦ C
Tw 0.5(Tf + TR ) = 35 ◦ C
λw 550 W.m−2 .K −1

We’ll proceed to two steps to calculate the thermal conductivity at the wall.

1. Re = 1.8.106 with νf (Tw ) = 16.5.10−6 m2 .s−1


P r = 0.7

2. Churchill-Bernstein: 103 < Re < 4.107 and P r4 > 0.2


1 1  
0.62.Ref2 .P rf3  58 5
N¯u = 0.3 + !1
Ke
1 + 282000 = 2308.75 ⇒ ᾱ = 20.78 W.m−1 .K −1
 2 4
3
1+ P0.4
rw

If we now take the steal wall thickness into account, the thermal conductivity of the wall becomes:
αmodif = 1 +1 δ = 20.78 W.m−1 .K −1
ᾱ λw

In this case, ᾱ ≈ αmodif . In our model, we could therefor neglect the thickness of the wall.

Calculate the thermal conductivity of a wall - Example 2

A hot cylindrical battery cell of radius r and height L is cooled down by the surrounding air; the thermal
conductivity at the wall is the unknown α (figures 44 and 45).

67
Figure 44: Heat exchange between a cylindrical battery cell and the air outside.

Figure 45: Definition of some temperature: Tw the temperature of the solid wall, Tf the temperature of the fluid
close to the wall, Tinf = T∞ the reference temperature of the fluid.

The parameters and their values are described hereunder:

Parameter Value
L 0.05 m
Circ 2πr = 0.02 m
T∞ 20 ◦ C
Tw ? ◦C
1 ◦
Tf 2 (Tw − T∞ ) =? C

68
Same as previously, we’ll proceed to two steps to calculate the thermal conductivity at the wall.

1. First, we give an initial value for the thermal conductivity of the wall: αinit = 5 W.m−2 .K −1
Q ◦
Q = 1.47 W = α.S.∆T ⇒ ∆T = αinit .S = 20 C
∆T = Tw − T∞ = 20◦ C ⇒ Tf = 12 (2T∞ + 20) = 30◦ C, Tw = 40◦ C

2. P rf = 0.701, νf = 16.10−6 m2 .s−1 , λf = 2.67.10−2 W.m−2 .K −2 , β = 3.29.10−3 K −1


3
Gr = g.L
ν2
β(Tw − T∞ ) = 9.58.107 , Gr × P r = 6.716.107
1
N¯u = C.(Gr × P r)n = 0.135(Gr × P r) 3 = 54.87 ⇒ alpha ¯ = 29.3 W.m−2 .K −1
The coefficients and formulas are obtained from tables depending of the physical case.

69

You might also like