Fluid dynamics
Fields • Domain Ω ⊆ R 2 • Scalar field f : Ω → R • Vector field f : Ω → R 2
Types of derivatives • Derivatives measure how something changes due to its parameters ∂ f • Temporal derivatives ∂ t • Spatial derivatives � T � ∂ f ∂ x, ∂ f • gradient operator ∇ f = ∂ y ∇ · f = ∂ f x ∂ x + ∂ f y • divergence operator ∂ y ∇ 2 f = ∇ · ( ∇ f ) = ∂ 2 f ∂ x + ∂ 2 f • Laplacian operator ∂ y
Spatial derivatives • Gradient: a vector pointing at the steepest uphill of the function • Divergence: measures the net flux • Laplacian: measures the difference from the average of neighbors
Quiz • What is the laplacian of f(x, y) = 2xy + y 2 ? • (2y, 2x+2y) • 2 • x + 2y • 4
Quiz What’s the gradient at ( π 3 , − π 4 ) ? What about Laplacian?
Representation Density ρ : Ω → [0 , 1] Domain Ω Velocity u : Ω → R 3
Navier-Stoke equations Momentum ∂ t = − ( u · ∇ ) u − 1 ∂ u ρ ∇ p + s ∇ 2 u + f equation Mass equation u : velocity ∇ · u = 0 (Incompressibility p : pressure condition) s : kinematic viscosity f : body force ρ : fluid density
Momentum equation • Each particle represents a little blob of fluid with mass m , a volume V , and a velocity u • The acceleration of the particle a ≡ D u Dt • The Newton’s law mD u Dt = F
Forces acting on fluids • Gravity: m g • Pressure: - ∇ p • Imbalance of higher pressure • Viscosity: µ ∇ · ∇ u • Force that makes particle moves at average speed • dynamic viscosity coefficient: µ
Momentum equation The movement of a blob of fluid mD u Dt = m g − V ∇ p + V µ ∇ · ∇ u Divide by volume ρ D u Dt = ρ g − ∇ p + µ ∇ · ∇ u Rearrange equation giving Navier-Stoke D u Dt + 1 ρ ∇ p = g + s ∇ · ∇ u
Quiz • If we want to add an additional force F to the entire domain of the fluid, how does that change the momentum equation? D u Dt + 1 ρ ∇ p = g + s ∇ · ∇ u
Lagrangian v.s. Eulerian • Lagrangian point of view describes motion as points travel around space over time • Eulerian point of view describes motion as the change of velocity field in a stationary domain • Lagrangian approach is conceptually easier, but Eulerian approach makes the spatial derivatives easier to compute/approximate
Material derivative Dq Dt = ∂ q ∂ t + u ∂ q ∂ x + v ∂ q ∂ y + w ∂ q ∂ z dtq ( t, x ) = ∂ q d ∂ t + ∇ q · d x dt = ∂ q ∂ t + ∇ q · u = Dq Dt
Advection • Advection describe how quantity, q , moves with the velocity field u • Density D ρ Dt = ∂ρ ∂ t + u · ∇ ρ • Velocity Dt = ∂ u D u ∂ t + u · ∇ u
Advection momentum D u Dt + 1 ρ ∇ p = g + s ∇ · ∇ u equation Advection Projection Diffusion Body force ∂ t = − ( u · ∇ ) u − 1 ∂ u ρ ∇ p + s ∇ 2 u + f
Density advection compute derivative of density field: ∂ρ ∂ t = − ( u · ∇ ) ρ integrate density field using ∂ρ ∂ t
Velocity advection compute derivative of velocity field: ∂ u ∂ t = � ( u · r ) u integrate velocity field using ∂ u ∂ t compute derivative of density field: ∂ρ ∂ t = − ( u · ∇ ) ρ integrate density field
Projection Advection Projection Diffusion Body force ∂ t = − ( u · ∇ ) u − 1 ∂ u ρ ∇ p + s ∇ 2 u + f ∇ · u = 0
Divergence free ∇ · u > 0? ∇ · u < 0?
Divergence free ∇ ∙ u = 0 ∇ ∙ u ≠ 0
Projection ∂ t = − ( u · ∇ ) u − 1 ∂ u ρ ∇ p + s ∇ 2 u + f s.t. ∇ · u = 0
Diffusion Advection Projection Diffusion Body force ∂ t = − ( u · ∇ ) u − 1 ∂ u ρ ∇ p + s ∇ 2 u + f ∇ · u = 0
High viscosity fluids
Dropping viscosity • Viscosity plays a minor role in most fluids • Numeric methods introduce errors which can be physically reinterpreted as viscosity • Fluid with no viscosity is called “inviscid”
Body force Advection Projection Diffusion Body force ∂ t = − ( u · ∇ ) u − 1 ∂ u ρ ∇ p + s ∇ 2 u + f ∇ · u = 0
External forces • Gravity • Heat • Surface tension • User-specified forces (stirring coffee)
Boundary conditions • Solid walls • The fluid cannot go in and out of it • Control the normal velocity • Free surfaces • Air can be represented as a region where the pressure is zero • Do not control the velocity at the surface
Solid boundary • Velocity at the boundary u · ˆ n = u solid · ˆ n • No-slip condition: u = u solid • Pressure at the boundary • Make the fluid incompressible AND enforce the solid boundary condition
Physics recap • Physical quantity represented as fields • Navier-Stokes PDE describes the dynamics
Practical challenges • What is the representation for fluids? • use grid structures to represent velocity, pressure, and other quantities of interest • What is the equation of motion for fluids? • approximate Navier-Stokes in a discrete domain • compute Navier-Stokes efficiently
Simple grid structure ( i , j+1 ) p i,j ( i-1 , j ) ( i , j ) ( i+1 , j ) u i,j ( i , j-1 )
Velocity field vector field: u scalar field: u u i,j u i,j scalar field: v v i,j u i,j = ( u i,j , v i,j )
Computing divergence r · u i,j = u i,j +1 � u i,j − 1 + v i +1 ,j � v i − 1 ,j 2 ∆ x cell width: ∆ x v i +1 ,j horizontal vertical scalar field u i,j scalar field u i,j − 1 u i,j +1 v i,j v i − 1 ,j
Derivative evaluation • Evaluating derivatives using scalar fields ∂ t = − ( u · ∇ ) u − 1 ∂ u ρ ∇ p + s ∇ 2 u + f ∂ t = � ( u · r ) u � 1 ∂ u ρ ( r p ) x + s r 2 u + f x ∂ t = � ( u · r ) v � 1 ∂ v ρ ( r p ) y + s r 2 v + f y
MAC grid structure p i,j +1 v i,j +1 / 2 p i +1 ,j p i − 1 ,j p i,j u i − 1 / 2 ,j u i +1 / 2 ,j v i,j − 1 / 2 p i,j − 1
Quiz How do you compute the divergence at u i,j using MAC grid? v i,j +1 / 2 u i − 1 / 2 ,j u i +1 / 2 ,j v i,j − 1 / 2
Explicit integration • Solving for the differential equation explicitly, namely ∂ t = − ( u · ∇ ) u − 1 ∂ u ρ ∇ p + s ∇ 2 u + f u t +1 = u t + h ˙ u ( t ) • You get this...
Explicit integration
Stable fluids Invented by Jos Stam Simple, fast, and unconditionally stable
Splitting methods • Suppose we had a system ∂ x ∂ t = f ( x ) = g ( x ) + h ( x ) • We define simulation function S f S f ( x, ∆ t ) : x ( t ) → x ( t ) + ∆ tf ( x ) • Then we could define S f ( x, ∆ t ) : x ( t + ∆ t ) = S g ( x, ∆ t ) ◦ S h ( x, ∆ t )
Splitting methods ∂ t = − ( u · ∇ ) u − 1 ∂ u ρ ∇ p + s ∇ 2 u + f w 0 = u ( x , t ) add force Advect Diffuse Project w 0 ( x ) w 1 ( x ) w 2 ( x ) w 3 ( x ) w 4 ( x ) u ( x , t + Δ t ) = w 4
Splitting methods ∂ t = − ( u · ∇ ) u − 1 ∂ u ρ ∇ p + s ∇ 2 u + f w 0 = u ( x , t ) add force Advect Diffuse Project w 0 ( x ) w 1 ( x ) w 2 ( x ) w 3 ( x ) w 4 ( x ) u ( x , t + Δ t ) = w 4
Body forces
Splitting methods ∂ t = − ( u · ∇ ) u − 1 ∂ u ρ ∇ p + s ∇ 2 u + f w 0 = u ( x , t ) add force Advect Diffuse Project w 0 ( x ) w 1 ( x ) w 2 ( x ) w 3 ( x ) w 4 ( x ) u ( x , t + Δ t ) = w 4
Semi-Lagrangian Advection
Numerical dissipation • Semi-Lagrangian advection tend to smooth out sharp features by averaging the velocity field • The numerical errors result in a different advection equation solved by semi-Largrangian ∂ x = u ∆ x ∂ 2 q ∂ q ∂ t + u ∂ q ∂ x 2 • Smooth out small vortices in inviscid fluids
Splitting methods ∂ t = − ( u · ∇ ) u − 1 ∂ u ρ ∇ p + s ∇ 2 u + f w 0 = u ( x , t ) add force Advect Diffuse Project w 0 ( x ) w 1 ( x ) w 2 ( x ) w 3 ( x ) w 4 ( x ) u ( x , t + Δ t ) = w 4
Diffusion • Solve for the effect of viscosity ∂ w 2 = ν ∇ 2 w 2 ∂ t • Use an implicit method for stable result ( I − ν ∆ t ∇ 2 ) w 3 ( x ) = w 2 ( x )
Splitting methods ∂ t = − ( u · ∇ ) u − 1 ∂ u ρ ∇ p + s ∇ 2 u + f w 0 = u ( x , t ) add force Advect Diffuse Project w 0 ( x ) w 1 ( x ) w 2 ( x ) w 3 ( x ) w 4 ( x ) u ( x , t + Δ t ) = w 4
Projection P( )
Projection • Projection step subtracts off the pressure from the intermediate velocity field w 3 w 4 = w 3 − ∆ t 1 ρ ∇ p • project ( ∆ t, u ) must satisfies two conditions: ∇ · u t +1 = 0 • divergence free: • boundary velocity: u t +1 · ˆ n = u solid · ˆ n
Divergence-free condition u t +1 − u t +1 + v t +1 − v t +1 p i,j +1 2 1 2 1 = 0 ∆ x ∆ x v 2 w 4 = w 3 − ∆ t 1 Replace (from ) u t +1 p i +1 ,j p i − 1 ,j p i,j ρ ∇ p 2 u 1 u 2 u 2 − ∆ t p i +1 ,j − p i,j with v 1 ∆ x ρ Interpolating u 2 = u i +1 ,j + u i,j p i,j − 1 2 − ∆ t = u i +1 ,j + u i,j p i +1 ,j − p i,j resulting in u t +1 2 ∆ x 2 ρ
Recommend
More recommend