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

Fix bug in radialspectrum() #318

Merged
merged 1 commit into from
May 29, 2022
Merged

Fix bug in radialspectrum() #318

merged 1 commit into from
May 29, 2022

Conversation

parfenyev
Copy link
Contributor

Fixing bug in the function radialspectrum(). Now the definitions of lshift and kshift are consistent with the operation fftshift.

Fixing bug in the function `radialspectrum`.
@navidcy navidcy self-requested a review May 28, 2022 21:57
@navidcy navidcy added the bug label May 28, 2022
@navidcy navidcy changed the title Update utils.jl Fix bug in radialspectrum() May 28, 2022
Copy link
Member

@navidcy navidcy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest using the grid's wavenumber and shifting them using FFTW.fftshift instead of re-creating them. This way we minimize the places where errors can be introduced.

Also, I'd suggest changing

kshift = range(0, stop=grid.nkr-1, length=grid.nkr) * 2π/grid.Lx

to

kshift = grid.kr

src/utils.jl Show resolved Hide resolved
src/utils.jl Show resolved Hide resolved
@navidcy
Copy link
Member

navidcy commented May 28, 2022

@parfenyev
Copy link
Contributor Author

parfenyev commented May 29, 2022

In your version I have the problem with interpolation:

MethodError: no method matching scale(::Interpolations.BSplineInterpolation{ComplexF64, 2, Matrix{ComplexF64}, BSpline{Linear{Throw{OnGrid}}}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, ::Matrix{Float64}, ::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64})
Closest candidates are:
  scale(::AbstractInterpolation{T, N, IT}, ::AbstractRange...) where {T, N, IT} at ~/.julia/packages/Interpolations/y4lLj/src/scaling/scaling.jl:27

Probably, it happens because interpolation works only on uniformly spaced grids and this is the way to control this.

@navidcy
Copy link
Member

navidcy commented May 29, 2022

Yeap, fair. Forget my suggestion then! :)

@navidcy navidcy self-requested a review May 29, 2022 08:20
@navidcy
Copy link
Member

navidcy commented May 29, 2022

Thanks @parfenyev!

@navidcy navidcy merged commit dc8f102 into FourierFlows:main May 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants