JuliaMolSim / DFTK.jl

Density-functional toolkit
https://docs.dftk.org
MIT License
444 stars 89 forks source link

Use time-reversal symmetry for orbitals at the gamma point #616

Open antoine-levitt opened 2 years ago

antoine-levitt commented 2 years ago

There are two parts to this.

  1. Using TRS only to speed up FFTs, keeping the data representation the same

  2. Using a minimal compressed representation

The issue with 1 is we have functions like G_to_r!(f_real, f_fourier) where f_real is complex 3D, and f_fourier is complex 1D. This function puts f_fourier into f_real, and then in-place transforms it. If we want to keep this structure (and not have an extra array) we need to use a rfft!, which is not implemented directly by FFTW.jl. There's https://discourse.julialang.org/t/in-place-rfft-with-padded-arrays/3340/4 which suggests a way out. The key part is calling FFTW.rFFTWPlan to access the lower-level interface directly. Together with some low-level reinterpret business this should be OK (we should put these ad-hoc things in r_to_G!_lowlevel functions that would only be used by DftHamiltonian)

Then, for 2, the minimal compressed representation should be done in a way that preserves the inner product. That means sqrt(2) and DC component shenanigans. It also means that not every randn() is valid as an orbital (because the DC component should be real), so things like the randn in LOBPCG have to be modifed. The gain/annoyance to ratio is pretty low for this one, so we should probably don't do it.

mfherbst commented 2 years ago

Related to #36 and #224

mfherbst commented 2 years ago

I agree. 1 sounds useful, 2 not so much.

antoine-levitt commented 2 years ago

Good point, I forgot I wrote a nice writeup in https://github.com/JuliaMolSim/DFTK.jl/issues/36. So yeah, let's definitely not do 2.