Introduction to Fluid Dynamics & Applications Nitin Jain COMP 259 Class Presentation The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL.

Download Report

Transcript Introduction to Fluid Dynamics & Applications Nitin Jain COMP 259 Class Presentation The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL.

Introduction to Fluid
Dynamics & Applications
Nitin Jain
COMP 259
Class Presentation
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Motivation
• Starting point for all simulation
and animation that involves fluid
flow : indispensable for physically
based modeling
2
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Overview
• Understanding & Deriving the NavierStokes equations
• Solving the Navier-Stokes equations
- Basic approach
- Boundary conditions
• Applications
- Lid Driven Cavity flow
- Smoke
3
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
So, Let’s begin the journey…
4
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Foundations
• Physical Quantities
-
5
u
P
d
g
:
:
:
:
The velocity field
Pressure
Density
Gravity & other external forces
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Foundations
Operators

- gradient
div
2
6
u ,∂
u 
u   ∂
x
∂
y
 ∂
- divergence


div u    u  u
- Laplacian
  2u
u
2
x
x
 u
2

u
2 
y
y 2
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Navier-Stokes Equations

u  0



 1
du
2
 (u  )u  p   u  f
dt

convection
7
pressure viscosity
external
forces
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Navier-Stokes Equations
• In two
dimensions …
8
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Boundary Conditions
•
•
•
•
•
9
No-slip condition
Free-slip condition
Inflow condition
Outflow condition
Periodic Boundary Condition
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Derivation
• Transport Theorem
• Conservation of Mass
• Conservation of Momentum
10
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Transport Theorem

 (c , t )

c
0
t


 
d


f ( x , t )dx    f  div( fu )( x, t )dx


t t
dt t


  
x  (c , t )
11
  
 
u ( x , t )   (c , t )
t
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Conservation of Mass




mass    ( x,0)dx   ( x, t )dx
0
t
;  is density
Transport theorem


 
d


 ( x, t )dx      div(u )( x, t )dx  0


t t
dt t




  div( u )  0
t
 is constant
for incompressible
fluids
Integrand vanishes

div u  0
Continuity equation
12
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Conservation of Momentum
momentum 
t

  
 ( x, t )u ( x, t )dx
changein momentum actingforces
  

body forces:   ( x, t ) f ( x, t )dx
t
 
surface forces:  σ( x, t )nds
t

σ : stress tensor n : normal
d
dt
13

t
  

  

 
 ( x , t )u ( x , t )dx    ( x , t ) f ( x , t )dx   σ( x , t )nds
t
 t
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Conservation of Momentum
d
dt

t
  

  

 
 ( x , t )u ( x , t )dx    ( x , t ) f ( x , t )dx   σ( x , t )nds
t
 t
Transport theorem
Divergence
theorem






d
( u )  (u  )( u )  ( u ) div u  g  div σ  0
dt
…



 1
du
2
 (u  )u  p   u  f
dt

Momentum equation
14
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Dynamic Similarity of flows
• Dimensionless quantity =
dimensional quantity/ reference
quantity with same physical units
• The reference quantities used should
possess certain properties :
- They should be constant for the problem
- They should be known in advance
- They should be characteristic for the problem
15
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Dimensionless Variables
In a wind tunnel, L = length of the obstacle in the
flow, u’,P’and p’ are the upstream velocity,
pressure and density.
•
•
•
•
16
x’’ = x/L
t’’ = u’t/L
u’’ = u/u’
P’’ = (P-P’) / (p’u’2)
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Reynolds Number and Froude
number
• These numbers describe the properties of
the flow
- Re = p’u’L/μ
- Fr = u’/sqrt(L*magnitude(g))
• The Reynolds number represents the
relative magnitude of the inertial and
viscous forces
• The Froude number relates the velocity of
object to velocity of fluid waves.
17
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Let us now see
how to solve the
Navier Stokes
equations…
18
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Discretization
• Refers to passing from a continuous problem to
one considered at only a finite number of points.
• Reduces differential equations to a system of
algebraic equations.
• The solution is found only at a finite number of
points in the domain.
19
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Discretization
• Forward difference
- Derivative at grid point i = ((function value at i+1) –
(function value at i)) / (grid spacing)
• Backward difference
- Derivative at grid point i = ((function value at i) – (function
value at i-1)) / (grid spacing)
• Central difference
- Derivative at grid point i = ((function value at i+1) –
(function value at i-1)) / (2*grid spacing)
20
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Pros and Cons
• With forward and backward differencing, the order
of approximation is first order. With central
differencing, it is second order.
• For convection-diffusion problems, stability
problems occur with central differencing when the
grid spacing is too coarse. Maintaining stability
hence requires restricting the grid spacing to be
very small.
• A possible compromise is to use a weighted
average of both discretizations :
- μ*forward difference + (1- μ)*backward difference
21
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Solving the equations
Basic Approach
1. Create a tentative velocity field.
a. Finite differences
b. Semi-Lagrangian method (Stable Fluids
[Stam 1999])
2. Ensure that the velocity field is
divergence free:
a. Adjust pressure and update velocities
b. Projection method
22
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Staggered Grid
pi , j 1
vi , j  1
2
ui  1 , j
pi 1, j
2
ui  1 , j
2
pi , j
vi , j  1
2
pi , j 1
pi 1, j
The staggered grid provides velocities
immediately at cell boundaries, is
convenient for finite differences,
and avoids oscillations.
Consider problem of a 2D fluid at rest
with no external forces. The
continuous solution is:
u0
v0
p  constant
On a discretized non-staggered grid
you can have:
ui , j  0
vi , j  0
pi , j  P1 for i  j even,P2 for i  j odd
23
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
The algorithm
• Perform time discretization of
momentum equations. Discretize in a
manner explicit in the velocities and
implicit in the pressure.
• Evaluate continuity equation at time
t(n) + 1, to yield a poisson equation
for pressure. Solve for the pressure.
• Use the pressure values to compute
new velocities.
24
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Solving for pressure
  ( n1) ~ ( n )
du u
u
1

  p ( n1)
dt
t

Discretize in time
 ( n1) ~ ( n ) t
u
 u  p ( n1)
Rearrange terms


t
  u ( n1)    u~ ( n )   2 p ( n 1)  0

25
Satisfy continuity eq.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Solving for pressure
We end up with the Poisson equation for pressure.
 p
2
( n 1)


t
  u~ ( n )
This is another sparse linear system. These types of
equations can be solved using iterative methods.
Use pressures to update final velocities.
 ( n1) ~ ( n ) t
u
 u  p ( n1)

26
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
No-slip condition
• The velocities vanish at the
boundaries to satisfy the no-slip
condition.
u0,j = 0,
vi,o = 0,
ui-max,j = 0,
vi,j-max = 0
27
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Free Slip Condition
• The velocity component normal to the
boundary should vanish along with
the derivative of the velocity
component tangent to the boundary.
u0,j = 0, vi,o = 0,
ui-max,j = 0, vi,j-max = 0,
v0,j = v1,j , vi-max + 1,j = vi-max ,j ,
ui,0 = ui,1 , ui,j-max+1 = ui,j-max
28
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Outflow Condition
• The normal derivatives of both
velocity components are set to zero at
the boundary
u0,j = u1,j , ui-max,j = ui-max -1 ,j ,
vi-max+1,j= vi-max,j, v0,j = v1,j,
ui,0 = ui,1 , ui,j-max+1 = ui,j-max
vi,0 = v1,j , vi,j-max = vi,j-max-1 ,
29
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Inflow Conditions
• The velocities are explicitly given
• We impose this for velocities normal
to the boundary by directly fixing the
values on the boundary line
• For the velocity components
tangential to the boundary, we
achieve this by averaging the values
on either side of the boundary.
30
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Periodic boundary conditions
• For periodic boundary conditions
in the x-direction, the boundary
values on the left and the right
boundaries coincide.
u0,j = ui-max-1,j , ui-max,j = u1,j
v0,j = vi-max-1,j , vi-max,j = v1,j
31
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Stability condition
Limits on time step
• CFL conditions – don’t move more
than a single cell in one time step
umax t  x,
vmax t  y
• Diffusion term
 1
1 
2t   2  2 
y 
 x
32
1
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Satisfying the Continuity Eq.
The tentative velocity field is not necessarily
divergence free and thus does not satisfy
the continuity equation.
Three methods for satisfying the continuity
equation:
1.
2.
3.
33
Explicitly satisfy the continuity equation by iteratively
adjusting the pressures and velocities in each cell.
Find a pressure correction term that will make the
velocity field divergence free.
Project the velocities onto their divergence free part.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Explicitly Enforcing u=0
Since we have not yet added the pressure term, we can
use pressure to ensure that the velocities are
divergence free.
u>0 increased pressure and subsequent outflux
u<0 decreased pressure and subsequent influx
Relaxation algorithm
1. Correct the pressure in a cell
2. Update velocities
3. Repeat for all cells until each has u<ε
34
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Let’s move on
to some
applications
now…
35
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Lid Driven Cavity Flow
• We simulate a driven cavity flow in a
square domain.
• The physical configuration consists of
a square container filled with a fluid.
• The lid of the container moves at a
given, constant velocity, thereby
setting the fluid in motion.
36
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Boundary Conditions
• No slip conditions on all four
segments of the boundary, except the
upper boundary.
• Vertical velocity at the upper
boundary is zero.
• The horizontal velocity is set equal to
the given lid velocity.
37
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Lid Driven Cavity Flow
• Demo time :
http://www.math.ubordeaux.fr/Math_Appli/Fenetre
2/videotheque/DNS/Welcome.ht
ml
38
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Smoke (Fedkiw, Stam, Jensen
1999)
• Uses Euler equations instead of
the Navier Stokes equations
since
- These are more appropriate for gas
models
- Are less computationally expensive
• Uses “vorticity confinement” to
reduce numerical dissipation
39
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Euler Equations
• Incompressible Euler Equations
• Solve the equation in two steps
- Compute intermediate velocity without
the pressure term
- Forve the velocity field to be
incompressible
40
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Euler Equations
• Solve the second equation over a
timestep, ignoring the pressure term :
• Compute the pressure from the following
poisson equation
41
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Euler equations
• The intermediate velocity is then
made incompressible by subtracting
the gradient of the pressure from it.
• The temperature and density of the
smoke are then calculated by simply
advecting along the velocity field.
42
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Vorticity Confinement
• Smoke usually consists of velocity
field having a significant amount of
rotational and turbulence
components.
• Numerical dissipation damps out
these phenomena, and so they are
added back by a technique called
vorticity confinement
43
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Vorticity Confinement
• Vorticity is the
curl of the
velocity field.
• First, calculate
normalized
vorticity location
vectors.
• Then add
vorticity terms at
these locations.
44
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Some Videos…
45
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL