Other CFD Methodsgtryggva/CFD-Course/2011-Lecture-29.pdfFinite Volume Methods are used in the vast...
Transcript of Other CFD Methodsgtryggva/CFD-Course/2011-Lecture-29.pdfFinite Volume Methods are used in the vast...
Computational Fluid Dynamics
Other!CFD Methods!
Grétar Tryggvason!Spring 2011!
http://www.nd.edu/~gtryggva/CFD-Course/!Computational Fluid Dynamics
Finite Volume Methods are used in the vast majority of CFD codes. However, there are other ways to compute the motion of fluids. Some of the more common alternatives include:!
Spectral Methods!Finite Element Methods!Lattice Boltzmann Methods!Smoothed Particle Hydrodynamics!Vortex Methods and other particle methods!
Here we will briefly examine those!
Computational Fluid Dynamics
Spectral !
Methods!
Computational Fluid Dynamics
Consider the initial-boundary value problem for the one dimensional heat equation!
By standard technique (Fourier sine transform) the solution is!
�
∂f∂t
= ∂ 2 f∂x 2
0 < x < π, t ≥ 0
f (0,t) = f (π,t) = 0f (x,0) = f (x)
�
f (x, t) = an (t)sinnxn=1
∞
∑an (t) = fne
−n 2t
fn = 2π
f (x)sinnx dx0
π∫
Computational Fluid Dynamics
Assuming that the time integration is exact, the error by using only N terms is!
�
f − fN ≈ e−N2t for all time!
This is faster than any power of N. Recall that the error for finite difference/finite volume methods is!
�
O(hα ) ≈ 1N α
Spectral methods are said to have “spectral” or “infinite order” accuracy!This property is not retained if the solution has discontinuities!
Computational Fluid Dynamics
A spectral approximation to the heat equation is now simply!
�
f (x, t) = an (t)sinnxn=1
N
∑ Sum to N only!!
Substituting into the heat equation we get:!
�
dandt
= −n2an; an (0) = fn (n =1,2,…N)
Computational Fluid Dynamics
For nonlinear equations the use of spectral methods becomes much more involved!
�
∂f∂t
+ f ∂f∂x
= ν ∂2 f∂x 2
Expand the solution in a Fourier series!
�
f (x,t) = ak (t)e−i 2π
Lkx
|k|<K∑
�
daldt
+ iπL3 / 2
l al−mam = −ν 2πlL
⎛ ⎝ ⎜
⎞ ⎠ ⎟
|m|<K|l -m|<K
∑2
al
We get the following equation for the coefficients:!
Computational Fluid Dynamics
Computing the nonlinear term can become expensive, particularly for three-dimensional systems. By using the Fast Fourier Transform, the computation can be made faster by taking the inverse transform and do the multiplication in real space. Then Fourier transform the product back into spectral space. The multiplication can, however, lead to aliasing problems where the resolved wave numbers are contaminated by unresolved ones.!
Computational Fluid Dynamics
The fast Fourier transform!
�
f j ≡ ˆ f lei 2π
Nl j
l=1
N
∑
Can be evaluated in 2N log2N operations!
inverse!
�
ˆ f l ≡ f je− i 2π
Nlj
l=1
N
∑
The Cooley-Tukey algorithm!
Computational Fluid Dynamics
Although spectral methods can have very high accuracy, they can be difficult to apply to nonlinear problems, problems with complex boundary conditions, and complicated geometries.!
In addition to Fourier series, several other basis function can be used for other geometries and to control the resolution near boundaries!
Spectral elements methods, where a complex domain is broken into large blocks and each block is treated spectrally can be used treat somewhat complex boundaries !
Computational Fluid Dynamics
Finite Element Methods!
Computational Fluid Dynamics
�
f x( ) = f I NI x( )I∑
�
∂f∂x
= f I∂NI
∂xI∑
Finite element methods are similar to spectral methods in that we expand the solution in terms of a known basis function. Unlike spectral methods, where the basis functions are defined globally over the whole computational domain, in the finite element method the basis functions are defined locally on each element.!
Element 1! Element 2!
Computational Fluid Dynamics
�
Ni(1) = x − xi−1
Δxi; Ni−1
(1) = xi − xΔxi
�
Ni(2) = xi+1 − x
Δxi+1
; Ni+1(2) = x − xi
Δxi+1
For element 2:!
For element 1:!
�
i
�
i +1
�
i −1�
Ni(1)
�
Ni−1(1)
�
Ni(2)
�
Ni+1(2)
Linear basis functions!
element 1! element 2!
Computational Fluid Dynamics
�
∂Ni(1)
∂x= 1Δxi
; ∂Ni−1(1)
∂x= −1Δxi
�
Ni(1) = x − xi−1
Δxi; Ni−1
(1) = xi − xΔxi
�
Ni(2) = xi+1 − x
Δxi+1
; Ni+1(2) = x − xi
Δxi+1
For element 2:!
For element 1:!
�
∂Ni(2)
∂x= −1Δxi+1
; ∂Ni+1(2)
∂x= 1Δxi+1
Computational Fluid Dynamics
Example: Elliptic Problem!
�
∂∂x
k ∂f∂x
⎛ ⎝ ⎜
⎞ ⎠ ⎟ = q
�
R = ∂∂x
k ∂f∂x
⎛ ⎝ ⎜
⎞ ⎠ ⎟ − q
�
W (x)R(x)dxΩ∫ = 0
�
W ∂∂x
k ∂f∂x
⎛ ⎝ ⎜
⎞ ⎠ ⎟ dx
Ω∫ = qWdxΩ∫
The residual is:!
The weighted residual is:!
Or:!
W(x): Weighting function!
Computational Fluid Dynamics
Integrate by parts!
�
W ∂∂x
k ∂f∂x
⎛ ⎝ ⎜
⎞ ⎠ ⎟ dx
Ω∫ = qWdxΩ∫
�
k ∂f∂x
⎛ ⎝ ⎜
⎞ ⎠ ⎟ ∂W∂x
dxΩ∫ + ∂
∂xW k ∂f
∂x⎛ ⎝ ⎜
⎞ ⎠ ⎟ dx
Ω∫ = qWdxΩ∫
�
k ∂f∂x
⎛ ⎝ ⎜
⎞ ⎠ ⎟ ∂W∂x
dxΩ∫ + W k ∂f
∂x⎛ ⎝ ⎜
⎞ ⎠ ⎟
⎡ ⎣ ⎢
⎤ ⎦ ⎥ 2
− W k ∂f∂x
⎛ ⎝ ⎜
⎞ ⎠ ⎟
⎡ ⎣ ⎢
⎤ ⎦ ⎥ 1
= qWdxΩ∫
Evaluating the second term:!
Cancel for adjacent elements!
Computational Fluid Dynamics
Galerkin Method!Take weighting function equal to the interpolation function!
�
f x( ) = f I NI x( )I∑
k ∂ f∂x
⎛⎝⎜
⎞⎠⎟∂W∂x
dxΩ∫ = qW dx
Ω∫
For node i:!
f jj= i−1
i+1
∑ k∂N j
∂xi−1
i+1
∫∂Ni
∂xdx − qNi (x)
i−1
i+1
∫ dx = 0
�
∂Ni(1)
∂x= 1Δxi
;
∂Ni−1(1)
∂x= −1Δxi
�
∂Ni(2)
∂x= −1Δxi+1
∂Ni+1(2)
∂x= 1Δxi+1
Computational Fluid Dynamics
f jj= i−1
i+1
∑ k∂N j
∂xi−1
i+1
∫∂Ni
∂xdx − qNi (x)
i−1
i+1
∫ dx = 0
ki+1/2fi+1 − fiΔx2
− ki−1/2fi − fi−1Δx2
−qi−1 + 4qi + qi+1
6= 0
ki+1/2 =1Δx
ki
i+1
∫ dx
integrating!
where! Notice that a finite difference method would give the same result except with qi on the RHS! �
∂Ni(1)
∂x= 1Δxi
;
∂Ni−1(1)
∂x= −1Δxi
�
∂Ni(2)
∂x= −1Δxi+1
∂Ni+1(2)
∂x= 1Δxi+1
Computational Fluid Dynamics
Finite Element approximation of an unsteady problem:!
�
∂f∂t
+U ∂f∂x
= 0
�
f x( ) = f I NI x( )I∑�
∂f∂tW dx
Ω∫ + U ∂f
∂xW dx
Ω∫ = 0
Weak formulation!
Introduce the finite element representation!
Computational Fluid Dynamics
�
f x( ) = f I NI x( )I∑
�
∂f∂tW dx
Ω∫ + U ∂f
∂xW dx
Ω∫ = 0
Introduce the finite element representation!
�
∂f I∂tI
∑ NINJ dxΩ∫ +U NI
dNJ
dxdx
Ω∫ = 0
or!
�
∂f I∂t
MIJ +U KIJI∑ = 0
I∑
�
MIJ = NINJ dxΩ∫ ; KIJ = NI
dNJ
dxdx
Ω∫ ;
“Mass matrix”! “Stiffness matrix”!
Computational Fluid Dynamics
The mass matrix makes it complex to use simple explicit time integrators. This can be overcome by “lumping” the matrix!
Computational Fluid Dynamics
In two-dimensions triangular (or tedrahedron) elements are frequently used!
Computational Fluid Dynamics
While finite elements dominate solid mechanics, their role in computational fluid dynamics has been secondary to finite volume methods. Indeed, most methodological progress has been first developed in the context of finite volumes and then implemented in the finite element framework. Some areas, such as simulations of viscoelastic flows have, however, relied heavily on finite elements for historical reasons.!
Computational Fluid Dynamics
Lattice Boltzmann Methods!
Computational Fluid Dynamics
Lattice Boltzmann methods use “particles” on hexagonal grids where the particles move according to discrete rules. It can be shown that the macroscopic motion of the particles resembles the Navier-Stokes equations. It is now believed that these methods can yield results comparable in accuracy to other numerical methods!
Lattice Boltzmann methods !Computational Fluid Dynamics
where!
and at each node!
�
e1�
e2
�
e5
�
e6
�
e3
�
e7
�
e4
�
e8
Update the velocity distributions at each node by:!
∂ fγ∂t
+ eγ ⋅∇fv =1ετ
fγ(eq) − fγ( ), γ = 0,1,,M
ρ = fγγ =1
M
∑ ρu = fγγ =1
M
∑ eγ
fγ(eq) = wγ ρ 1+ 3 eγ ⋅u( ) + 92 eγ ⋅u( )2 − 32 u ⋅u( )2⎡
⎣⎢⎤⎦⎥
Lattice Boltzmann methods !
Computational Fluid Dynamics
�
Δt = Δx = Δy = ε
�
α = Δt eγ Δx ; β = Δx ε
�
fγ x,t + Δt( ) − fγ x,t( ) = −α fγ x,t( ) − fγ x −Δteγ ,t( )( )− βτ
fγ x −Δteγ ,t( ) − fγ(eq ) x −Δteγ ,t( )( )
where!
taking! And replacing!
�
fγ x + Δteγ ,t + Δt( ) − fγ x,t( ) = 1τ
fγ(eq ) x,t( ) − fγ x,t( )( )
�
∂fγ∂t
+ eγ ⋅ ∇fv = 1ετ
fγ(eq ) − fγ( ), γ = 0,1,,M
Approximate the time derivative by a first order forward in time, the advection term by upwind and the collision by downwind, we get!
�
Δx = Δt eγ
�
x + Δteγ yields!by!
�
x
Lattice Boltzmann methods !Computational Fluid Dynamics
�
Δt = Δx = Δy = ε
�
α = Δt eγ Δx ; β = Δx ε
�
fγ x,t + Δt( ) − fγ x,t( ) = −α fγ x,t( ) − fγ x −Δteγ ,t( )( ) − βτ
fγ x −Δteγ ,t( ) − fγ(eq ) x −Δteγ ,t( )( )
Set!
taking!
Replace!
�
fγ x + Δteγ ,t + Δt( ) − fγ x,t( ) = 1τ
fγ(eq ) x,t( ) − fγ x,t( )( )
�
Δx = Δt eγ
�
x + Δteγby!
�
x
�
fγ x + Δteγ ,t + Δt( ) − fγ x + Δteγ ,t( ) = −Δt eγΔx
fγ x + Δteγ ,t( ) − fγ x,t( )( ) − Δt eγετ
fγ x,t( ) − fγ(eq ) x,t( )( )
And crossing out the common term yields!
Proof!Lattice Boltzmann methods !
Computational Fluid Dynamics
eγ =ΔxΔt
cos π2
⎛⎝⎜
⎞⎠⎟γ −1( ),sin π
2⎛⎝⎜
⎞⎠⎟γ −1( )⎛
⎝⎜⎞⎠⎟, γ = 1,3,5,7
eγ = 2 ΔxΔt
cos π2
⎛⎝⎜
⎞⎠⎟γ −1( ) + π
4,sin π
2⎛⎝⎜
⎞⎠⎟γ −1( ) + π
4⎛⎝⎜
⎞⎠⎟, γ = 2,4,6,8
�
e0 = 0
w0 = 0wγ = 4 9 γ = 1,3,5,7wγ = 1 36 v = 2,4,6,8 �
e1�
e2
�
e5
�
e6
�
e3
�
e7
�
e4
�
e8
The weights must be taken to be!
The displacement vectors are!
Lattice Boltzmann methods !Computational Fluid Dynamics
�
e1�
e2
�
e5
�
e6
�
e3
�
e7
�
e4
�
e8
�
fγ x + Δteγ ,t + Δt( ) − fγ x,t( ) = 1τ
fγ(eq ) x,t( ) − fγ x,t( )( )
�
ρ = fγγ =1
M
∑
�
ρu = fγγ =1
M
∑ eγ�
fγ(eq ) = wγ ρ 1+ 3 eγ ⋅u( ) + 9
2eγ ⋅u( )2 − 32 u ⋅u( )2⎡
⎣ ⎢ ⎤ ⎦ ⎥
where!
and at each node!
Update the velocity distributions at each node by:!Summary:!
Lattice Boltzmann methods !
Computational Fluid Dynamics Lattice Boltzmann methods !
Advantages!
Very easy to program–parallelization easy!
Fast–in part because incompressibility is not enforced!
Disadvantages!
Difficult to implement new physics—must find a discrete equation that corresponds to the new physics!
The flow is not completely incompressible!
Computational Fluid Dynamics Lattice Boltzmann methods !
By now it is understood that LBM are give results comparable to second order finite difference/volume methods!
LBM has been extended to more complex flow, including multiphase flows with sharp interfaces!
The figure shows a comparison of the unsteady rise of a buoyant bubble computed by LBM (left) and front tracking finite volume method (right).!
From: K. Sankaranarayanan, I.G. Kevrekidis, S. Sundaresan , J. Lu, G. Tryggvason. A comparative study of lattice Boltzmann and front-tracking finite-difference methods for bubble simulations. Int. J. Multiphase Flow 29 (2003) 109–116.!
Computational Fluid Dynamics
Smooth Particle Hydrodynamics!
Computational Fluid Dynamics
Smooth Particle Hydrodynamics: the fluid mass is lumped into smoothed blobs that are moved using Newtonʼs second law directly, without an underlying mesh!
Smooth Particle Hydrodynamics!
x1 x2 x3
Computational Fluid Dynamics
In SPH the fluid is modeled as a collection of smooth “blobs” or particles !
A(r) = A(r ')δ∫ | r − r ' |( )dr '
We start by the relationship!
And then approximate the delta function by a smoother “kernal”!
A(r) = A(r ')W (| r − r ' |,h)∫ dr '
W (r,h)∫ dr = 1 & W (r,h) h→0⎯ →⎯⎯ δ r( )
Where:!
W (r,h) =1
π 3/2hexp
r2
h2
⎛
⎝⎜⎜
⎞
⎠⎟⎟
We could select the kernal to be a Gaussian, although usually we desire a compact support!
Smooth Particle Hydrodynamics!Computational Fluid Dynamics
ρi = ρ(ri ) = mk
k∑ ρk
ρk
W (| ri − rk |,h) = mkk∑ W (ri − rk ,h),
A(r) = A(r ')W (| r − r ' |,h)∫ dr '
= A(r ')ρ(r ')ρ(r ')
W (| r − r ' |,h)∫ dr '
= mkk∑ Ak
ρk
W (| r − rk |,h)
Smooth Particle Hydrodynamics!
mk ≈ ρ(r ')∫ dr '
Approximate the integral by a sum over the smoothed particles:!
For density we have!
Computational Fluid Dynamics Smooth Particle Hydrodynamics!
The introduction of the smoothed kernal allows us to compute the gradient!
The introduction of the smoothed kernal allows us to compute the gradient!
∇A(r) = mk
k∑ Ak
ρk
∇W (| r − rk |,h)
Computational Fluid Dynamics
1ρ∇P = ∇
Pρ
⎛⎝⎜
⎞⎠⎟+
Pρ2 ∇ρ
∇ρ = mk
k∑ ∇W (| r − rk |,h)
∇
Pρ
⎛⎝⎜
⎞⎠⎟= mk
k∑ Pk
ρk2 ∇W (| r − rk |,h)
For the pressure we write:!
And using that!
The momentum equation is!
dui
dt= − mk
k∑ Pk
ρk2 +
Pi
ρi2
⎛
⎝⎜
⎞
⎠⎟ ∇W (| ri − rk |,h)
∇A(r) = mk
k∑ Ak
ρk
∇W (| r − rk |,h)
dudt
=−1ρ∇P
Start with the momentum equation!
Computational Fluid Dynamics
∇ρ = mk
k∑ ∇W (| r − rk |,h)
Similarly, for density we start with!
And using that!
The mass conservation equation is!
dρi
dt= − ρ∇ ⋅u( )i
ρ∇ ⋅u( ) = ∇ ⋅ ρu( ) − u ⋅∇ρ
∇A(r) = mk
k∑ Ak
ρk
∇W (| r − rk |,h)
dρi
dt= mk
k∑ uk − ui( ) ⋅∇W (| ri − rk |,h)
Sometimes an alternative form is used!
dρi
dt= ρi
mk
ρkk∑ uk − ui( ) ⋅∇W (| ri − rk |,h)
Computational Fluid Dynamics
∇ρ = mk
k∑ ∇W (| r − rk |,h)
The energy equation is !
Using that!
gives!
dEdt
= −Pρ∇ ⋅u
Pρ∇ ⋅u = ∇ ⋅
Pρ
u⎛⎝⎜
⎞⎠⎟− u ⋅∇
Pρ
⎛⎝⎜
⎞⎠⎟
∇A(r) = mk
k∑ Ak
ρk
∇W (| r − rk |,h)
dEi
dt= mk
Pk
ρk2
k∑ uk − ui( ) ⋅∇W (| ri − rk |,h)
Computational Fluid Dynamics
dui
dt= − mk
k∑ Pk
ρk2 +
Pi
ρi2
⎛
⎝⎜
⎞
⎠⎟ ∇W (| ri − rk |,h)
dri
dt= ui
dρi
dt= ρi
mk
ρkk∑ uk − ui( ) ⋅∇W (| ri − rk |,h)
dEi
dt= mk
Pk
ρk2
k∑ uk − ui( ) ⋅∇W (| ri − rk |,h)
Summary of governing equations!
Mass!
Momentum!
Energy!
Advect particles!
Smooth Particle Hydrodynamics!
P = P(ρ,e)Plus an equation of state!
Computational Fluid Dynamics
W (s) =10
7πh2
1−32
s2 +34
s3 0 ≤ s ≤ 1
14
(2 − s)2 1< s ≤ 2
0 2 < s < ∞
⎧
⎨
⎪⎪⎪
⎩
⎪⎪⎪
Smooth Particle Hydrodynamics!
Several different kernals have been used. The following is a popular one:!
For a more complete introduction, see: J. J. Monaghan. “An introduction to SPH.” Computer Physics Communications 48, 1988, Pages 89-96.!
SPH has been modified to include viscous effects by “local averaging” as well as incompressibility.!
Computational Fluid Dynamics
Other Particle Methods!
Computational Fluid Dynamics
Particle methods cover a large range of physical situations, some overlapping with more conventional methods. Particle methods include:!
!Point vortex/vortex blob methods!
!Particle-in-Cell codes!
!Direct Simulation Monte Carlo (rarified flow)!
!Dissipative particle methods !
!Molecular dynamics!
!and many more!
In many cases a grid is used also, either for efficiency or to account for some of the physics!
Not really for continuum flows!
Computational Fluid Dynamics
Dissipative Particles Dynamics: particles represents molecules or fluid blobs but while the method has similarities with SPH, it is generally used to model mesoscale behavior of complex fluids and more liberties are taken in modeling the interactions of the particles!
Molecular Dynamics: Not really a CFD technique but can be used to simulate small (really small) fluid regions!