DFTK.jl
DFTK.jl copied to clipboard
Derivative in Fourier space of real function not real
Linked to https://github.com/JuliaMolSim/DFTK.jl/pull/691
Gist of the issue if real functions are converted in Fourier with complex FFT
ifft(im .* [0 1 -1] .* fft([1 8 7])))
is real, but not
ifft(im .* [0 1] .* fft([1 8])))
To bypass the issue when getting a gradient, I have used G_to_r(…; assume_real=Val(true)).
Otherwise, with filters, G_to_r(r_to_G) may not be the identity.
To bypass the issue when getting a gradient, I have used G_to_r(…; assume_real=Val(true))
I think that's fine. Other possibilities are to filter out the last component of the gradient operator (here 1 in [0, 1]), which is super annoying, or to have r_to_G filter it out, which makes r_to_G and G_to_r not inverses of each other, which is even worse. Of course, longer term we should use the real FFT routines...
Real FFT routines implemented now.