+ All Categories
Home > Documents > Solving the Navier-Stokes Methods for the Navier-Stokes Equations...

Solving the Navier-Stokes Methods for the Navier-Stokes Equations...

Date post: 18-Jun-2020
Category:
Upload: others
View: 5 times
Download: 1 times
Share this document with a friend
9
Computational Fluid Dynamics Solving the Navier-Stokes Equations in Primitive Variables Grétar Tryggvason Spring 2011 http://www.nd.edu/~gtryggva/CFD-Course/ Computational Fluid Dynamics The projection method—review Methods for the Navier-Stokes Equations Moin and Kim Bell, et al Colocated grids Boundary conditions Outline Computational Fluid Dynamics ! h " u i , j n +1 = 0 Discretization in time u i, j n +1 ! u i , j n "t = !A i, j n !# h P i, j + D i, j n Summary of discrete vector equations No explicit equation for the pressure! Evolution of the velocity Constraint on velocity Computational Fluid Dynamics u i , j n +1 ! u i , j t "t = !# h P i , j $ u i , j n +1 = u i, j t !"t # h P i, j u i , j t ! u i, j n "t = ! A i, j n + D i, j n # u i, j t = u i, j n + "t !A i, j n + D i, j n ( ) u i, j n +1 ! u i , j n "t = !A i, j n !# h P i, j + D i, j n Split by introducing the temporary velocity u t into and Projection Method Discretization in time Computational Fluid Dynamics u i, j n + 1 = u i , j t !"t # h P i, j ! h " u i , j n +1 = 0 ! h " u i , j n +1 = ! h " u i, j t #$t ! h "! h P i, j 0 To derive an equation for the pressure we take the divergence of and use the mass conservation equation ! h 2 P i, j = 1 "t ! h # u i, j t The result is Discretization in time Computational Fluid Dynamics u i , j n +1 = u i , j t !"t # h P i, j u i , j t = u i, j n + !t "A i , j n + D i, j n ( ) ! h 2 P i, j = 1 "t ! h # u i, j t 1. Find a temporary velocity using the advection and the diffusion terms only: 2. Find the pressure needed to make the velocity field incompressible 3. Correct the velocity by adding the pressure gradient: Discretization in time
Transcript
Page 1: Solving the Navier-Stokes Methods for the Navier-Stokes Equations ...gtryggva/CFD-Course/2011-Lecture-22.pdf · Methods for the Navier-Stokes Equations!!Moin and Kim!!Bell, et al

Computational Fluid Dynamics

Solving the Navier-Stokes!Equations in Primitive

Variables!

Grétar Tryggvason !Spring 2011!

http://www.nd.edu/~gtryggva/CFD-Course/!Computational Fluid Dynamics

The projection method—review!Methods for the Navier-Stokes Equations!

!Moin and Kim!!Bell, et al !!

Colocated grids!Boundary conditions!

Outline!

Computational Fluid Dynamics

!h "ui , jn +1 = 0

Discretization in time!

ui, jn +1 ! ui, j

n

"t= !A i, j

n ! #hPi, j +Di, jn

Summary of discrete vector equations !

No explicit equation for the pressure! !

Evolution of the velocity!

Constraint on velocity!

Computational Fluid Dynamics

ui , jn +1 ! ui , j

t

"t= !#hPi , j $ ui , j

n +1 = ui, jt ! "t #hPi, j

ui , jt ! ui, j

n

"t= !Ai, j

n +Di, jn # ui, j

t = ui, jn + "t !Ai, j

n + Di, jn( )

ui, jn +1 ! ui, j

n

"t= !A i, j

n ! #hPi, j +Di, jn

Split !

by introducing the temporary velocity ut!

into!

and!

Projection Method!

Discretization in time!

Computational Fluid Dynamics

ui, jn +1 = ui, j

t ! "t # hPi, j

!h "ui , jn +1 = 0

!h "ui , jn +1 =!h "ui, j

t # $t !h "!hPi, j0!

To derive an equation for the pressure we take the divergence of!

and use the mass conservation equation!

!h2Pi, j =

1"t

!h #ui, jt

The result is!

Discretization in time!Computational Fluid Dynamics

ui , jn +1 = ui , j

t ! "t #hPi, j

ui , jt = ui, j

n + !t "Ai , jn +Di, j

n( )

!h2Pi, j =

1"t

!h #ui, jt

1. Find a temporary velocity using the advection and the diffusion terms only:!

2. Find the pressure needed to make the velocity field incompressible!

3. Correct the velocity by adding the pressure gradient:!

Discretization in time!

Page 2: Solving the Navier-Stokes Methods for the Navier-Stokes Equations ...gtryggva/CFD-Course/2011-Lecture-22.pdf · Methods for the Navier-Stokes Equations!!Moin and Kim!!Bell, et al

Computational Fluid Dynamics Algorithm!

Determine u, v boundary conditions!

Poisson equation for (iteration)!

Initial field given!

t=t+Δt!

Projection!

( )nji

nji

nji

tji t ,,,, DAuu +!"+=

jiP ,

ui , jn +1 = ui , j

t ! "t #hPi, j

Advect!

Computational Fluid Dynamics

Forward in time, centered in space (summary):!

u* !u n

"t= !A u n( ) + #$2u n

$2p = 1"t

$ %u*

u n+1 = u* !"t$p

!t " 2#U 2 & !t " 1

4h2

#

U 2 =max(u2 + v 2)

Time step limitations!

where!

Computational Fluid Dynamics

Forward in time, centered in space:!

!tadv "2#U 2 & !tdiff "

14h2

#

! = LU

!t '= !t"

# 2$U 2

UL

= 2Re

!t '= !t"

# 14h2

$UL

= 14

hL

% & '

( ) * 2

Re

Define!

Therefore the nondimensional time step is:!

And Δt 0 for Re 0 and Re ∞!

and!

Computational Fluid Dynamics

Forward in time, centered in space:!

!t '= 2Re

!t '= 14hL

" # $

% & ' 2

Re

What is the maximum timestep?!

Δt 0 for Re 0 and Re ∞!

and!

Increasing h!

h 0! Re!

Δt’!

!t 'max = 12hL

Re!t ' max = 8 Lh

Computational Fluid Dynamics

Advanced Solvers!

For low Re, use implicit methods for diffusion term!For high Re, use stable advection schemes!!Combine both for schemes intended for all Re !

Computational Fluid Dynamics

Fully Implicit!

un +1 ! un

"t=12

! A (un ) +A(un +1)( ) +# $h2un + $ h

2un+1( )[ ] !$p$ %un+1 = 0

Solve by iteration!

Rarely used due to the complications of the nonlinear system that must be solved for the advection terms!

Page 3: Solving the Navier-Stokes Methods for the Navier-Stokes Equations ...gtryggva/CFD-Course/2011-Lecture-22.pdf · Methods for the Navier-Stokes Equations!!Moin and Kim!!Bell, et al

Computational Fluid Dynamics

Predictor-Corrector!

u* !u n

"t= !#u nu n + $#2u n

#2p* = 1"t

# %u*

u1 = u* !"t#p*

u ** ! u1

"t= !#u1u1+$#2u1

#2p** = 1"t

#%u **

u 2 = u ** ! "t#p**

u n+1 = 12u n + u 2( )

Then average the results!

Backward step using the predicted velocity:!

A second order method can be developed by first taking a forward step, then a backward step and average the results:!

Computational Fluid Dynamics

Adam-Bashford/Crank-Nicolson!

un +1 ! un

"t= !

32A(un ) ! 1

2A(un!1)#

$ % & +

'2

