Phonon computations

This is a quick sketch how to run a simple phonon calculation using DFTK. First we run an SCF calculation.

using AtomsBuilder
using DFTK
using PseudoPotentialData

pseudopotentials = PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth")
model  = model_DFT(bulk(:Si); pseudopotentials, functionals=LDA())
basis  = PlaneWaveBasis(model; Ecut=10, kgrid=[4, 4, 4])
scfres = self_consistent_field(basis, tol=1e-8);
n     Energy            log10(ΔE)   log10(Δρ)   Diag   Δtime
---   ---------------   ---------   ---------   ----   ------
  1   -7.916453171422                   -0.69    4.8    102ms
  2   -7.921212118254       -2.32       -1.52    1.0   52.0ms
  3   -7.921408092952       -3.71       -2.49    1.4   56.8ms
  4   -7.921441008129       -4.48       -2.84    2.5   70.5ms
  5   -7.921441694018       -6.16       -3.06    1.2   62.2ms
  6   -7.921442007194       -6.50       -4.58    1.0   53.0ms
  7   -7.921442021864       -7.83       -4.64    3.1   81.9ms
  8   -7.921442022130       -9.58       -5.29    1.0   52.9ms
  9   -7.921442022143      -10.90       -5.81    1.5   58.7ms
 10   -7.921442022144      -11.88       -6.05    1.5   65.0ms
 11   -7.921442022144      -12.73       -6.62    1.1   56.8ms
 12   -7.921442022144      -13.57       -8.07    1.8   62.7ms

Next we compute the phonon modes at the q-point [1/4, 1/4, 1/4].

scfres = DFTK.unfold_bz(scfres)
phret_q0 = @time DFTK.phonon_modes(scfres; q=[0.25, 0.25, 0.25]);
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.1   1.93s  Non-interacting
   1        0       1        0.31     52.5   2.18s
   2        0       2       -0.52     47.1   1.44s
   3        0       3       -2.40     41.8   1.32s
   4        0       4       -4.46     30.0   1.03s
   5        0       5       -6.46     17.5   725ms
   6        0       6       -8.91      4.0   407ms
   7        1       1       -7.86     55.6   1.95s  Restart
   8        1       2       -9.07      5.6   443ms
                                      72.8   1.93s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.80s  Non-interacting
   1        0       1        0.31     52.5   1.67s
   2        0       2       -0.52     47.1   1.44s
   3        0       3       -2.40     41.8   1.96s
   4        0       4       -4.46     30.0   1.01s
   5        0       5       -6.46     17.5   733ms
   6        0       6       -8.91      4.0   411ms
   7        1       1       -7.86     55.6   1.97s  Restart
   8        1       2       -9.07      5.6   451ms
                                      72.9   1.96s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.81s  Non-interacting
   1        0       1        0.31     52.5   1.67s
   2        0       2       -0.52     47.1   1.45s
   3        0       3       -2.40     41.8   1.33s
   4        0       4       -4.46     30.0   1.03s
   5        0       5       -6.46     17.5   734ms
   6        0       6       -8.91      4.0   407ms
   7        1       1       -7.86     55.6   1.98s  Restart
   8        1       2       -9.07      5.6   442ms
                                      72.8   1.94s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.1   1.79s  Non-interacting
   1        0       1        0.31     52.5   1.66s
   2        0       2       -0.52     47.1   1.44s
   3        0       3       -2.40     41.8   1.30s
   4        0       4       -4.46     30.0   1.69s
   5        0       5       -6.46     17.5   695ms
   6        0       6       -8.91      4.0   404ms
   7        1       1       -7.88     55.3   1.95s  Restart
   8        1       2       -9.14      5.4   442ms
                                      72.8   1.96s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.80s  Non-interacting
   1        0       1        0.31     52.5   1.68s
   2        0       2       -0.52     47.1   1.44s
   3        0       3       -2.40     41.8   1.32s
   4        0       4       -4.46     30.0   1.04s
   5        0       5       -6.46     17.5   731ms
   6        0       6       -8.91      4.0   416ms
   7        1       1       -7.88     55.3   1.95s  Restart
   8        1       2       -9.14      5.4   446ms
                                      72.8   1.95s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.81s  Non-interacting
   1        0       1        0.31     52.5   1.67s
   2        0       2       -0.52     47.1   1.45s
   3        0       3       -2.40     41.8   1.32s
   4        0       4       -4.46     30.0   1.03s
   5        0       5       -6.46     17.5   733ms
   6        0       6       -8.91      4.0   1.10s
   7        1       1       -7.88     55.3   1.88s  Restart
   8        1       2       -9.14      5.4   441ms
                                      72.8   1.96s  Final orbitals
 86.322377 seconds (94.39 M allocations: 80.433 GiB, 7.33% gc time, 1.17% compilation time: 100% of which was recompilation)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.0034981553780456666
 -0.0029774511810992123
 -0.0029774511780980843
  0.004302230587303587
  0.004302230591275319
  0.00435320172395886
Preliminary implementation

Practical phonon computations have only seen rudimentary testing as of now. As of now we do not yet recommend relying on this feature for production calculations. We appreciate any issues, bug reports or PRs.