RE: Doubly Periodic vs Fourier-Chebyshev grid

384 views
Skip to first unread message

Kesava Prasad

unread,
Apr 6, 2021, 8:57:53 AM4/6/21
to Dedalus Users
Hello,

I am comparing some results of 2D NSE (KHI) with Fourier-Chebyshev grid and doubly periodic (thanks to Keaton I was able to run this) and I am getting different results even though the formulation of the equations is same in both grids.

For example, the passive tracer evolves in an entirely different manner in the doubly periodic domain especially at the top and bottom boundaries. Are  additional constraints needed  at the boundaries even though in this case no boundaries conditions are requires.  Is this correct or am i missing something? I appreciate any help.

Cheers,
Kesava
kh3_fourier_chebyshev.py
kh3_fourier.py
doubly_periodic.gif

Daniel Michael Lecoanet

unread,
Apr 6, 2021, 9:07:38 AM4/6/21
to dedalu...@googlegroups.com
Hi Kesava,

You have to be careful with BCs. The doubly periodic problem has two shear layers — one at z=0, and one at z=\pm 1 (which are the same point. If you use Chebyshev in the z direction with, say, stress-free BCs, then you only have one shear layer.

There are two ways to get similar results with the two simulations. The first is to make the Chebyshev problem more like the Fourier problem. For that, you want to set periodic BCs (left(u)-right(u) = 0, etc. for all your variables). The other option is to make the periodic problem more like the Chebyshev problem. You can do that by using the SinCos basis in z. There should be a choice of parity that will let you get something similar to the Chebyshev problem.

Daniel

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/dedalus-users/46d2bdd2-a060-4023-951f-04eb84ebc402n%40googlegroups.com.
<kh3_fourier_chebyshev.py><kh3_fourier.py><doubly_periodic.gif>

Kesava Prasad

unread,
Apr 7, 2021, 3:15:22 AM4/7/21
to Dedalus Users
Hi Daniel,

It makes sense to set periodic BCs but won't dedalus throw an error if you specify any sort of boundary conditions in a doubly periodic problem. Is there any specific way to define BCs in this case?

Thanks,
Kesava 

Daniel Michael Lecoanet

unread,
Apr 7, 2021, 9:00:56 AM4/7/21
to dedalu...@googlegroups.com
Hi Kesava,

I see two options here: Use Chebyshev to impose periodic BCs; use SinCos which parity conditions which are similar to the Chebyshev BCs you’re currently using. You’re right that you cannot apply BCs to a Fourier series.

Daniel

Kesava Prasad

unread,
Apr 7, 2021, 9:27:08 AM4/7/21
to Dedalus Users
Hi Daniel,

thanks for the insight. I understand what you mean.  So basically imposing periodic BCs on a Chebyshev grid.

Here is a snippet of the implementation:

x_basis = de.Fourier('x', nx, interval=(0, Lx), dealias=3/2)
z_basis = de.Chebyshev('z',nz, interval=(-Lz/2, Lz/2), dealias=3/2)

problem = de.IVP(domain, variables=['p','u','w','uz','wz','S','Sz'])
problem.add_equation("dt(u) + dx(p) - 1/Re*(dx(dx(u))  +dz(uz)) = - u*dx(u)  -w*uz")
problem.add_equation("dt(w) + dz(p)  - 1/Re*(dx(dx(w))  +dz(wz)) = - u*dx(w)  -w*wz")
problem.add_equation("dx(u)  + wz = 0")   #,condition="(nx!=0) or (nz!=0)")
problem.add_equation("dt(S) - 1/(Re*Sc)*(dx(dx(S))  + dz(Sz)) = - u*dx(S)  - w*Sz")
problem.add_equation("uz - dz(u) = 0")
problem.add_equation("wz - dz(w) = 0")
problem.add_equation("Sz - dz(S) = 0")

problem.add_bc("left(u)-right(u) = 0")
problem.add_bc("left(w)-right(w)=0")
problem.add_bc("left(S)-right(S)=0 ")
problem.add_bc("left(p)-right(p)=0 ")
 
Is there a need to impose additional conditional constraints  when defining the equations, since the number of equations and boundary conditions don't match?

Kesava

Daniel Michael Lecoanet

unread,
Apr 7, 2021, 9:30:36 AM4/7/21
to dedalu...@googlegroups.com
You need to impose periodicity on all your variables. That includes uz, wz, and Sz. By the way, you probably also need to impose a gauge choice on the pressure (something like left(p)=0 for the nx==0 mode).

Daniel

Kesava Prasad

unread,
Apr 7, 2021, 9:53:21 AM4/7/21
to Dedalus Users
Hi Daniel,

Yes, I did impose the periodicity for all the variables and also the pressure gauge, but I am getting the following error.

Traceback (most recent call last):
  File "kh2.py", line 53, in <module>
    solver =  problem.build_solver(ts)
  File "/home/kd033/.conda/envs/dedalus/lib/python3.8/site-packages/dedalus/core/problems.py", line 313, in build_solver
    return self.solver_class(self, *args, **kw)
  File "/home/kd033/.conda/envs/dedalus/lib/python3.8/site-packages/dedalus/core/solvers.py", line 361, in __init__
    pencil.build_matrices(self.pencils, problem, ['M', 'L'])
  File "/home/kd033/.conda/envs/dedalus/lib/python3.8/site-packages/dedalus/core/pencil.py", line 65, in build_matrices
    pencil.build_matrices(problem, matrices, cacheid=cacheid)
  File "/home/kd033/.conda/envs/dedalus/lib/python3.8/site-packages/dedalus/core/pencil.py", line 191, in _build_coupled_matrices
    raise ValueError("Pencil {} has {} constant equations for {} constant variables plus {} differential equations / tau terms.".format(global_index, n_const_eqs, n_const_vars, n_tau))
ValueError: Pencil (0,) has 7 constant equations for 0 constant variables plus 6 differential equations / tau terms.

I don't know what I am missing here. Maybe some conditions in the equations?

Kesava
kh2.py

Daniel Michael Lecoanet

unread,
Apr 7, 2021, 10:40:48 AM4/7/21
to 'Adrian Fraser' via Dedalus Users
Ah, ok, this is a bit more subtle than I originally realized… The issue is that we have 7 variables, but only 6 differential equations (incompressibility is an algebraic equation). So you can only impose that 6 of the 7 variables are periodic. For instance, you could pick all of the variables except wz, because wz - dx(u) = 0, and u is periodic, so wz will also be periodic. On top of that, you need to impose a pressure gauge. Here’s a set of BCs which seem to satisfy these:

problem.add_bc("left(u)-right(u) = 0")
problem.add_bc("left(w)-right(w) = 0", condition="(nx!=0)")
problem.add_bc("left(uz)-right(uz) = 0")
problem.add_bc("left(p) = 0", condition="(nx == 0)")
problem.add_bc("left(p)-right(p) = 0")
problem.add_bc("left(S)-right(S) = 0")
problem.add_bc("left(Sz)-right(Sz) = 0")

Daniel

Kesava Prasad

unread,
Apr 7, 2021, 11:09:45 AM4/7/21
to Dedalus Users
Great, it works. I'll report back with the results.

Kesava
Reply all
Reply to author
Forward
0 new messages