(h2un + ( h

2un+1( ) !(p( )un+1 = 0

˜ u !un

"t= ! 3

2A (un ) ! 1

2A (un!1)#

$ % & +

'2( h

2un

un +1 - ˜ u "t

= !(p +'2( h

2un+1

( )un+1 = 0

! h2p =

1"t

! # ˜ u

Split:!

The correction equation is implicit and must be solved by an iteration in the same way as the pressure equation!

Computational Fluid Dynamics

Method of Kim and Moin (JCP 59 (1985), 8-23)!

˜ u !un

"t= ! 3

2A (un ) ! 1

2A (un!1)#

$ % & +

'2

( h2un + (h

2 ˜ u ( )un +1 ! ˜ u

"t= !()

( *un+1 = 0

! h2" =

1#t

!$ ˜ u

The first equation is implicit and must be solved by an iteration in the same way as the pressure equation!

Computational Fluid Dynamics

un +1 ! un

"t= !

32

A(un ) ! 12

A(un!1)# $

% & +

'2

(h2un + ( h

2un+1( ) +'2

(h2 ˜ u !( h

2un+1( ) !()

!2"h

2 ˜ u #" h2un+1( ) #"$ =

!2" h

2$ #"$ = "p

Where we have added and subtracted an implicit diffusion term.!

un +1 ! ˜ u "t

= !#$

we can rewrite the last terms as:!

!p

Using!

Notice that Φ is not exactly p. Adding the first two equations gives!

Computational Fluid Dynamics

Method of Bell, Colella and Glaz (JCP 85 (1989), 7-83)!

un +1 ! un

"t= !A (un+1/ 2) +

#2

$ h2un + $h

2un +1( ) ! $p$ %un+1 = 0

A Godunov method is used for the advection terms!

Computational Fluid Dynamics

u * ! u n

12 "t

= !#u nu n +$#2u n

#2p* = 2"t

#%u *

u1 = u * ! "t2#p*

u ** ! u n

12 "t

= !#u1u1+$#2u1

#2p** = 2"t

#%u **

u 2 = u ** ! "t2#p**

continue for the second step:!

First a half step:!A complete Runge-Kutta time integration (Weinan E.) !

Page 4: Solving the Navier-Stokes Methods for the Navier-Stokes Equations ...gtryggva/CFD-Course/2011-Lecture-22.pdf · Methods for the Navier-Stokes Equations!!Moin and Kim!!Bell, et al

Computational Fluid Dynamics

u *** ! u n

"t= !#u 2u 2 +$#2u 2

#2p*** = 1"t

#%u ***

u 3 = u *** ! "t#p***

k = !t "#u 3u 3 +$#2u 3( )

u+ = 13 !u n + u1+ 2u 2 + u 3( ) + 1

6 k

"2p+ = 1#t

"$u+

u n+1 = u+ ! #t"p+

And finally!

Then compute !

Take a full step using the predicted velocity!

A complete Runge-Kutta time integration (continued) !

Computational Fluid Dynamics

u * ! u n

12 "t

= !#u nu n +$#2u n

u ** ! u *12 "t

= !#u *u * +$#2u *

u *** ! u n

"t= !#u *u * +$#2u *

u+ = 13 !u n + u * + 2u ** + u ***( ) + "t

6!#u ***u *** +$#2u ***( )

#2p+ = 1"t

#%u+

u n+1 = u+ ! "t#p+

Simplified Fourth order method!

Computational Fluid Dynamics

Colocated grids!

Computational Fluid Dynamics

Colocated grids!Although staggered grids have been very successful, in some cases it is desirable to use co-located (or colocated) grids where all variables are located at the same physical point. !

Computational Fluid Dynamics

vi,j+1/2!

Pi,j!ui-1/2,j! ui+1/2,j!

vn!

uw! ue!

vs!vi,j-1/2!

Pi,j,ui,j,vi,j!

Colocated grids!Staggered grids!

All variables are stored at the same location!

Computational Fluid Dynamics

First idea: use averaging for the variables on the edges:!

ui, j* = ui, j ! "tA(ui, j

n )

ui, jn+1 = ui, j

* ! "th(pe ! pw )

uen+1 ! uw

n+1 + vnn+1 ! vs

n+1 = 0

pe =12pi+1, j + pi, j( )

ui, jn+1 = ui, j

* ! "th12pi+1, j + pi, j( ) ! 12 pi, j + pi!1, j( )#

$ %

& ' (

ue =12ui+1, j + ui, j( )

ui, jn+1 = ui, j

* ! "t2h

pi+1, j ! pi!1, j( )

Split equations for the u velocity!

Page 5: Solving the Navier-Stokes Methods for the Navier-Stokes Equations ...gtryggva/CFD-Course/2011-Lecture-22.pdf · Methods for the Navier-Stokes Equations!!Moin and Kim!!Bell, et al

Computational Fluid Dynamics

Substituting!

ui, jn +1 = ui, j

* !"t2h

pi+1, j ! pi, j!1( )into!

uen +1 ! uw

n+1 + vnn +1 ! vs

n +1 = 0

yields!

pi+2, j + pi! 2, j + pi, j+2 + pi, j! 2 ! 4 pi, j =2h"t

ui+1, j* ! ui!1, j

* + vi, j+1* !vi, j!1

*( )

ue =12ui+1, j + ui, j( ) and!

Computational Fluid Dynamics

The pressure points are also uncoupled and the pressure field can develop oscillations!

A straight forward application discretization on colocated grids results in a very wide stencil for the pressure!

Computational Fluid Dynamics

The remedy is to find the pressures that make the edge velocities incompressible!

Rhie and Chow. AIAA Journal. 21 (1983), 1525-1532.!

Computational Fluid Dynamics

vn!

uw! ue!

vs!

Pi,j,ui,j,vi,j!

Instead of interpolating (the final velocity)!

uen +1 = ue

* !"th

pi+1, j ! pi, j( )

ue* =12ui+1, j* + ui, j

*( )

uen +1 =

12ui+1, jn +1 + ui, j

n+1( )

interpolate (the intermediate velocity)!

and then find!

In effect, “pretend” we are using a staggered grid!!

The Rhie and Chow method!

Computational Fluid Dynamics

uen +1 = ue

* !"th

pi+1, j ! pi, j( )

uen +1 ! uw

n+1 + vnn +1 ! vs

n +1 = 0

ue* =12ui+1, j* + ui, j

*( )

ue* !"th

pi+1, j ! pi, j( )# $

% & ! uw* !

"th

pi, j ! pi!1, j( )# $

% &

+ vn* !"th

pi, j+1 ! pi, j( )# $

% & ! vs* !

"th

pi, j ! pi, j!1( )# $

% & = 0

pi+1, j + pi!1, j + pi, j+1 + pi, j!1 ! 4 pi, j =h"t

ue* ! uw

* + vn* ! vs

*( )Rearrange:!

Substitute!

where!into!

giving!

Computational Fluid Dynamics

Substituting for the velocities:!

pi+1, j + pi!1, j + pi, j+1 + pi, j!1 ! 4 pi, j =h2"t

ui+1, j* ! ui!1, j

* + vi, j+1* !vi, j!1

*( )

ui, jn +1 = ui, j

* !"t2h

pi+1, j ! pi!1, j( )

pe =12pi+1, j + pi, j( )

For the correction of the momentum equation we still use the average of the pressures!

giving!

Page 6: Solving the Navier-Stokes Methods for the Navier-Stokes Equations ...gtryggva/CFD-Course/2011-Lecture-22.pdf · Methods for the Navier-Stokes Equations!!Moin and Kim!!Bell, et al

Computational Fluid Dynamics

The boundary conditions for the velocity are now very simple: The velocity at nodes on the wall is simply the wall velocity.!!The pressure boundary is more complex:!

Computational Fluid Dynamics

Find the pressure gradient by applying the Navier-Stokes equations at a point at the boundary!

!"v"t

+ u"v"x

+ v"v"y

# $ % &

' = (

"p"y

+ µ" 2v"x 2

+" 2v"y2

# $ % &

' )

At the wall, most of the terms are zero!

!p!y

= µ! 2v!y 2

pi,2 ! pi,1h

= µ" 2v"y 2

# $ % i,1

Evaluated by one-sided differences!

i,1

i,2

pi,2 ! pi,1h

= µ vi,1n ! 2vi,2

n + vi,3n

h2

Computational Fluid Dynamics

Define:!

We can write:!

i,1

i,2

pi,2 ! pi,1h

= µ vi,1n ! 2vi,2

n + vi,3n

h2

pi,2 ! pi,1 = h"tvi,1*

vi,1* = !t

hpi,2 " pi,1( ) = µ!t

h2vi,1n " 2vi,2

n + vi,3n( )

Computational Fluid Dynamics

Write the pressure equation for j=2!

pi,2 ! pi,1 =h"tvi,1*

pi+1,2 + pi!1,2 + pi,3 + pi,1 ! 4 pi,2 =h2"t

ui+1,2* ! ui!1,2

* + vi,3* !vi,1

*( )

And use!

For the pressure at j=1!

Computational Fluid Dynamics

The algorithm is therefore:!

1. First find predicted velocities:!

ui, j* = ui, j ! "tA(un )

2. Find pressure by solving:!

pi+1, j + pi!1, j + pi, j+1 + pi, j!1 ! 4 pi, j =h2"t

ui+1, j* ! ui!1, j

* + vi, j+1* !vi, j!1

*( )

3. Correct the velocities:!

and!

ui, jn +1 = ui, j

* !"t2h

pi+1, j ! pi!1, j( ) and!

suitably modified at the boundaries!

vi, j* = vi, j ! "tA(vn )

vi, jn+1 = vi, j

* !"t2h

pi, j+1 ! pi. j!1( )

Computational Fluid Dynamics

% projection method in primitive variables on a colocated mesh nx=19;ny=19;dt=0.0025;nstep=300;mu=0.1;maxit=100;beta=1.2;h=1/nx; time=0; u=zeros(nx,ny);v=zeros(nx,ny);p=zeros(nx,ny); ut=zeros(nx,ny);vt=zeros(nx,ny); u(2:nx-1,ny)=1.0; for is=1:nstep for i=2:nx-1,for j=2:ny-1 ut(i,j)=u(i,j)+dt*(-(0.5/h)*(u(i,j)*(u(i+1,j)-u(i-1,j))+v(i,j)*(u(i,j+1)-u(i,j-1)))+(mu/h^2)*(u(i+1,j)+u(i-1,j)+u(i,j+1)+u(i,j-1)-4*u(i,j))); vt(i,j)=v(i,j)+dt*(-(0.5/h)*(u(i,j)*(v(i+1,j)-v(i-1,j))+v(i,j)*(v(i,j+1)-v(i,j-1)))+ (mu/h^2)*(v(i+1,j)+v(i-1,j)+v(i,j+1)+v(i,j-1)-4*v(i,j))); end,end vt(2:nx-1,1)=(mu*dt/h^2)*(v(2:nx-1,3)-2*v(2:nx-1,2)); vt(2:nx-1,ny)=(mu*dt/h^2)*(v(2:nx-1,ny-2)-2*v(2:nx-1,ny-1)); ut(1,2:ny-1)=(mu*dt/h^2)*(u(3,2:ny-1)-2*u(2,2:ny-1)); ut(nx,2:ny-1)=(mu*dt/h^2)*(u(nx-2,2:ny-1)-2*u(nx-1,2:ny-1)); for it=1:maxit % solving for pressure p(2:nx-1,1)=p(2:nx-1,2)+(h/dt)*vt(2:nx-1,1); p(2:nx-1,ny)=p(2:nx-1,ny-1)-(h/dt)*vt(2:nx-1,ny); p(1,2:ny-1)=p(2,2:ny-1)+(h/dt)*ut(1,2:ny-1); p(nx,2:ny-1)=p(nx-1,2:ny-1)-(h/dt)*ut(nx,2:ny-1); for i=2:nx-1,for j=2:ny-1 p(i,j)=beta*0.25*(p(i+1,j)+p(i-1,j)+p(i,j+1)+p(i,j-1)- (0.5*h/dt)*(ut(i+1,j)-ut(i-1,j)+vt(i,j+1)-vt(i,j-1)))+(1-beta)*p(i,j); end,end

p(floor(nx/2),floor(ny/2))=0.0; % set the pressure in the center. Needed since bc is not incorporated into eq end u(2:nx-1,2:ny-1)=ut(2:nx-1,2:ny-1)-(0.5*dt/h)*(p(3:nx,2:ny-1)-p(1:nx-2,2:ny-1)); v(2:nx-1,2:ny-1)=vt(2:nx-1,2:ny-1)-(0.5*dt/h)*(p(2:nx-1,3:ny)-p(2:nx-1,1:ny-2)); time=time+dt hold off,quiver(flipud(rot90(u)),flipud(rot90(v)),'r'); hold on;axis([1 nx 1 ny]);axis square,pause(0.01) end plot(10*u(floor(ny/2),1:nx)+floor(nx/2),1:nx),hold on; plot([1,nx],[floor(ny/2),floor(ny/2)]),plot([floor(nx/2),floor(nx/2)],[1,ny]) plot(10*v(1:nx,floor(ny/2))+floor(ny/2));axis square,axis([1,nx, 1,ny])

Page 7: Solving the Navier-Stokes Methods for the Navier-Stokes Equations ...gtryggva/CFD-Course/2011-Lecture-22.pdf · Methods for the Navier-Stokes Equations!!Moin and Kim!!Bell, et al

Computational Fluid Dynamics

Colocated grids!

2 4 6 8 10 12 14 16 18

2

4

6

8

10

12

14

16

18

Computational Fluid Dynamics

Why colocated grids:!!Sometimes simpler for body fitted grids!!Easy to use methods for hyperbolic equations!!Easier to implement AMR!!Some people just don’t like staggered grids!!

Computational Fluid Dynamics

Boundary conditions!Inflow and outflow!

Computational Fluid Dynamics

Boundary conditions!

Fully enclosed flow!!Driven cavity!

!Internal flow (inflow & outflow)!!External flow!

!Flow over bodies!

Computational Fluid Dynamics

For fully enclosed domains, such as in the driven cavity problem, the application of the boundary conditions is relatively straight forward.!

For domains with inflows it is usually reasonable to specify the velocity profile at the inlet!

The major problem is how to handle outflow boundaries in such a way that the fluid leaves in a “physically plausible” way!

Computational Fluid Dynamics

The Backward Facing Step Problem!

Velocity given!

u = u(y)v = 0

!u!x

= 0

!v!x

= 0

Page 8: Solving the Navier-Stokes Methods for the Navier-Stokes Equations ...gtryggva/CFD-Course/2011-Lecture-22.pdf · Methods for the Navier-Stokes Equations!!Moin and Kim!!Bell, et al

Computational Fluid Dynamics

u!

vnx+1,j!

P!

unx,j! Pnx,j!

u! P!

v!

u!

unx+1,j!

u!

vnx+2,j!

v!v(nx+2,1:ny+1)=v(nx+1,1:ny+1);!

u(nx+1,j)=u(nx,j);!

p(nx,j)=(1/2)*(p(nx,j+1)+p(nx,j-1)-(h/dt)*(v(nx+1,j+1)-v(nx+1,j)));!!

!u!x

= 0

!v!x

= 0

For the pressure, obtain an equation by applying conservation of mass to the control volume next to the boundary!

Computational Fluid Dynamics

Example!

Computational Fluid Dynamics

Simplified Backward Facing Step Problem!

Velocity given!

u = u(y)v = 0

!u!x

= 0

Velocity gradient given!

!v!x

= 0

Computational Fluid Dynamics

0 5 10 15 20 25 30 350

2

4

6

8

10

12

14

16

18

20

Velocity!

Computational Fluid Dynamics

5 10 15 20 25 30

2

4

6

8

10

12

14

16

18

Velocity+vorticity!

Computational Fluid Dynamics

05

1015

20

0

10

20

30

40-2.5

-2

-1.5

-1

-0.5

0

0.5

Pressure!

Inflow!

Page 9: Solving the Navier-Stokes Methods for the Navier-Stokes Equations ...gtryggva/CFD-Course/2011-Lecture-22.pdf · Methods for the Navier-Stokes Equations!!Moin and Kim!!Bell, et al

Computational Fluid Dynamics

Periodic Boundary conditions!In many cases it is possible to use periodic boundary conditions, where what flows out through one boundary reappears flowing in through the opposite boundary. Such conditions are particularly suitable for theoretical studies of idealized flows. For such boundaries it is easiest to specify the pressure drop, but by adjusting the pressure gradient it is possible to specify the volume flux!

Computational Fluid Dynamics

External flow!

Free outflow!

Free stream (uniform flow, for example)!

Boundary of computational domain!

Computational Fluid Dynamics

Other ways to deal with free-stream boundaries!!Include potential flow perturbation!!Compute flow from vorticity distribution!!Map the boundary at infinity to a finite distance!

Fundamentally, the specification of the boundary conditions does not have a unique solution and is also faced by experimentalists. However, by taking the boundaries far away and checking the solution for the effect of moving the boundaries, good results can be obtained!

Computational Fluid Dynamics

The two-dimensional programs developed in the project and shown here can be extended to fully three-dimensional flows in a relatively straight forward way, replacing u(i,j) by u(i,j,k), etc. The time required to run the code increases significantly and visualizing the output becomes more challenging. !


Recommended