0% found this document useful (0 votes)
9 views53 pages

05-Computational Grid and Time Step

Sogang University CFD lecture note ch.5

Uploaded by

이동근
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views53 pages

05-Computational Grid and Time Step

Sogang University CFD lecture note ch.5

Uploaded by

이동근
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

Introduction to computational

grid and time step

Computational Fluid Dynamics


* Includes some topics of numerical method class
* : Skipped in the exam.
Sources of error in CFD ( simulation )
• Human error . mastake
– ex) wrong viscosity value
– Solution : 확인 & 확인

• Modeling error
– Error in the differential equation
4 deat
– ex)  = , constant density for aero-acoustics, etc. gas Frealgas
– Can be human error
– Solution : 공부 & 확인

• Discretization error (truncation error)


– Error from discretization method in terms of Taylor series expansion
– Solution : Reduced by using a smaller grid spacing

• Round-off error
– Machine epsilon : The smallest real number represented by computer
– Below this, the numeric information is lost
– Related to computer memory architecture
• The smallest number expressed by 4-byte real number : 10~
– Solution : Use 8-byte real number (long float in C, r8 in Star-CCM+)
Sources of error in CFD
• Convergence error
– Error in the numerical solution
– Only for an iterative method for solving matrix
• Simulation은 기본적으로 연립 방정식을 푸는 것
– 연립 방정식은 기본적으로 matrix식 Ax=b로 표현 가능
• Direct method * 5M .
Unknown

F
.

 =   * 25o16 . mafrixelements



• Iterative method
* 4byteX 25시 lb
. = lol4 bytes
– 대부분의 경우에 해당

 =   +  Convergence error

– Solution : Convergence

(residual) criterion (수렴 조건)을 낮춤
x Time 가
Why computational grid is necessary
• Governing equation for heat conduction
∇  = 

– Poisson equation
– Categorized as an elliptic PDE
– q is the heat source/sink

• In 1-D
  
In Math class = () =  +   + 
  2

In CFD class ℎ ℎ ℎ ℎ

T i−2 T i −1 Ti T i +1 T i+2

– h is the grid spacing


Why computational grid is necessary
• In 1-D
h h h h
T i−2 T i −1 Ti T i +1 T i+2

  − 2 + 


= =  , " = 1,2, ⋯ , $
  ℎ
– Governing differential equation => a series of algebraic equations

• In 3-D
Computational grid (mesh) in 2-D or 3-D
• Terminology for computational grid
small C
O
V
node
.

y
/

Cell = control volume into which cell center

domain is broken up.


Ocoredge )
face


Node = grid point.
cell

Cell center = center of a cell. sface center 2D computational grid

O
Edge = boundary of a face.


Face = boundary of a cell.
ㅇ node

O ㅇ
edge
"
face cell

3D computational grid
Computational grid in 2-D or 3-D
• Topology for computational mesh

hexahedron
… prism or wedge
~

6 5

polyhedron

(arbitrary)
tetrahedron
pyramid 다면체
F 5
Computational grid in 2-D or 3-D
• Examples : hexahedral mesh, trimmerftrimmed
d
Otfine

ㅇ ㅇ


Computational grid in 2-D or 3-D
• Examples : tetrahedral mesh
Computational grid in 2-D or 3-D
• Examples : polyhedral mesh

O
fine L
Computational grid in 2-D or 3-D
• Examples of mesh
– Tri/Tetrahedral mesh vs. Quad/Hexahedral mesh

