Where is Fourier()

In the demo on spectral methods found at
https://docs.sciml.ai/SciMLBenchmarksOutput/stable/MOLPDE/burgers_spectral_wpd/
there is a call to Fourier(). I cannot figure out which module it is in. Could somebody please let me know? Also, what is the best way to find that module that contains a particular method is the module is not yet `added via the package manager.

Here is my own pseudo spectral code to solve Burger’s equation using Euler method, although I can obviously upgrade to any temporal solver for higher order results:

using Plots
using FFTW

# Solve Burger's equation via pseudospectral method. 
# Use periodic boundary conditons
# u_t + u u_x = ν u_xx
# Let uhat = F(u) be the Fourier transform of u
# In Fourier space, Burgers equation becomes
# uhat_t + i k uhat = ν k^2 uhat
# Given uhat, its spatial derivative is given by
# uhat_x = i k uhat

# Define the domain
Lx = 2π
Nx = 512
# Periodic x domain
x = range(0, Lx, length=Nx+1)[1:end-1]
dx = x[2] - x[1]
T = 1.0
Nt = 400
dt = T / Nt
μ = 0.01

u0 = sin.(3 .* x)
frequ = fftfreq(129)*129 |> collect

# Functions to simoplify Collocation method
function derivs(u, freq)
    uhat = rfft(u)
    uhatk = im .* freq .* uhat
    uhatkk = -freq.^2 .* uhat
    ux = irfft(uhatk, length(u))
    uxx = irfft(uhatkk, length(u))
    return ux, uxx
end

u0 = sin.(1 .* x)
Nh = div(Nx, 2) + 1
frequ = fftfreq(Nh)*Nh |> collect
ux, uxx = derivs(u0, frequ)

plot(u0)
plot!(ux)
plot!(uxx / 9.)

# Euler
# Save solution ever step iterations for plotitng
nstep = 1
# usave: list of solution
usave = []
sol = zeros(Float64, Nx, Nt)
sol[:, 1] = u0
push!(usave, copy(u0));
u = copy(u0)
for i in 2:Nt
    ux, uxx = derivs(u, frequ)
    u .= u + dt .* (μ * uxx - u .* ux)
    if i % nstep == 0
        sol[:,i] = copy(u)
        push!(usave, copy(u))
    end
end

plot(x, usave[1])
for i in 2:20:400
    p = plot!(x, usave[i], c=:red, alpha=i/400)
    display(p)
end

Any improvements to this code are welcome. It runs extremely fast.

Where is Fourier?
At Père Lachaise in Paris.

2 Likes

I knew that! Note the brackets though. :slight_smile:

3 Likes

It’s an approximation space from ApproxFun: Spaces · ApproxFun.jl

1 Like

Try @which or @less perhaps.

julia-1.9> @which Fourier()
(ApproxFunBase.SumSpace{Tuple{CosSpace{DD, RR}, SinSpace{DD, RR}}, DD, RR} where {DD, RR})()
     @ ApproxFunFourier ~/.julia/packages/ApproxFunFourier/qgHBD/src/ApproxFunFourier.jl:423
1 Like

Thank you both! I had checked all the functions in all the packages manually, but did not find the method. I obviously missed because it is indeed there! I did not think of @which. My bad. Thanks.