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.916421987781                   -0.69    4.9    113ms
  2   -7.921207197869       -2.32       -1.52    1.0   55.9ms
  3   -7.921409380983       -3.69       -2.49    1.5   62.7ms
  4   -7.921441004885       -4.50       -2.86    2.5   77.4ms
  5   -7.921441764445       -6.12       -3.14    1.1   72.4ms
  6   -7.921442010091       -6.61       -4.52    1.1   58.5ms
  7   -7.921442021984       -7.92       -4.85    2.4   79.5ms
  8   -7.921442022136       -9.82       -5.39    1.1   59.5ms
  9   -7.921442022143      -11.15       -5.39    1.8   65.8ms
 10   -7.921442022144      -11.96       -6.38    1.0   58.0ms
 11   -7.921442022144      -12.91       -7.37    1.9   79.2ms
 12   -7.921442022144      -14.21       -8.41    2.4   78.8ms

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   2.42s  Non-interacting
   1        0       1        0.31     52.9   4.07s
   2        0       2       -0.52     47.2   1.58s
   3        0       3       -2.40     42.0   1.43s
   4        0       4       -4.46     30.0   1.12s
   5        0       5       -6.46     17.6   800ms
   6        0       6       -8.91      4.0   450ms
   7        1       1       -7.88     55.6   2.18s  Restart
   8        1       2       -9.08      5.5   482ms
                                      72.9   2.13s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.98s  Non-interacting
   1        0       1        0.31     52.9   1.83s
   2        0       2       -0.52     47.2   1.58s
   3        0       3       -2.40     42.0   1.43s
   4        0       4       -4.46     30.0   1.15s
   5        0       5       -6.46     17.6   800ms
   6        0       6       -8.91      4.0   443ms
   7        1       1       -7.88     55.6   2.13s  Restart
   8        1       2       -9.08      5.5   477ms
                                      72.9   2.13s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   3.48s  Non-interacting
   1        0       1        0.31     52.9   1.81s
   2        0       2       -0.52     47.2   1.56s
   3        0       3       -2.40     42.0   1.43s
   4        0       4       -4.46     30.0   1.13s
   5        0       5       -6.46     17.6   795ms
   6        0       6       -8.91      4.0   445ms
   7        1       1       -7.88     55.6   2.15s  Restart
   8        1       2       -9.08      5.5   478ms
                                      72.8   2.12s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.1   2.00s  Non-interacting
   1        0       1        0.31     52.9   1.83s
   2        0       2       -0.52     47.2   1.59s
   3        0       3       -2.40     42.0   1.45s
   4        0       4       -4.46     30.0   1.12s
   5        0       5       -6.46     17.6   797ms
   6        0       6       -8.91      4.0   446ms
   7        1       1       -7.88     55.5   2.13s  Restart
   8        1       2       -9.22      5.4   482ms
                                      72.9   2.15s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.1   1.99s  Non-interacting
   1        0       1        0.31     52.9   1.81s
   2        0       2       -0.52     47.2   1.56s
   3        0       3       -2.40     42.0   1.43s
   4        0       4       -4.46     30.0   1.12s
   5        0       5       -6.46     17.6   778ms
   6        0       6       -8.91      4.0   444ms
   7        1       1       -7.88     55.5   2.12s  Restart
   8        1       2       -9.22      5.4   483ms
                                      72.9   2.12s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.96s  Non-interacting
   1        0       1        0.31     52.9   1.79s
   2        0       2       -0.52     47.2   1.55s
   3        0       3       -2.40     42.0   1.40s
   4        0       4       -4.46     30.0   2.52s
   5        0       5       -6.46     17.6   724ms
   6        0       6       -8.91      4.0   430ms
   7        1       1       -7.88     55.5   2.03s  Restart
   8        1       2       -9.22      5.4   485ms
                                      72.9   2.14s  Final orbitals
100.230389 seconds (101.57 M allocations: 80.572 GiB, 8.16% gc time, 7.53% compilation time: 100% of which was recompilation)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.0034981553539986166
 -0.0029774511549183337
 -0.002977451154315081
  0.004302230629945645
  0.004302230630781423
  0.004353201760846797