Fourier in all directions

641 views
Skip to first unread message

nathanael...@gmail.com

unread,
Apr 19, 2016, 8:41:25 AM4/19/16
to Dedalus Users
Hello,

We try to solve the 2D Navier-Stokes equation in a cartesian periodic domain.
Is there something special to do when doing Fourier in all directions ?

In particular with pressure ?
Is there a way to get rid of the pressure by "projecting" on divergence-free modes, like is commonly done in spectral periodic simulations of Navier-Stokes ?

I could not find any example with only periodic directions.

Thank you!
Nathanael.

Keaton Burns

unread,
Apr 19, 2016, 9:29:24 AM4/19/16
to Dedalus Users
Hi Nathanael,

The typical approach with Dedalus is to simultaneously solve the evolution equations with the divergence constraint to enforce incompressibility. In this approach, the double-Fourier formulation is only different from the Chebyshev formulation in that you don’t need to reduce the z-derivatives to first order, and you need to condition on both the x and y wavenumbers to replace the (0,0) mode of the divergence constraint with the pressure gauge. Here’s one way you might write the Boussinesq equations a double-Fourier domain, for example:

problem.add_equation("p = 0", condition="(nx == 0) and (nz == 0)")
problem.add_equation("dx(u) + dz(w) = 0", condition="(nx != 0) or (nz != 0)")
problem.add_equation("dt(b) - κ*(dx(dx(b)) + dz(dz(b))) + N**2*w = -(u*dx(b) + w*dz(b))")
problem.add_equation("dt(u) - ν*(dx(dx(u)) + dz(dz(u))) + dx(p) = -(u*dx(u) + w*dz(u))")
problem.add_equation("dt(w) - ν*(dx(dx(w)) + dz(dz(w))) + dz(p) - b = -(u*dx(w) + w*dz(w))")

For 2D, you could also use a streamfunction-vorticity formulation to reduce the size of the system, similarly using the (0,0) mode of the streamfunction equation to set the streamfunction gauge.

Also I’ll try to add a fully Fourier example for future reference.

Best,
-Keaton
> --
> You received this message because you are subscribed to the Google Groups "Dedalus Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to dedalus-user...@googlegroups.com.
> To post to this group, send email to dedalu...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/dedalus-users/a961b616-296e-4b29-9c26-1d2bde8f48fa%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

nathanael...@gmail.com

unread,
Apr 19, 2016, 10:27:32 AM4/19/16
to Dedalus Users
Thank you for your quick answer.

I overlooked the condition on pressure, and it works now.

cheers!
Nathanael

Ben Brown

unread,
Apr 19, 2016, 11:43:05 PM4/19/16
to dedalus-users
Nat,
     Great to see you here!  I wanted to expand very slightly on Keaton's excellent answer, since this issue has come up repeatedly.

When solving constrained equations, like incompressible Navier-Stokes, it is critical to set one or more gauges like the pressure gauge that is set in the example script Keaton sent.

When doing fully compressible Navier-Stokes, no such gauge condition needs to be applied in the boundary conditions.  One way that I think about it is that the return of the time derivative in the continuity equation eliminates this need for gauge fixing and conversely when we lose that time derivative (in incompressible dynamics), the gauge must be fixed. 

Compressible Navier-Stokes at moderately high Mach number (say Ma~0.1) is fairly trivial to implement; just code up the equations and away you go. 

Compressible Navier-Stokes at very low Mach number (Ma~1e-4) is quite feasible but takes leveraging the stiffly stable time stepping characteristics of the IMEX timesteppers.  Daniel has a nice write up of this for one set of equations in his 2014 ApJ paper (http://adsabs.harvard.edu/abs/2014ApJ...797...94L), and these were tested extensively against Athena in Lecoanet et al 2016 MNRAS (http://adsabs.harvard.edu/abs/2016MNRAS.455.4274L).  We've been playing around with them a bunch for stratified convection and other problems, and I'd be happy to help if you want to take a look at some of those problems.

--Ben



--
You received this message because you are subscribed to the Google Groups "Dedalus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dedalus-user...@googlegroups.com.
To post to this group, send email to dedalu...@googlegroups.com.

Ben Brown

unread,
Apr 19, 2016, 11:44:28 PM4/19/16
to dedalus-users
Keaton & users,
       What about a doubly-periodic incompressible Kelvin Helmholtz problem?  It's nice and clean and ties in conceptually with Daniel's benchmark (though that was fully compressible).

--Ben

geoff

unread,
Apr 20, 2016, 12:22:26 AM4/20/16
to dedalu...@googlegroups.com
I might add all of the well-known formulation are completely equivalent. 

A lot of the concepts come from the days when people lovingly hand made the order of the physics in their code much more than needed today. 

For example people like to discuss differences like “pressure projection methods” and “divergence cleaning”. What’s the difference?

You can think of things in two common ways. 

You could 

(1) Compute Fx, Fy
(2) Get rid of the divergence of the forces.
(3) Update the velocity.

Or you could

(1) Compute Fx, Fy
(2) Update the velocity
(3) Get rid of the divergence of the velocity.

The difference amounts to solving 

Gx = Fx - dx(p)
Gy = Fy - dy(p)
dx(Fx) + dy(Fy) = 0

dt(ux) = Gx
dt(uy) = Gy 


versus 

dt( vx ) = Fx
dt( vy ) = Fy

ux = vx + dx(phi)
uy = vy + dx(phi)
dx(ux) + dy(uy) = 0

All this is saying is that p = dt(phi). 

The main reason for this is that there is no “time” to enforce the divergence condition. It doesn’t know if it’s happening before or after the tilmestep. 

The stream-function formulation doesn’t know what time to make things not diverge because the divergence condition is a sort of disembodied assumption that pervades the entire calculation. In a way, stream function formulation is like doing both of the two options just to really make sure you got it. First taking the curl of the momentum equations makes sure the forces don’t have divergence. Then writing the velocity in terms of the curl of something makes sure that the velocity can’t diverges even though you kind of already got things with the forces in the first place. The stream function is non-divergent 24 hours a day, 7 days a week 356 days a year, day and night in any season. The hardest-working non-diverger in the business. I might add that it’s annoying to write the equations this way. 

Dedalus clears the divergence in one single simultaneous solve. Because there is no time derivative in the diverges condition it is block decoupled from the rest of the calculation. This simple fact means the solver can do it in what ever order it sees fit. 

Another advantage is that simply adding a suitably scaled time-derivative term into the divergence condition make the calculation compressible. The solver doesn’t care at all.  

-Geoff

Reply all
Reply to author
Forward
0 new messages