[ *
• Tri/Tetrahedral mesh : Easier (faster) generation
• Quad/Hexahedral mesh : More accurate solution

.
다뀔 .. .
Computational grid in 2-D or 3-D
• Examples : Hybrid mesh
– Types by region
tet mesh
Specific regions can be meshed with
different cell types.
hex mesh

Both efficiency and accuracy are enhanced


relative to a hexahedral or tetrahedral mesh
alone.

wedge mesh

Hybrid mesh for a valve port


Computational grid in 2-D or 3-D
• Examples : Hybrid mesh
– Types by orientation
– Polyhedral - Generalized Cylinder Mesher - Prism Layer

Tvhexahedral
polyhedral >
Computational grid in 2-D or 3-D
• Structured/Unstructured mesh
Single-Block Structured Mesh
- i,j,k indexing to locate neighboring cells + +
- Grid lines must pass all through domain & + +

→ Obviously can’t be used for very complicated geometries 딸

Multi-Block Structured Mesh


- Uses i,j,k indexing within each mesh block (ij )

- The grid can be made up of arbitrarily-connected blocks


→ More flexible than single block, but still limited

Unstructured Mesh
- The cells are arranged in an arbitrary fashion
- No i,j,k grid index, no constraints on cell layout (usually 1-D index)
→ There is some memory and CPU overhead for unstructured referencing 체 N ~
Topics on computational grid
• How to make a computational grid and what is a good
grid?


• How to convert a governing equation to a series of
algebraic equations?
– Discretization in space
– Finite difference method
1 –

Finite volume method
Finite element method

• What is the error from the approximation?


– Error evaluation using Taylor-series expansion
Topics on computational time step
• How to convert a governing equation to a series of
algebraic equations?
– Discretization in time

• What is good discretization in time?


– On accuracy & error term
• Derived by Taylor series expansion
– On stability
• How large Δt can be used to solve a PDE or ODE?
– The larger, the better => we can finish a simulation earlier
• Stability analysis
디 stability
U
accuracy

( divergenceblow )
up
-
Taylor series expansion

Computational Fluid Dynamics


fn
Papproximate
a .

Taylor series expansion


• An important theory to analyze numerical accuracy
FCextrapolation (guessing a function value) based on a
– An '

orlation
polynomial built using a passing point and derivative information
interl
)

at the point x
[ 보간)
present tirate
– Various forms
%
• Based on a linear polynomial (2 terms)

%
% ℎ = %(0) + ℎ + Ο ℎ

resent' slopetime
future
'


|

• Based on a quadratic polynomial (3 terms)


% ℎ   % 0 ℎ 

% ℎ = %(0) + ℎ + 
+ Ο ℎ'
 2 
• Based on a cubic polynomial (4 terms) iaterporlation

% ℎ   % ℎ'  ' % 요
% ℎ = %(0) + ℎ + 
+ '
+ Ο ℎ) X extraporlation
 2  6  고
O
difficult
• In most general form, (가장 일반적인 형태로) X
. + +
ℎ  %
% ℎ = %(0) + * +
+ Ο ℎ.
,! 
product
+/
Error of Taylor series expansion
• From the general form of extrapolation
– Note that all derivatives are defined at x=0 ( Passing point)

.
ℎ+  + %
% ℎ = %(0) + * + 0
,!  +
+/

– Error dependency on $

• A reasonable guess on error


– As the number of terms increases ($ increases, 더 고차의 항이 들
어갈수록), the error of extrapolation decreases
• When $ becomes infinity, the extrapolation converges to the exact
value
6
이 ( 하고 ℎ+  + %
%12345 ℎ = %(0) + *
~ ,!  +
+/
Error of Taylor series expansion
• Error for a finite number (=n) of terms
% ℎ   % ℎ'  ' % ℎ)  ) %
%12345 ℎ = %(0) + ℎ + + + +⋯
 2   6  ' 24  )
hN Ist error term
– For Taylor series with 2 terms ⇒ as ,

becomes dominan가
% ℎ   % ℎ'  ' % ℎ)  ) %
%12345 ℎ = %(0) + ℎ + + + +⋯
 2   6  ' 24  )
Extrapolation Error term exact guess


= -

• (Most dominant) Error is reduced to about ¼ when ℎ becomes ½


• Called as “second-order” error
prentotn leading
order error term
-


– For Taylor series with 3 terms
%12345 ℎ = %(0) + ℎ

+
2  
+O
% ℎ   % ℎ'  ' % ℎ)  ) %
+
6  ' 24  )
+⋯

Extrapolation Error term


