Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oddball handling (Nyquist mode at even discretization sizes) #37

Open
Ceyron opened this issue Sep 6, 2024 · 1 comment
Open

Oddball handling (Nyquist mode at even discretization sizes) #37

Ceyron opened this issue Sep 6, 2024 · 1 comment

Comments

@Ceyron
Copy link
Owner

Ceyron commented Sep 6, 2024

Given a discretization with N degrees of freedom, the FFT of such an array has the Nyquist mode at N//2. Typically, for each mode, except the mean mode (k=0), there is both a "positive wavenumber" and a "negative wavenumber." However, if N is even (i.e., N%2 == 0), only one wavenumber carries the energy in the Nyquist mode. This is problematic because it only allows the cosine component of the Nyquist mode to be captured.

Let's say N=6, and I want to sample cos(3 * 2*pi/L x). This will give a contribution to the Nyquist mode [at unscaled wavenumber -3] of N + 0i (N in the real part of the complex number, and zero in the imaginary part). Then, there are three scenarios:

  1. I want to obtain the first derivative: I would multiply with 1j (-3), turning the coefficient into 0 - 3N j. In an inverse transform, the imaginary Nyquist component would result in an imaginary cosine signal (precisely: 3j * cos(3 * 2*pi/L x) ). However by using the rfft, we zero out any imaginary components at the Nyquist mode, so there essentially is only a zero real signal, which is fine because the analytical derivative of the cosine at Nyquist mode (a sine) would be seen as a zero signal anyway.

  2. I want to obtain the second derivative efficiently: I would multiply with (1j * (-3))^2 = -9. Hence, I would just scale the real component. Transforming back would give the correct derivative signal of -9 cos(3 * 2*pi/L x).

  3. I want to obtain the second derivative by applying the former first derivative twice: This would - incorrectly - also give a zero signal. This can be problematic, but the effect can also be very small because a signal with a Nyquist component likely also has higher modes that, with their aliases, produce issues anyway.

I am still thinking about how this is in 2D and 3D and whether that affects the ETDRK methods.

@Ceyron
Copy link
Owner Author

Ceyron commented Sep 6, 2024

This is potentially also related to #10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant