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

Small bug: spatial domain discretization is wrong #6

Merged
merged 1 commit into from
Jun 4, 2022

Conversation

pjabardo
Copy link
Contributor

This is a small and commont bug when using FFTs. The domain on each axis is (0, 2π). When discretizing it, the code was including both ends! What this means is that actually the domain has a period of 2π * (1 + 1/(N-1)). This introduces noise and aliasing. And the periodic function is discontinuous.

The domain should be divided in N_POINTS_P_AXIS segments and the points should correspond to the left point of each segment.

It is difficult to see but this appears to reduce noise in the solution.

This is a small and commont bug when using FFTs. The domain on each axis is (0, 2π). When discretizing it, the code was including both ends! What this means is that actually the domain has a period of 2π * (1 + 1/(N-1)). This introduces noise and aliasing. And the periodic function is discontinuous.

The domain should be divided in `N_POINTS_P_AXIS` segments and the points should correspond to the left point of each segment.

It is difficult to see but this appears to reduce noise in the solution.
@Ceyron
Copy link
Owner

Ceyron commented Jun 4, 2022

Hi Paulo,
thanks for the PR. :) You are right, that is a small mistake in the discretization. I am continuously learning, thanks for the contribution.
I will merge it in and also leave a comment under the video.

In the repo, there are also three more files that rely on a spectral solver that also have the same bug. I will adapt them as well.

Cheers,
Felix

@Ceyron Ceyron merged commit 208fc31 into Ceyron:main Jun 4, 2022
@pjabardo
Copy link
Contributor Author

pjabardo commented Jun 4, 2022

I have to say that your youtube channel is one of the best I've seen. I wish your channel existed when I got started on this area 20 years ago. Congratulations.

@Ceyron
Copy link
Owner

Ceyron commented Jun 5, 2022

Thanks for these kind words :). They are really appreciated.
The content I produce is also born by the fact that there are just no hands-on resources for this kind of stuff on YouTube. Even with this small mistake in the FFT here, I still believe that the videos (and the accompanying source code) can be of great help for someone who wants to dive into numerical simulations.

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

Successfully merging this pull request may close these issues.

None yet

2 participants