• (Most dominant) Error is reduced to about 1/8 when ℎ becomes ½
• Called as “third-order” error 3 H - order
~
accuracy
( exponet fh ) .
Error of Taylor series expansion
• Error for a finite number (=n) of terms

– In the most general form


. 6
ℎ+ + %
ℎ+  + %
%12345 ℎ = %(0) + * +* leading ordererror : A - th order
,!  + ,!  + -
>

+/ +/.

Extrapolation Error term

• Error term is reduced to about 1/2n when ℎ becomes ½


• Called as “(n)th-order” error term
• Called as “(n)th-order” accuracy

• From now on, Taylor series expansion is written as


.

% ℎ = %(0) + *
ℎ+  + %
,! 
+/
+ + Ο ℎ. O
Extrapolation Error term
Numerical differentiation using Taylor series expansion
• Accuracy analysis of numerical derivatives 00
%(0) %(ℎ) − %(−ℎ) 뉴
=
 2ℎ %(−2ℎ) %(−ℎ) %(0) %(ℎ) %(2ℎ)

• Error estimation using Taylor series expansion


% ℎ   % ℎ'  ' % 스⑤ ( O ( h 4

d( fhd '. f Ihol "이
"

% ℎ = %(0) + ℎ + + + Ο ℎ) (f 6

= )

 2   6  '

% ℎ   % ℎ'  ' %
% −ℎ = %(0) ㅇ
−ℎ +  − ' + Ο ℎ)
 2  6 
.

%(ℎ) − %(−ℎ)
=
1
%(0) + ℎ
%

+
ℎ   %
2  
+
ℎ'  ' %
6 
% ℎ   % ℎ'  ' %
'
+ Ο ℎ) 따빠
E"
5
2ℎ 2ℎ )
없"
"
x
− %(0) − ℎ + − + Ο ℎ
 2   6  '
num ,

1 % ℎ'  ' % )
% ℎ  ' % '
derivative = 2ℎ + + Ο ℎ = + + Ο ℎ
2ℎ  3  '  6  '
.
guess (exact) Derivative Second-order error term

Error estimation using Taylor series expansion
• Accuracy analysis of numerical derivatives
– Using Taylor series expansion
φ i −2 φ i −1 φi φ i +1 φ i+2
% % − %
= + Ο ℎ : second-order central difference
 2ℎ

% % − %
= +Ο ℎ : first-order forward difference
 ℎ

% % − %
= +Ο ℎ : first-order backward difference
 ℎ

% 3% − 4% + %


= + Ο ℎ : second-order backward difference
 2ℎ

% % − 8% + 8% − %


= + Ο ℎ) : fourth-order central difference
 12ℎ

  % % − 2% + %



= 
+ Ο ℎ
 ℎ
Summary on Taylor series expansion
• Taylor series expansion is an extrapolation based on a
value and derivatives at a point
passing Point
• Size of the error (i.e. accuracy) is estimated based on the
exponent of the distance ℎ
– Second-order, third-order, nth-order
~ ㅡ

• Error of numerical derivatives (and almost everything in


1-D) can be evaluated using Taylor series expansion

• The size of error is affected by 3 factors


% ℎ   %
% ℎ = %(0) + ℎ + 
+ Ο ℎ'
 2 
Second-order error term
– Number of terms included in
extrapolation
( – ℎ : grid spacing
– Size of derivatives
Computational grid and
truncation error

Computational Fluid Dynamics


OA D

Finite difference method (FDM)⇒ 쟬


• Taylor series expansion to approximate derivative
operators
)
; = ; + ℎ
; ℎ    ; ℎ '  ' ; ℎ )  ) ;

+
2   +
6  ' +
24  ) + Ο ℎ< e× y
; ; − ;
= + Ο ℎ FDM
 2ℎ

σC ;
>
+
;

=0 ⇒
;
>
+
; − ;
2ℎ

– Derivative of any order can be derived


=0 ⇒
; . − ; .
Δ>
+

음.
; − ;
2ℎ

udexofgrid
=0

n. indexof fimestep
• The size of error is affected by 3 factors
; − ; ; ℎ  ' ;
= + '
+ Ο ℎ'
2ℎ  6 

– Accuracy ~
Second-order error term
Hofterms
– ℎ : grid spacing
– Size of derivatives
~
Conditions for a good grid in 1-D
• Good grid is one that minimizes the error
; − ; ; ℎ  ' ; '
= + + Ο ℎ
2ℎ  6  '
Error term
– Smaller ℎ => error term decreases
– Smaller size of derivatives => error term decreases D
• In order to reduce the error, small ℎ is necessary in the region where
the size of derivatives is large
• So, non-uniform ℎ may be desirable

– In 1-D, different grids can be generated by modifying ℎ (grid


spacings) 짧기
짧고
hi −2 hi −1 hi hi +1
T i−2 T i −1 Ti T i +1 T i+2
hp rforfast
.
.
computation
hN tfor
Cefficiency )
smallererrorl
Conditions for a good grid in 1-D
• Good grid is one that minimizes the error
 ℎ     ℎ '  ' 
 =  + ℎ + + + Ο ℎ)
hi−2 hi −1 hi hi +1  2   6  '

 '
T i−2 T i −1 Ti T i +1 T i+2  ℎ    ℎ  ' 
 =  − ℎ + − + Ο ℎ)
 2   6  '

'
 −   ℎ − ℎ    1 ℎ + ℎ'  ' 
= +  + ' + Ο ℎ'
ℎ + ℎ  2  6 ℎ + ℎ 

Error term – first-order

– (hi-hi-1) increases => first-order error term increases


– Expansion ratio = hi / hi-1
• Expansion ratio close to 1 => good grid
Conditions for a good grid in 1-D
• Summary
– A good grid can reduce the error
– Smaller overall grid spacing
– Smaller grid spacing in the region where the size of derivatives
~

are large onovuniformgrid


– Expansion ratio close to 1
Conditions for a good grid in 2-D or 3-D
• Good grid is one that minimizes the error
– Smaller overall grid spacing
• More accurate but more expensive
– Smaller grid spacing in the region where the size of derivatives
are large
– Expansion ratio (인접한 cell사이의 크기 ratio) close to 1
• Which grid is better?
– Case #1
Same as 1-D case
smooth change large jump in
in cell size cell size
– Case #2 : 프로펠러 날개 끝 쪽의 속도 contours 태며
타력
sma ~

derivative
.

II
flarge
cerivative
Conditions for a good grid in 2-D or 3-D
– Case #2 : 프로펠러 날개 끝 쪽의 속도 contours

• Left one is better in terms of the expansion ratio


• Right one aims to reduce the error by using smaller grid spacing h
Conditions for a good grid in 2-D or 3-D
• Good grid is one that minimizes the error
– Skewness (based on the optimum angle) close to zero =
정각형
= max C − CDE5FGF
• The optimum angle is 60 deg. for a triangle, 90 deg. for a rectangle,
etc. (angle between edges for a regular polygon (정각형))
• Examples
C = 90 θ max
θ min
Skewness = 0 Skewness > 0
optimal (equilateral) cell

circumcircle

actual cell

• How does skewness affect the accuracy?


Conditions for a good grid in 2-D or 3-D
• How skewness affects the error
– Analysis of the error term is possible using the multi-dimensional
Taylor series expansion
∂φi ∂φi ∆x12 ∂ 2φi ∆x1 ∆y1 ∂ 2φi ∆y12 ∂ 2φi
φ1 = φi + ∆x1
∂x
+ ∆y1
∂y
+
2 ∂x∂x
+
2 ∂x∂y
+
2 ∂y∂y
+ Ο h2( )

1 i 2 1 i 2

3 3

∂φi φ2 − φ1 ∂φi φ2 − φ1
∂x
=
h
+ Ο h1 ( ) = + Ο h0 ( )
∂x h
∂φi φ1 + φ2 − 2φ3 ∂φi φ1 + φ2 − 2φ3
= + Ο(h1 ) = + Ο h0 ( )
∂y 3h ∂y 3h

– For case with zero skewness, 1st order accuracy but 0th order
accuracy for skewed grid
Conditions for a good grid in 2-D or 3-D
• Good grid is one that minimizes the error
– Aspect ratio (종횡비)
• Aspect ratio is the ratio of longest edge length to shortest edge
length
• Equal to 1 (ideal) for a regular polygon (정각형)

aspect ratio = 1 high- aspect- ratio quad

aspect ratio = 1 high- aspect- ratio triangle

Good Not good

• How does the aspect ratio affect the accuracy?


Conditions for a good grid in 2-D or 3-D
• How aspect ratio affects the error
– Consider a 2-D heat conduction problem with a large aspect
ratio
i, j + 1

∂ 2T ∂ 2T i − 1, j i, j i + 1, j
∇ 2T = q 2
+ 2 =q
∂x ∂y
i, j − 1

Ti −1, j − 2Ti , j + Ti +1, j Ti , j −1 − 2Ti , j + Ti , j +1


h 2
( )
+ Ο h 2x +
h 2
( )
+ Ο h 2y = qi , j
x y

– If hx = 100hy
Ti −1, j − 2Ti , j + Ti +1, j + 10000Ti , j −1 − 20000Ti , j + 10000Ti , j +1
h2x
( ) ( )
+ Ο 10000 h 2y + Ο h 2y = qi , j

• Size of coefficient in x-direction is relatively so small that it can be


ignored (x 방향은 제외한 것과 비슷한 효과)
– Error size in x-direction can increase a lot
Summary of good grid in 2-D or 3-D
• Smaller overall grid spacing

서 • Smaller grid spacing in the region where the size of


derivatives are large

• Expansion ratio close to 1

• Skewness close to zero


삶 [• Aspect ratio close to 1

• + ??
Basics to select time step size &
grid spacing

Computational Fluid Dynamics


Discretization in time
• "Computational grid" in time
∆t n −2 ∆t n −1 ∆t n ∆t n +1
; ;
+ =0
>  f n −2 f n −1 fn f n +1 f n +2

– In an unsteady (transient) simulation, the solutions at discrete


time stamps are obtained

• Finite difference method in time


– Use the Taylor series expansion to approximate derivative
operators
;. Δ>    ;. Δ> '  ' ;. Δ> )  ) ;.
;. = ;. + Δ> +  + ' + ) + Ο Δ> <
> 2 > 6 > 24 >
;. ;. − ;.
⇒ = + Ο Δ> 
> Δ>

– Δ> : computational time step -< 71 ,


h
General rules for computational time step
* n , MH fime
• Question: How to choose Δ>?
.
step
Egrid pt - in fime )

• Rule #1. The smaller, the more accurate ∂f


=
f n +1 − f n ∆t 2 ∂ 3 f

24 ∂t 3
– We know that the error decreases as Δ> decreases ∂t ∆t
f n +1 − f n
– How small should it be to get a reasonable solution?=
∆t
+ Ο ∆t 2 ( )

• Rule #2. Based on the size of time derivative


– Similar to discretization in space, we need small Δ> only in the
regions where the derivative (in time) is large

f (t )

t
small ∆t is desirable large ∆t is fine
1
'
forsmaller error
forefficienct
General rules for computational time step
• One question: How to choose Δ>?
• Rule #3 Based on the time scale
– See the “time scale” of flow variables…

– If Δ> is similar to the spacing between black points, what we get


from a simulation can be just a steady solution!
– Use several Δ> spacings (>=8) per an important time scale
Determining time step using time scale
• Examples of Rule #3
– From the “time scale” of flow variables…

• Case #1. Acoustics (noise) problem


– Important frequency of a sound wave ranges
• 50~2000 Hz (1/sec)
– The time scale ranges
• 0.0005~0.02 (sec)
– If we want 8 intervals in a time scale…
• Δ> = 0.0005/8~0.02/8 (sec)
• We have to choose the smaller one for accuracy
• => Δ> = 0.0005/8

• For a flow physics, you need to know the physical time


scale
– Ex) Smallest scale of turbulence
Setting time step using time scale
• Examples of Rule #3
– From the “time scale” of flow variables…

