Upload
others
View
19
Download
0
Embed Size (px)
Citation preview
Computational Fluid Dynamics CFD
Basic Discretisation
Governing equations
System of equations:
iii
i
i
ijj
iii
i fux
pux
uxTk
xtq
xEu
tE ρ
τρρρ
+∂
∂−
∂∂
+
∂∂
∂∂
+∂∂
=∂
∂+
∂∂
j
ij
ji
j
jii
xxpf
xuu
tu
∂∂
+∂∂
−=∂
∂+
∂∂ τ
ρρρ
0=∂
∂+
∂∂
i
i
xu
tρρ
Mass
Momentum
Energy
Governing equations
iii
i
i
ijj
iiii fu
xpu
xu
xTk
xtq
xEu
tE ρ
τρρρ +
∂∂
−∂
∂+
∂∂
∂∂
+∂∂
=∂∂
+∂∂
j
ij
ji
j
ij
i
xxpf
xuu
tu
∂∂
+∂∂
−=∂∂
+∂∂ τ
ρρρ
0=∂∂
+∂∂
+∂∂
i
i
ii x
ux
ut
ρρρMass
Momentum
Energy
Non-conserved forms
Classification of PDEs ( )( ) ( ) ( )( )2
1221122112212
1221 dxdbdbdxdycbcbdadadycacaA −+−+−−−=
( ) ( ) ( ) 0122112211221
2
1221 =−+−+−−
− dbdb
dxdycbcbdada
dxdycaca
02
=+−
c
dxdyb
dxdya
aacbb
dxdy
242 −±
=
Three situations:
04
04
04
2
2
2
<−
=−
>−
acb
acb
acb hyperbolic
parabolic
elliptic
Classification of PDEs
Hyperbolic
P Domain of dependence Region of influence
Charateristic lines
y
x
Classification of PDEs
parabolic
P Domain 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.
x∆x∆ 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
tt
tt
t φφφφφ
H.O.T.!3!2 3
32
2
21
−
∂∂∆
−
∂∂∆
−∆
−=
∂∂ + n
j
n
j
nj
nj
n
j tt
tt
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 tt
tt
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 differences First derivative.
Use Taylor expansion :
H.O.T.!3!2 3
33
2
221 +
∂∂∆
+
∂∂∆
+
∂∂
∆+=+n
j
n
j
n
j
nj
nj t
tt
tt
t φφφφφ
H.O.T.32 3
3211
+
∂∂∆
−∆−
=
∂∂ −+ n
j
nj
nj
n
j tt
ttφφφφ
H.O.T.!3!2 3
33
2
221 +
∂∂∆
−
∂∂∆
+
∂∂
∆−=−n
j
n
j
n
j
nj
nj t
tt
tt
t φφφφφ
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 tt
ttφφφφ
Second order central difference, the truncation error is proportional to the time step squared.
( )211
2tO
tt
nj
nj
n
j∆+
∆−
=
∂∂ −+ φφφ
Finite differences Second 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
xx
xx
xx
x φφφφφφ
H.O.T.4
24
42
211
2
2+
∂∂∆
−∆
+−=
∂∂ −+
n
j
nj
nj
nj
n
j tx
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
xx
xx
xx
x φφφφφφ
Second order central difference, the truncation error is proportional to the node distance squared.
Finite differences
φ
t tn-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
211
1
=∆
+−−
∆− −+
+
xt
nj
nj
nj
nj
nj φφφ
αφφ
Called the FTCS scheme (Forward in Time, Central in Space)
Finite differences Dissipation error
02
2=
∂∂
−∂∂
xxc φαφ
Convection-diffusion equation
1st order FD appoximation of the first derivative and 2nd order for the second derivative:
( ) 02
22
21 =∆+
∂∂∆
+∆−
=∂∂ − xO
xx
xxjj φφφφ
( )22
1112
2
2
2 22
xOxx
cxx
xcx
c jjjjj ∆+∆
+−−
∆−
=∂∂
−∂∂∆
−∂∂ −+− φφφ
αφφφαφφ
Numerical dissipation
( )44
42
211
2
2
O4
2x
xx
xx j
jjj ∆+
∂∂∆
−∆
+−=
∂∂ −+ φφφφφ
Finite differences Dispersion error
02
2=
∂∂
−∂∂
xxc φαφ
Convection-diffusion equation
2nd order FD appoximation of the first derivative and 2nd order for the second derivative:
( ) 022
43
3211 =∆+
∂∂∆
+∆−
=∂∂ −+ xO
xx
xxjj φφφφ
( )44
42
211
2
2
O4
2x
xx
xx j
jjj ∆+
∂∂∆
−∆
+−=
∂∂ −+ φφφφφ
Even derivatives are dissipative
Odd derivatives are dispersive
Peclet number (Cell Reynolds number) α
xcPe ∆=
Dispersive schemes are unstable if
2>Pe
Finite Volumes
0=∂∂
+∂∂
+∂∂
yG
xF
tq
vGuF
q
ρρρ
===
0=
∂∂
+∂∂
+∂∂∫ dxdy
yG
xF
tq
ABCD
Green’s theorem ( )
( )( ) GdxFdyds
GF
dsqdVdtd
ABCD
−=⋅=
=⋅+∫ ∫
nHH
nH
,
0
Finite Volumes
Discrete approximation
( ) ( ) 0, =∆−∆+∑DA
ABABCDkj xGyFAq
dtd
ABAB
ABAB
xxxyyy
−=∆−=∆
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
dtdqA
Finite Volumes
02
2
2
2=
∂∂
+∂∂
yxφφ
( ) 02
2
2
2=⋅=
∂∂
+∂∂ ∫∫ dsdxdy
yxABCD
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
xyyxAAyyyyyy
,1,1''''
,1''''
''''
−−
−
∆∆−∆∆==
∆≈∆−≈∆∆≈∆−≈∆
( ) ( )AB
ABkkkjkjAB
kj Ayy
xφφφφφ −∆+−∆
=
∂∂ −−
−
,1,1,
2/1,
( ) ( )AB
ABkkkjkjAB
kj Axx
yφφφφφ −∆+−∆
=
∂∂ −−
−
,1,1,
2/1,
• 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,
=→∆∆
njtx
ε
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 node 11+
−njφ1
1+
+njφ
( ) 022
!6!5!4!3!2
!6!5!4!3!2
72
12
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
xx
xx
xx
xx
xx
xx
x
xx
xx
xx
xx
xx
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
( )
( )33
32
2
2
43
33
2
221
O!3!2
O!3!2
1
tt
tt
tt
tt
tt
tt
ttt
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
xx
xx
xtφφφα
φφ
Now expand 1+njφ
1
2
2 +
∂∂
n
jxφ and
1
4
4 +
∂∂
n
jxφ
Consistency
( )
∆+
∂∂
∂∆+
∂∂
∂∆+
∂∂
=
∂∂
+3
22
42
2
3
2
21
2
2
2tO
xtt
xtt
xx
n
j
n
j
n
j
n
j
φφφαφα
( )
∆+
∂∂
∂∆+
∂∂
∂∆+
∂∂∆
=
∂∂∆
+3
42
62
4
5
4
421
4
42
21212tO
xtt
xtt
xx
xx
n
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
xx
xtt
xx
xtt
xtt
x
tt
tt
x
φ
φφ
φφφα
φφφ
Consistency From the governing equation:
6
63
3
3
4
42
2
2
2
2
2
2
2
2
2
2
xt
xxxxtttt
xt
∂∂
=∂∂
∂∂
=
∂∂
∂∂
=
∂∂
∂∂
=
∂∂
∂∂
=∂∂
∂∂
=∂∂
φαφ
φαφααφαφφ
φαφ
02
2=+
∂∂
−∂∂ n
j
n
j
Extφαφ
We can now write:
...720366122 3
3
2
422
2
22+
∂∂
∆+
∆∆+
∆−
∂∂
∆+
∆−=
n
j
n
j
nj t
xtxtt
xtE φαα
φα
2xts
∆∆
=α
Consistency 02
2=+
∂∂
−∂∂ n
j
n
j
Extφαφ
...120
1411
3611
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
tsst
tst
ttx
txt
ttxtE
φφ
φαα
φα
2xts
∆∆
=α
Consistent if 0lim2
0,=
∆∆
→∆∆ tx
xt
Stability Consider the numerical error *n
jnj
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
211
1
=∆
+−−
∆− −+
+
xt
nj
nj
nj
nj
nj φφφ
αφφ
( ) nj
nj
nj
nj sss 11
1 21 +−+ +−+= φφφφ 2x
ts∆
∆=
α
( ) *11
**1
*1 21 ++−
+ +−+= nj
nj
nj
nj sss φφφφ
If the system is linear we can subract these equations
( ) nj
nj
nj
nj sss 11
1 21 +−+ −++= ξξξξ
Stability von 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
jimj
mθξInitial error: xmm ∆= πθ
( ) nj
nj
nj
nj sss 11
1 21 +−+ −++= ξξξξ
Assume exponetial growth or decay in time: tnm ea ∆= α
Stability von Neumann stability analysis
jitnnj 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 −=∆
tnj
nj eG ∆
+
== α
ξξ 1
( )21 −++= −∆ θθα iit eese ( )2
cosθθ
θii ee −+
=
( )2
cos12
sin2 θθ −=
Amplification factor
Stability von Neumann stability analysis
Stable if 1≤G for all θ
hence for this scheme ( ) 12/sin411 2 ≤−≤− θs
true if 21
≤s 2xts
∆∆
=α
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
0111
=∆−
+∆− −+
+
xc
t
nj
nj
nj
nj φφφφ
The convection equation.
011
=∆−
+∆− −
+
xc
t
nj
nj
nj
nj φφφφ
0=∂∂
+∂∂
xc
tφφ
Central difference for convective term
θsin1 iCG −=
1≤C
xtcC
∆∆
=Courant number
Unstable!
Upwind difference for convective term
( ) θθ sincos11 iCCG −−−=
Stable if CFL (Courant-Friedrich-Levi) condition
Physical interpretation:
txcC∆
∆=
Convection speed
travelling speed
Stability von Neumann stability analysis
02
2 21111
1
=∆
+−−
∆−
+∆
− −+−++
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 ≤≤≤ sCxtcC
∆∆
=Courant number Stable if
2xts
∆∆
=α
Stability von Neumann stability analysis
The convection-diffusion equation.
02
2111
1
=∆
+−−
∆−
+∆
− −+−+
xxc
t
nj
nj
nj
nj
nj
nj
nj φφφ
αφφφφ
02
2
=∂∂
−∂∂
+∂∂
xxc
tφαφφ
Upwind difference for convective term
( ) ( )θθ sincos121 iCsG −−−=
12 ≤+ sCxtcC
∆∆
=Courant number
Stability
02
2
11
111
1
=∆
+−−
∆− +
−++
++
xt
nj
nj
nj
nj
nj φφφ
αφφ
2xts
∆∆
=α
Explicit vs. implicit schemes
Explicit: 02
211
1
=∆
+−−
∆− −+
+
xt
nj
nj
nj
nj
nj φφφ
αφφ
Stable if 21
≤s
Implicit:
( )2/sin411
2 θsG
+=
( )2/sin41 2 θsG −=
( ) nj
nj
nj
nj sss ξξξξ =−++− +
+++
−11
111 21
Stable if 0≥s i.e. unconditionally stable