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.916260211081                   -0.69    4.8    107ms
  2   -7.921122918413       -2.31       -1.52    1.0   54.5ms
  3   -7.921409201159       -3.54       -2.49    1.9   63.3ms
  4   -7.921441115502       -4.50       -2.90    2.4   73.1ms
  5   -7.921441828390       -6.15       -3.23    1.2   56.6ms
  6   -7.921442010698       -6.74       -4.49    1.1   56.0ms
  7   -7.921442022080       -7.94       -5.08    2.9   81.9ms
  8   -7.921442022142      -10.21       -5.51    1.6   61.9ms
  9   -7.921442022143      -12.09       -5.45    1.4   58.6ms
 10   -7.921442022144      -11.91       -6.42    1.0   55.0ms
 11   -7.921442022144      -13.17       -7.85    1.6   62.1ms
 12   -7.921442022144      -14.27       -8.40    3.1   85.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.0   2.07s  Non-interacting
   1        0       1        0.31     52.5   3.79s
   2        0       2       -0.52     47.0   1.32s
   3        0       3       -2.40     41.8   1.21s
   4        0       4       -4.46     29.7   942ms
   5        0       5       -6.46     17.4   679ms
   6        0       6       -8.91      4.0   417ms
   7        1       1       -7.87     55.4   1.86s  Restart
   8        1       2       -9.14      5.6   453ms
                                      72.8   1.75s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.59s  Non-interacting
   1        0       1        0.31     52.5   1.51s
   2        0       2       -0.52     47.0   1.37s
   3        0       3       -2.40     41.8   1.21s
   4        0       4       -4.46     29.7   935ms
   5        0       5       -6.46     17.4   686ms
   6        0       6       -8.91      4.0   412ms
   7        1       1       -7.87     55.4   1.82s  Restart
   8        1       2       -9.14      5.6   440ms
                                      72.8   1.79s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.62s  Non-interacting
   1        0       1        0.31     52.5   1.53s
   2        0       2       -0.52     47.0   1.32s
   3        0       3       -2.40     41.8   1.20s
   4        0       4       -4.46     29.7   933ms
   5        0       5       -6.46     17.4   680ms
   6        0       6       -8.91      4.0   413ms
   7        1       1       -7.87     55.4   1.80s  Restart
   8        1       2       -9.14      5.6   457ms
                                      72.8   1.75s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.60s  Non-interacting
   1        0       1        0.31     52.5   1.50s
   2        0       2       -0.52     47.0   2.77s
   3        0       3       -2.40     41.8   1.37s
   4        0       4       -4.46     29.7   897ms
   5        0       5       -6.46     17.4   687ms
   6        0       6       -8.91      4.0   413ms
   7        1       1       -7.86     55.4   1.81s  Restart
   8        1       2       -9.09      5.6   438ms
                                      72.8   1.77s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.60s  Non-interacting
   1        0       1        0.31     52.5   1.54s
   2        0       2       -0.52     47.0   1.31s
   3        0       3       -2.40     41.8   1.20s
   4        0       4       -4.46     29.7   957ms
   5        0       5       -6.46     17.4   692ms
   6        0       6       -8.91      4.0   418ms
   7        1       1       -7.86     55.4   1.83s  Restart
   8        1       2       -9.09      5.6   447ms
                                      72.8   1.76s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.62s  Non-interacting
   1        0       1        0.31     52.5   1.48s
   2        0       2       -0.52     47.0   1.29s
   3        0       3       -2.40     41.8   1.17s
   4        0       4       -4.46     29.7   933ms
   5        0       5       -6.46     17.4   674ms
   6        0       6       -8.91      4.0   406ms
   7        1       1       -7.86     55.4   1.77s  Restart
   8        1       2       -9.09      5.6   440ms
                                      72.9   1.74s  Final orbitals
 85.674790 seconds (101.37 M allocations: 80.356 GiB, 7.96% gc time, 8.68% compilation time: 100% of which was recompilation)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.003498155353756112
 -0.0029774511554444545
 -0.00297745115520175
  0.004302230637420741
  0.00430223063744881
  0.004353201766838269