• Case #2. Let’s guess the “time scale”


– A flow around a circular cylinder
I = 1 J/L M=1 J

– Try to compute the time scale by simply using the dimensions


P$Q>ℎ J M
"J LNO  L = = =1 L
RO">S J/L I

– In CFD, the observed time scale=2.7(s)

– Not perfect but not that bad


Setting time step using time scale
• Examples of Rule #3

• Case #3. Guess the “time scale”


– Transonic airplane (Ma~1) of length=100m & height=10m
– Speed of airplane = speed of sound : about 300 m/sec
– Then, the time scale (sec) is
• About 100 (m) / 300 (m/sec)
• About 10 (m) / 300 (m/sec)
•  = 0.03~0.3 (sec)
– If we want 8 intervals in a time scale…
• Δ> = 0.03/8~0.3/8 (sec)
• Choose the smaller Δ> …
Setting time step using CFL
• How to choose a right time step Δ> in a simulation?
– For accuracy & stability

• Rule #4 Based on CFL (Courant-Friedrich-Lewy) number


– Discussed in numerical PDE part
– Definition of CFL number in 1-D
. velocitySizelat )
VΔ> *
aghid P 마
TUP = Xo기 .
grid
Δ size

– Meaning of CFL number


• Distance a particle travels in a time step (u Δt) / grid spacing (Δx)
• Number of grid points a particle travels in a time step

– Typically used range of CFL number


• Less than CFL=10
• Typically 0.1~5
Summary : Basics rules on time step
• To finish a simulation earlier
– The larger, the better

• For accuracy
– Rule #1. The smaller, the better
– Rule #2. Based on the size of time derivative
• Similar to discretization in space, we need small Δt only in the
regions where the derivative (in time) is large
– Rule #3 Based on the time scale
• Use several Δ> spacings (>=8) per an important time scale
– Rule #4 Based on CFL number
• CFL=0.1~5
Summary: Basics rules on grid for accuracy
• Rule #1. The smaller, the more accurate
• Rule #2. Based on the size of spatial derivative
• Rule #3. Based on the scale in space
– Example: A flow around a circular cylinder
• Contours of the x-velocity

m 2 ogridy
55
7

Necessary grid spacing?

• Length scale in x : similar to the distance between red spots (high U)


– About 5 (m)
• If we want more than 20 intervals in a length scale
– Δx <= 0.25 (m)
Good computational grid for accuracy
• Smaller overall grid spacing

• Smaller grid spacing in the region where the size of


derivatives are large

• Expansion ratio close to 1

• Skewness close to zero

• Aspect ratio close to 1

• Resolving important physical scales


사례 : 벽면 격자를 위한 prism layer
• Where do you need a smaller grid size?
. large
change ( derivafive ) 어 Wal normal

d
*
x
사례 : 벽면 격자를 위한 prism layer
• Modes of prism layer (Star-CCM+)
– Stretch factor
– Wall thickness
– Thickness ratio
Stretch factor
• Parameters
– Number of Prism Layers
– Prism Layer Stretching
– Prism Layer Total Thickness

• Ex) Number of Prism Layers 2, Stretching 1.5, Total


thickness 5mm
– First Layer thickness 2mm, Second Thickness 3mm

smallest '
Wall thickness
• Surface의 첫번째 layer thickness를 우선 지정
– Properties 기반 나머지 layer들의 thickness를 자동 조정

• Parameters
– Number of Prism Layers
– Prism Layer Near Wall Thickness
– Prism Layer Total Thickness
Thickness ratio
• Parameters
– Number of Prism Layers
– Prism Layer Total Thickness
– Prism Layer Thickness Ratio
• 첫번째와 마지막 layer thickness의 비율
• 중간 layer들의 thickness는 자동의 계산
surface
(
사례 : Volumetric control of grid spacing
• 특정 영역(refinement zone)에서 격자 조밀도 변화
원래 격자

중요한
유동 특성이
나타나는 곳

Volume
설정

부분적으로 격자를
조밀하게 변화

You might also like