Phonon computations

This is a quick sketch how to run a simple phonon calculation using DFTK.

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.

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.916455508180                   -0.69    4.5    104ms
  2   -7.921211011806       -2.32       -1.52    1.0   53.7ms
  3   -7.921404649456       -3.71       -2.49    1.4   65.8ms
  4   -7.921440957444       -4.44       -2.82    2.8   79.4ms
  5   -7.921441615912       -6.18       -3.00    1.0   55.5ms
  6   -7.921442008406       -6.41       -4.56    1.0   55.8ms
  7   -7.921442021824       -7.87       -4.60    3.0   92.4ms
  8   -7.921442022130       -9.51       -5.32    1.0   55.6ms
  9   -7.921442022143      -10.91       -5.86    1.8   64.8ms
 10   -7.921442022144      -11.96       -6.03    1.4   62.2ms
 11   -7.921442022144      -12.67       -6.65    1.0   62.5ms
 12   -7.921442022144      -13.65       -7.73    1.6   64.2ms
 13   -7.921442022144      -14.57       -8.07    2.4   79.1ms

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.97s  Non-interacting
   1        0       1        0.31     52.7   2.26s
   2        0       2       -0.52     47.2   1.48s
   3        0       3       -2.40     41.9   1.35s
   4        0       4       -4.46     30.0   1.06s
   5        0       5       -6.46     17.5   754ms
   6        0       6       -8.91      4.0   418ms
   7        1       1       -7.83     55.9   1.99s  Restart
   8        1       2       -9.04      5.6   466ms
                                      72.8   2.79s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.83s  Non-interacting
   1        0       1        0.31     52.7   1.71s
   2        0       2       -0.52     47.2   1.46s
   3        0       3       -2.40     41.9   1.34s
   4        0       4       -4.46     30.0   1.04s
   5        0       5       -6.46     17.5   748ms
   6        0       6       -8.91      4.0   415ms
   7        1       1       -7.83     55.9   2.01s  Restart
   8        1       2       -9.04      5.6   458ms
                                      72.8   1.98s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.82s  Non-interacting
   1        0       1        0.31     52.7   1.70s
   2        0       2       -0.52     47.2   1.47s
   3        0       3       -2.40     41.9   1.32s
   4        0       4       -4.46     30.0   1.03s
   5        0       5       -6.46     17.5   737ms
   6        0       6       -8.91      4.0   415ms
   7        1       1       -7.83     55.9   1.97s  Restart
   8        1       2       -9.04      5.6   450ms
                                      72.8   1.97s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   2.67s  Non-interacting
   1        0       1        0.31     52.7   1.67s
   2        0       2       -0.52     47.2   1.48s
   3        0       3       -2.40     41.9   1.36s
   4        0       4       -4.46     30.0   1.06s
   5        0       5       -6.46     17.6   761ms
   6        0       6       -8.91      4.0   426ms
   7        1       1       -7.86     55.7   2.03s  Restart
   8        1       2       -9.15      5.6   462ms
                                      72.8   2.01s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.85s  Non-interacting
   1        0       1        0.31     52.7   1.72s
   2        0       2       -0.52     47.2   1.49s
   3        0       3       -2.40     41.9   1.36s
   4        0       4       -4.46     30.0   1.07s
   5        0       5       -6.46     17.6   766ms
   6        0       6       -8.91      4.0   426ms
   7        1       1       -7.86     55.7   2.03s  Restart
   8        1       2       -9.15      5.6   457ms
                                      72.8   1.99s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.82s  Non-interacting
   1        0       1        0.31     52.7   1.67s
   2        0       2       -0.52     47.2   1.45s
   3        0       3       -2.40     41.9   2.01s
   4        0       4       -4.46     30.0   1.01s
   5        0       5       -6.46     17.6   729ms
   6        0       6       -8.91      4.0   419ms
   7        1       1       -7.86     55.7   1.97s  Restart
   8        1       2       -9.15      5.6   456ms
                                      72.8   1.94s  Final orbitals
 88.140004 seconds (91.86 M allocations: 80.063 GiB, 7.26% gc time, 1.23% compilation time: 100% of which was recompilation)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.00349815535226618
 -0.0029774511578562505
 -0.002977451157619339
  0.004302230654362398
  0.00430223065456459
  0.0043532017813520864