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.916423615035                   -0.69    4.6    108ms
  2   -7.921198502742       -2.32       -1.52    1.0   54.7ms
  3   -7.921401314302       -3.69       -2.49    1.4   69.9ms
  4   -7.921440984326       -4.40       -2.80    2.8   78.9ms
  5   -7.921441449936       -6.33       -2.89    1.0   54.8ms
  6   -7.921442008366       -6.25       -4.51    1.0   55.3ms
  7   -7.921442021593       -7.88       -4.47    3.2   89.3ms
  8   -7.921442022118       -9.28       -5.13    1.0   54.8ms
  9   -7.921442022130      -10.94       -5.16    1.1   56.6ms
 10   -7.921442022143      -10.89       -5.87    1.0   67.7ms
 11   -7.921442022144      -12.04       -5.69    1.8   64.0ms
 12   -7.921442022144      -12.74       -5.76    1.0   57.3ms
 13   -7.921442022144      -12.93       -5.87    1.0    108ms
 14   -7.921442022144      -13.18       -6.11    1.0   56.2ms
 15   -7.921442022144      -13.53       -7.65    1.0   57.0ms
 16   -7.921442022144   +  -15.05       -6.61    2.2   74.3ms
 17   -7.921442022144      -14.57       -7.30    2.0   94.4ms
 18   -7.921442022144   +    -Inf       -7.87    1.0   56.4ms
 19   -7.921442022144      -15.05       -8.13    1.0   57.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.0   1.99s  Non-interacting
   1        0       1        0.31     52.7   3.71s
   2        0       2       -0.52     47.2   1.32s
   3        0       3       -2.40     41.8   1.21s
   4        0       4       -4.46     29.9   997ms
   5        0       5       -6.46     17.5   709ms
   6        0       6       -8.92      4.0   419ms
   7        1       1       -7.85     55.9   3.28s  Restart
   8        1       2       -8.95      5.5   414ms
                                      72.9   1.83s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.56s  Non-interacting
   1        0       1        0.31     52.7   1.56s
   2        0       2       -0.52     47.2   1.33s
   3        0       3       -2.40     41.8   1.21s
   4        0       4       -4.46     29.9   972ms
   5        0       5       -6.46     17.5   719ms
   6        0       6       -8.92      4.0   425ms
   7        1       1       -7.85     55.9   1.84s  Restart
   8        1       2       -8.95      5.5   467ms
                                      72.8   1.74s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.60s  Non-interacting
   1        0       1        0.31     52.7   1.55s
   2        0       2       -0.52     47.2   1.33s
   3        0       3       -2.40     41.8   1.21s
   4        0       4       -4.46     29.9   973ms
   5        0       5       -6.46     17.5   697ms
   6        0       6       -8.92      4.0   435ms
   7        1       1       -7.85     55.9   1.85s  Restart
   8        1       2       -8.95      5.5   450ms
                                      72.9   1.74s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.1   1.62s  Non-interacting
   1        0       1        0.31     52.7   1.54s
   2        0       2       -0.52     47.2   1.33s
   3        0       3       -2.40     41.8   1.20s
   4        0       4       -4.46     29.9   962ms
   5        0       5       -6.46     17.5   710ms
   6        0       6       -8.92      4.0   425ms
   7        1       1       -7.84     55.9   1.85s  Restart
   8        1       2       -9.02      5.6   472ms
                                      72.9   1.73s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.57s  Non-interacting
   1        0       1        0.31     52.7   1.52s
   2        0       2       -0.52     47.2   1.32s
   3        0       3       -2.40     41.8   1.21s
   4        0       4       -4.46     29.9   953ms
   5        0       5       -6.46     17.5   815ms
   6        0       6       -8.92      4.0   1.65s
   7        1       1       -7.84     55.9   1.71s  Restart
   8        1       2       -9.02      5.6   432ms
                                      72.9   1.71s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.57s  Non-interacting
   1        0       1        0.31     52.7   1.54s
   2        0       2       -0.52     47.2   1.32s
   3        0       3       -2.40     41.8   1.20s
   4        0       4       -4.46     29.9   966ms
   5        0       5       -6.46     17.5   702ms
   6        0       6       -8.92      4.0   433ms
   7        1       1       -7.84     55.9   1.86s  Restart
   8        1       2       -9.02      5.6   459ms
                                      72.9   1.74s  Final orbitals
 86.484021 seconds (101.36 M allocations: 80.461 GiB, 8.29% gc time, 7.61% compilation time: 100% of which was recompilation)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.003498155351826228
 -0.002977451153455158
 -0.002977451153453954
  0.004302230640574454
  0.004302230640584765
  0.004353201770292334