Upload
others
View
30
Download
3
Embed Size (px)
Citation preview
Computational Fluid Dynamics
CFD
Basic Discretisation
Governing equations
System of equations:
ii
i
i
i
ijj
iii
i fux
pu
x
u
x
Tk
xt
q
x
Eu
t
E
j
ij
j
i
j
jii
xx
pf
x
uu
t
u
0
i
i
x
u
t
Mass
Momentum
Energy
Governing equations
ii
i
i
i
ijj
iii
i fux
pu
x
u
x
Tk
xt
q
x
Eu
t
E
j
ij
j
i
j
ij
i
xx
pf
x
uu
t
u
0
i
i
i
ix
u
xu
t
Mass
Momentum
Energy
Non-conserved forms
Classification of PDEs
21221122112212
1221 dxdbdbdxdycbcbdadadycacaA
0122112211221
2
1221
dbdb
dx
dycbcbdada
dx
dycaca
0
2
c
dx
dyb
dx
dya
a
acbb
dx
dy
2
42
Three situations:
04
04
04
2
2
2
acb
acb
acb hyperbolic
parabolic
elliptic
Classification of PDEs
Hyperbolic
PDomain of
dependence Region of influence
Charateristic lines
y
x
Classification of PDEs
parabolic
PDomain of
dependence Region of influence
y
x
Known boundary conditions
Known boundary conditions
Classification of PDEs
Elliptic
P
y
x
Every point influences all
other points
Governing equations
and boundary
conditions
Discretisation,
choice of grid
System of
algebraic
equations
Equation
system solver
Approximate
solution
Mathematical
description of
physical ”reality”
FV, FD, FE?
Finite differences
02
2
ixt
Consider the equation
To solve this numerically we create a discrete
approximation in time and space. Hence, we get a
system of algebraic equations and obtain the solution
only at certain points.
xx is the grid spacing and
t is the time step
Finite differences
02
2
xt
For simplicity we use 1D-equation
First derivative.
Use Taylor expansion :
H.O.T.!3!2 3
33
2
221
n
j
n
j
n
j
nj
nj
t
t
t
t
tt
H.O.T.!3!2 3
32
2
21
n
j
n
j
nj
nj
n
j t
t
t
t
tt
Rearrange and divide by t:
Finite differences
H.O.T.!3!2 3
32
2
21
n
j
n
j
nj
nj
n
j t
t
t
t
tt
tOtt
nj
nj
n
j
1
Truncation
error
First order forward difference, the truncation error is directly
proportional to the time step.
Note that we can not from this say anything about the exact size of
the TE, only how it behaves as t goes to zero.
Finite differencesFirst derivative.
Use Taylor expansion :
H.O.T.!3!2 3
33
2
221
n
j
n
j
n
j
nj
nj
t
t
t
t
tt
H.O.T.32 3
3211
n
j
nj
nj
n
j t
t
tt
H.O.T.!3!2 3
33
2
221
n
j
n
j
n
j
nj
nj
t
t
t
t
tt
Second order central difference, the truncation error is proportional
to the time step squared.
Subtract these two expressions, rearrange and divide by t:
Finite differences
H.O.T.32 3
3211
n
j
nj
nj
n
j t
t
tt
Second order central difference, the truncation error is proportional
to the time step squared.
211
2tO
tt
nj
nj
n
j
Finite differencesSecond derivative.
Use Taylor expansion:
H.O.T.!4!3!2 4
44
3
33
2
22
1
n
j
n
j
n
j
n
j
nj
nj
x
x
x
x
x
x
xx
H.O.T.4
24
42
2
11
2
2
n
j
n
j
n
j
n
j
n
jx
x
xx
H.O.T.!4!3!2 4
44
3
33
2
22
1
n
j
n
j
n
j
n
j
nj
nj
x
x
x
x
x
x
xx
Second order central difference, the truncation error is proportional
to the node distance squared.
Finite differences
ttn-1 tn tn+1
First
order
Second order
1st and 2nd order approximations to the
time derivative at point tn
Finite differences
02
2
xt
In total, the discrete approximation to
can be written as
02
2
111
xt
nj
nj
nj
nj
nj
Called the FTCS scheme (Forward in Time, Central in Space)
Finite differencesDissipation error
02
2
xxc
Convection-diffusion equation
1st order FD appoximation of the
first derivative and 2nd order for
the second derivative:
2
2
21
2xO
x
x
xx
jj
2
2
111
2
2
2
2 2
2xO
xxc
xx
xc
xc
jjjjj
Numerical dissipation
4
4
42
2
11
2
2
O4
2x
x
x
xxj
jjj
Finite differencesDispersion error
02
2
xxc
Convection-diffusion equation
2nd order FD appoximation of the
first derivative and 2nd order for
the second derivative:
022
4
3
3211
xO
x
x
xx
jj
4
4
42
2
11
2
2
O4
2x
x
x
xxj
jjj
Even derivatives are dissipative
Odd derivatives are dispersive
Peclet number
(Cell Reynolds number)
xcPe
Dispersive schemes are unstable if
2Pe
Finite Volumes
0
y
G
x
F
t
q
vG
uF
q
0
dxdyy
G
x
F
t
q
ABCD
Green’s theorem
GdxFdyds
GF
dsqdVdt
d
ABCD
nH
H
nH
,
0
Finite Volumes
Discrete approximation, second order
0, DA
AB
ABCDkj xGyFAqdt
d
ABAB
ABAB
xxx
yyy
2
2
,1,
,1,
kjkjAB
kjkjAB
GGG
FFF
etc.
etc.
etc.
Finite Volumes
022
22
22
22
,,1,,1
1,,1,,
,1,,1,
,1,,1,
DAkjkj
DAkjkj
CDkjkj
CDkjkj
BCkjkj
BCkjkj
ABkjkj
ABkjkj
ABCD
xGG
yFF
xGG
yFF
xGG
yFF
xGG
yFF
dt
dqA
Discrete approximation, second order
Finite Volumes
Discrete approximation, first order
0, DA
AB
ABCDkj xGyFAqdt
d
ABAB
ABAB
xxx
yyy
1,
1,
kjAB
kjAB
GG
FF
etc.
etc.
etc.
Finite Volumes
0,1,1
,,
,,
1,1,
DAkjDAkj
CDkjCDkj
BCkjBCkj
ABkjABkjABCD
xGyF
xGyF
xGyF
xGyFdt
dqA
Discrete approximation, first order
Finite Volumes
02
2
2
2
yx
02
2
2
2
dsdxdyyx
ABCD
nH
dxy
dyx
ds
nH
dy
Adxdy
xAx DCBADCBAkj
11
2/1,
'''',''
''''
''1, ADADCkjCBB
DCBA
BAkj yyyydy
Finite Volumes
'''',''
''''
''1, ADADCkjCBB
DCBA
BAkj yyyydy
If the mesh is not too distorted:
kkABkkABDCBAAB
kkADCB
ABDCBA
xyyxAA
yyy
yyy
,1,1''''
,1''''
''''
AB
ABkkkjkjAB
kj A
yy
x
,1,1,
2/1,
AB
ABkkkjkjAB
kjA
xx
y
,1,1,
2/1,
Example
Backward facing step
Questions:
• Discretisation?
• Type of mesh?
• Boundary conditions?
Example
Backward facing step
Example
Backward facing step
residuals
Example
Backward facing step
Velocity
1st order upwind 2nd order upwind
Example
Backward facing step
• Question:
• Given a discrete approximation to the
governing equations can we ensure that
we get a solution and that the solution is
an approximation of reality?
Lax equivalence theorem:
Given a properly posed linear initial value
problem and a finite difference
approximation to it that satisfies the
consistency condition, stability is a
necessary and sufficient condition for
convergence.
Note! For an non-linear problem this is a
necessary but NOT sufficient condition.
Governing
Partial
Differential
Equations
System of algebraic
equations
Approximate
solution
Exact solution
discretisation
consistency
convergence
stability
CONSISTENCY+STABILITY=CONVERGENCE
Solution error: The difference between the
exact solution of the governing PDEs and
the exact solution to the system of
algebraic equations
njnj
nj tx ,
Convergence: The exact solution
to the system of algebraic
equations will approach the
exact solution of the governing
PDEs when grid spacing and
time step go to zero
0lim0,
nj
tx
Consistency: The system of algebraic
equations will be equivalent to the
governing PDEs at each grid point when
grid spacing and time step go to zero
Stability: If spontaneous perturbations
in the solution to the system of
algebraic equations decay, we have
stability
Consistency
02
2
11
111
1
xt
nj
nj
nj
nj
nj
Consider fully implicit form of the equation
Expand and around the j:th node1
1nj
11nj
022
!6!5!4!3!2
!6!5!4!3!2
7
2
1
2
1
6
661
5
551
4
441
3
331
2
2211
2
1
6
661
5
551
4
441
3
331
2
2211
2
1
xOxx
x
x
x
x
x
x
x
x
x
x
xx
x
x
x
x
x
x
x
x
x
x
x
xx
x
t
nj
n
j
n
j
n
j
n
j
n
j
n
j
nj
n
j
n
j
n
j
n
j
n
j
n
j
nj
nj
nj
Consistency
3
3
32
2
2
4
3
33
2
221
O!3!2
O!3!2
1
tt
t
t
t
t
tt
t
t
t
tt
tt
n
j
n
j
n
j
nj
n
j
n
j
n
j
nj
nj
nj
0...36012
1
6
641
4
421
2
21
n
j
n
j
n
j
nj
nj
x
x
x
x
xt
Now expand 1nj
1
2
2
n
jx
and
1
4
4
n
jx
,
Consistency
3
22
42
2
3
2
21
2
2
2tO
xt
t
xtt
xx
n
j
n
j
n
j
n
j
3
42
62
4
5
4
421
4
42
21212tO
xt
t
xtt
x
x
x
xn
j
n
j
n
j
n
j
Consistency
0....360
...12
...2
....62
6
64
4
5
4
42
22
42
2
3
2
2
3
32
2
2
n
j
n
j
n
j
n
j
n
j
n
j
n
j
n
j
n
j
x
x
xtt
x
x
xt
t
xtt
x
t
t
t
t
x
ConsistencyFrom the governing equation:
6
63
3
3
4
42
2
2
2
2
2
2
2
2
2
2
xt
xxxxtttt
xt
02
2
nj
n
j
Ext
We can now write:
...720366122 3
3
2
422
2
22
n
j
n
j
nj
t
xtxt
t
xtE
2x
ts
Consistency
02
2
nj
n
j
Ext
...120
1
4
11
36
11
2
...1204
136
12
3
3
2
2
2
2
3
3
22
422
2
22
n
j
n
j
n
j
n
j
nj
tss
t
ts
t
tt
x
t
xt
tt
xtE
2x
ts
Consistent if 0lim2
0,
t
x
xt
Stability
Consider the numerical error *nj
nj
nj
Exact solution to system
of algebraic equations
Numerical solution to
system of algebraic
equations
Stable if decreases towards round off
Unstable if increases
nj
nj
Stability
02
2
11
1
xt
n
j
n
j
n
j
n
j
n
j
n
j
n
j
n
j
n
j sss 11
1 21
2x
ts
*1
1
**
1
*1 21
n
j
n
j
n
j
n
j sss
If the system is linear we can subract these equations
n
j
n
j
n
j
n
j sss 11
1 21
Stabilityvon Neumann stability analysis
The errors are expanded as finite Fourier series. Stability is
determined by considering whether a Fourier component decays
or amplifies when progressing to the next time level.
1,.....,3,2 ,2
1
0
JjeaJ
m
ji
mjmInitial error: xmm
n
j
n
j
n
j
n
j sss 11
1 21
Assume exponetial growth or decay in time:tn
m ea
Stabilityvon Neumann stability analysis
jitnn
j ee
Due to linearity it is sufficient to study one a single
term of the series.
Substitute into the error equation:
111 21 jitnjitnjitnjitn eseeeseseee
2/sin41 2 se t
t
n
j
n
jeG
1
21 iit eese 2
cos
ii ee
2
cos1
2sin 2
Amplification
factor
Stabilityvon Neumann stability analysis
Stable if 1G for all
hence for this scheme 12/sin411 2 s
true if
2
1s
2x
ts
What does this mean physically?
tx
xs
physical information speed
travelling speed
i.e. speed of physical information should be half of what can be resolved
on the grid.
Stability
02
11
1
xc
t
n
j
n
j
n
j
n
j
The convection equation.
01
1
xc
t
n
j
n
j
n
j
n
j
0
xc
t
Central difference for convective term
sin1 iCG
1C
x
tcC
Courant number
Unstable!
Upwind difference for convective term
sincos11 iCCG
Stable if CFL (Courant-Friedrich-Levi) condition
Physical interpretation:
tx
cC
Convection speed
travelling speed
Stabilityvon Neumann stability analysis
02
2 2
11111
xxc
t
nj
nj
nj
nj
nj
nj
nj
The convection-diffusion equation. 02
2
xxc
t
Central difference for convective term
sincos121 iCsG
120 2 sCx
tcC
Courant numberStable if
2x
ts
Stabilityvon Neumann stability analysis
The convection-diffusion equation.
02
2
1111
xxc
t
nj
nj
nj
nj
nj
nj
nj
02
2
xxc
t
Upwind difference for convective term
sincos121 iCsG
12 sCx
tcC
Courant number
Stability
02
2
11
111
1
xt
nj
nj
nj
nj
nj
2x
ts
Explicit vs. implicit schemes
Explicit: 02
2
11
1
xt
n
j
n
j
n
j
n
j
n
j
Stable if2
1s
Implicit:
2/sin41
12 s
G
2/sin41 2 sG
nj
nj
nj
nj sss
11
111 21
Stable if 0s i.e. unconditionally stable