Size of coefficient Vectors (kx, ky, kz)

215 views
Skip to first unread message

Ali Asad

unread,
Feb 8, 2021, 11:57:14 AM2/8/21
to Dedalus Users
Hi,

I am running a 3-D couette flow problem with Fourier x and z basis and SinCos y basis. The physical domain has size (36, 36, 36), However, the coefficient domain ['c'] has size (18, 36, 35). As x and z have same basis it is strange for kx and kz to differ in size. I tried to understand this using some simpler 1D and 2D codes but the condition exists only for this particular 3D case.

Lx, Ly, Lz = (4*np.pi, 2., 2*np.pi)
nx, ny, nz = (36,36,36)

# Create bases and domain
x_basis = de.Fourier('x', nx, interval=(0, Lx), dealias=3/2)
y_basis = de.SinCos('y',ny, interval=(-Ly/2, Ly/2), dealias=3/2)
z_basis = de.Fourier('z', nz, interval=(0, Lz), dealias=3/2)
domain = de.Domain([x_basis, y_basis, z_basis], grid_dtype=np.float64) 

Please help me understand this behavior of dedalus. 

Thanks and Regards,
Ali

Jeffrey S. Oishi

unread,
Feb 8, 2021, 12:30:24 PM2/8/21
to dedalus-users
Hi Ali,

This is because when we do the transform from grid --> coefficient space, the first transform is real to complex. Thus it has only half the number of coefficients. The second transform is complex to complex, so it must have the same number of coefficients as grid points. The third transform is similar, but we drop the nyquist mode for Fourier bases. For a complex domain, this shows up as one fewer mode. For real, we do not shorten the array but we do not use the Nyquist mode. For further details, please see section IV.A of the Dedalus methods paper (https://journals.aps.org/prresearch/abstract/10.1103/PhysRevResearch.2.023068).

You can see similar behavior if you define a complex 1-D domain on a Fourier basis. You'll see an odd number of modes (N-1) for an even number N of grid points.

Jeff

--
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/a3e03297-9a42-460f-99ce-1df2567ccac5n%40googlegroups.com.

Jeffrey S. Oishi

unread,
Feb 8, 2021, 12:34:35 PM2/8/21
to dedalus-users
Hi Ali,

One other thing to add: your y basis is SinCos, so fields defined on it will have the same number of modes as grid points regardless of whether or not it is real or complex. Again, this is in the methods paper.

My comment about the second basis having 36 modes in the second direction is because it is SinCos, not because it is complex. If you had a triply periodic Fourier domain on 36,36,36 grid points, you would have 18,35,35 modes.

Of course, since you've specified a 3/2 dealiasing, you'd actually end up with 54^3 grid points...

Jeff

Ali Asad

unread,
Feb 8, 2021, 7:47:03 PM2/8/21
to Dedalus Users
Thanks a lot Jeff.

I understand how my x_basis is has a real to complex transform and the elements are halved. However, why the same is not applied to a subsequent z_basis is not clear to me. Maybe I sound stupid, I am a little new to spectral methods.

The paper is really helpful and needs to be present in dedalus documentation.

Thanks,
Ali

Jeffrey S. Oishi

unread,
Feb 8, 2021, 7:58:29 PM2/8/21
to dedalus-users

Thanks a lot Jeff.
Sure thing! 


I understand how my x_basis is has a real to complex transform and the elements are halved. However, why the same is not applied to a subsequent z_basis is not clear to me. Maybe I sound stupid, I am a little new to spectral methods.
Because once you do the first x transform real to complex, you now have complex numbers representing Fourier coefficients at each (y, z) point, so the subsequent transforms must be complex rather than real. This is one of the most common points of confusion for those new to spectral methods!
 
The paper is really helpful and needs to be present in dedalus documentation.
A link is on the front page of the documentation, but maybe we need a more prominent link for those new to the community

 
Reply all
Reply to author
Forward
0 new messages