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.916443363740                   -0.69    4.5    100ms
  2   -7.921206743602       -2.32       -1.52    1.0   52.4ms
  3   -7.921407025940       -3.70       -2.49    1.5   64.0ms
  4   -7.921440985965       -4.47       -2.84    2.4   70.4ms
  5   -7.921441667266       -6.17       -3.04    1.0   52.7ms
  6   -7.921442008366       -6.47       -4.58    1.1   54.2ms
  7   -7.921442021880       -7.87       -4.66    3.0   86.9ms
  8   -7.921442022134       -9.59       -5.37    1.1   54.6ms
  9   -7.921442022139      -11.31       -5.38    1.8   61.3ms
 10   -7.921442022144      -11.34       -6.05    1.0   53.5ms
 11   -7.921442022144      -12.59       -6.77    1.5   64.3ms
 12   -7.921442022144      -13.60       -7.05    2.0   65.8ms
 13   -7.921442022144      -14.75       -7.96    1.1   55.5ms
 14   -7.921442022144   +    -Inf       -8.10    2.2   70.2ms

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.92s  Non-interacting
   1        0       1        0.31     52.4   2.18s
   2        0       2       -0.52     47.0   2.07s
   3        0       3       -2.40     41.8   1.31s
   4        0       4       -4.46     29.8   1.04s
   5        0       5       -6.46     17.4   738ms
   6        0       6       -8.91      4.0   416ms
   7        1       1       -7.85     55.6   1.97s  Restart
   8        1       2       -8.92      5.6   450ms
                                      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.4   1.68s
   2        0       2       -0.52     47.0   1.46s
   3        0       3       -2.40     41.8   1.32s
   4        0       4       -4.46     29.8   1.03s
   5        0       5       -6.46     17.4   734ms
   6        0       6       -8.91      4.0   422ms
   7        1       1       -7.85     55.6   1.96s  Restart
   8        1       2       -8.92      5.6   449ms
                                      72.8   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.4   1.66s
   2        0       2       -0.52     47.0   1.44s
   3        0       3       -2.40     41.8   1.96s
   4        0       4       -4.46     29.8   1.04s
   5        0       5       -6.46     17.4   729ms
   6        0       6       -8.91      4.0   411ms
   7        1       1       -7.85     55.6   1.96s  Restart
   8        1       2       -8.92      5.6   461ms
                                      72.9   1.96s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.1   1.81s  Non-interacting
   1        0       1        0.31     52.4   1.67s
   2        0       2       -0.52     47.0   1.45s
   3        0       3       -2.40     41.8   1.32s
   4        0       4       -4.46     29.8   1.03s
   5        0       5       -6.46     17.4   731ms
   6        0       6       -8.91      4.0   410ms
   7        1       1       -7.86     55.5   1.96s  Restart
   8        1       2       -8.97      5.5   441ms
                                      72.8   1.95s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.1   1.79s  Non-interacting
   1        0       1        0.31     52.4   1.66s
   2        0       2       -0.52     47.0   1.43s
   3        0       3       -2.40     41.8   1.30s
   4        0       4       -4.46     29.8   1.02s
   5        0       5       -6.46     17.4   1.35s
   6        0       6       -8.91      4.0   427ms
   7        1       1       -7.86     55.5   1.93s  Restart
   8        1       2       -8.97      5.5   453ms
                                      72.9   1.97s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.82s  Non-interacting
   1        0       1        0.31     52.4   1.68s
   2        0       2       -0.52     47.0   1.45s
   3        0       3       -2.40     41.8   1.32s
   4        0       4       -4.46     29.8   1.04s
   5        0       5       -6.46     17.4   737ms
   6        0       6       -8.91      4.0   420ms
   7        1       1       -7.86     55.5   1.96s  Restart
   8        1       2       -8.97      5.5   453ms
                                      72.8   1.96s  Final orbitals
 86.454733 seconds (92.57 M allocations: 80.340 GiB, 6.86% gc time, 1.18% compilation time: 100% of which was recompilation)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.00349815535903826
 -0.002977451157750326
 -0.002977451157451438
  0.004302230620380276
  0.004302230620605862
  0.004353201752256856