DFTK.jl
DFTK.jl copied to clipboard
Minor refactoring of the FFTs
In this PR, I propose some refactoring of the FFTs, in order to try and help disentangle the massive PlaneWaveBasis
type.
The rational behind the proposed changes is that FFTs can, in principle, take place independently of the basis. As a result, a new FFTBundle
type is created, containing all data required to perform such operations. The creation of a FFTBundle
can take place independently of a PlaneWaveBasis
, and only requires fft_size
, unit_cell_volume
and architecture
. All subsequent calls to the fft()
and ifft()
functions now require a FFTBundle
as argument, rather than a PlaneWaveBasis
. Instead of having a loose collection of FFT plans, the PlaneWaveBasus
now has a single FFTBundle
as a field.
The main changes are in these files:
-
fft.jl
, where theFFTBundle
type is defined. All functions in this file are now independent of thePlaneWaveBasis
type. An extra couple of functions (fft_matrix()
andifft_matrix()
) were also moved to this file fromPlaneWaveBasis.jl
, as they are also basis independent. - A
Kpoint.jl
file was created, containing the definition of theKpoint
type and related functions. This was also taken out ofPlaneWaveBasis.jl
, for the main reason thatKpoint
must be defined for FFTs, which should be defined for the creation of aPlaneWaveBasis
. Note that this also reduces the size and complexity ofPlaneWaveBasis.jl
. -
PlaneWaveBasis.jl
, which was simplified.
The changes in all other files essentially consist in replacing argument in FFT function calls, e.g. fft(basis, ...)
--> fft(basis.fft_bundle, ...)
. Note that the original fft()
calls with the basis as argument could be easily retrieved by defining functions such as fft(basis, ...) = fft(basis.fft_bundle, ...)
in PlaneWaveBasis.jl
. I guess this is a stylistic question, and I personally like having these explicit calls (I am happy to change if the DFTK standard is different).
In the future, I plan to open a new PR where I take some of the K-point complexity out of PlaneWaveBasis.jl
, by creating a new type containing all the necessary data for a set K-points.