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.916453300739                   -0.69    4.6    106ms
  2   -7.921210532563       -2.32       -1.52    1.0   54.4ms
  3   -7.921405952197       -3.71       -2.49    1.5   59.5ms
  4   -7.921440972127       -4.46       -2.83    2.5   86.4ms
  5   -7.921441649930       -6.17       -3.02    1.1   56.8ms
  6   -7.921442009221       -6.44       -4.58    1.1   56.1ms
  7   -7.921442021942       -7.90       -4.72    3.0   86.0ms
  8   -7.921442022133       -9.72       -5.47    1.0   55.6ms
  9   -7.921442022137      -11.50       -5.19    1.8   65.3ms
 10   -7.921442022144      -11.14       -6.17    1.0   67.3ms
 11   -7.921442022144      -12.60       -7.00    1.8   64.0ms
 12   -7.921442022144      -13.85       -7.19    2.1   71.4ms
 13   -7.921442022144   +  -14.75       -7.72    1.0   57.3ms
 14   -7.921442022144   +    -Inf       -8.09    1.2   60.7ms

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.43s  Non-interacting
   1        0       1        0.31     52.5   4.04s
   2        0       2       -0.52     46.9   1.59s
   3        0       3       -2.40     41.7   1.45s
   4        0       4       -4.46     29.7   1.14s
   5        0       5       -6.46     17.5   791ms
   6        0       6       -8.91      4.0   442ms
   7        1       1       -7.80     56.0   2.22s  Restart
   8        1       2       -8.74      5.7   1.98s
                                      72.8   2.19s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.91s  Non-interacting
   1        0       1        0.31     52.5   1.80s
   2        0       2       -0.52     46.9   1.57s
   3        0       3       -2.40     41.7   1.45s
   4        0       4       -4.46     29.7   1.11s
   5        0       5       -6.46     17.5   796ms
   6        0       6       -8.91      4.0   439ms
   7        1       1       -7.80     56.0   2.14s  Restart
   8        1       2       -8.74      5.7   481ms
                                      72.8   2.16s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   2.00s  Non-interacting
   1        0       1        0.31     52.5   1.83s
   2        0       2       -0.52     46.9   1.60s
   3        0       3       -2.40     41.7   1.43s
   4        0       4       -4.46     29.7   1.13s
   5        0       5       -6.46     17.5   816ms
   6        0       6       -8.91      4.0   442ms
   7        1       1       -7.80     56.0   2.15s  Restart
   8        1       2       -8.74      5.7   478ms
                                      72.8   2.13s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.97s  Non-interacting
   1        0       1        0.31     52.5   1.81s
   2        0       2       -0.52     46.9   1.58s
   3        0       3       -2.40     41.7   1.43s
   4        0       4       -4.46     29.7   1.13s
   5        0       5       -6.46     17.5   801ms
   6        0       6       -8.91      4.0   435ms
   7        1       1       -7.80     56.0   2.16s  Restart
   8        1       2       -8.75      5.7   494ms
                                      72.8   3.54s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.87s  Non-interacting
   1        0       1        0.31     52.5   1.79s
   2        0       2       -0.52     46.9   1.55s
   3        0       3       -2.40     41.7   1.41s
   4        0       4       -4.46     29.7   1.10s
   5        0       5       -6.46     17.5   786ms
   6        0       6       -8.91      4.0   428ms
   7        1       1       -7.80     56.0   2.12s  Restart
   8        1       2       -8.75      5.7   501ms
                                      72.8   2.10s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.96s  Non-interacting
   1        0       1        0.31     52.5   1.81s
   2        0       2       -0.52     46.9   1.59s
   3        0       3       -2.40     41.7   1.43s
   4        0       4       -4.46     29.7   1.12s
   5        0       5       -6.46     17.5   795ms
   6        0       6       -8.91      4.0   445ms
   7        1       1       -7.80     56.0   2.14s  Restart
   8        1       2       -8.75      5.7   484ms
                                      72.8   2.10s  Final orbitals
100.357543 seconds (101.51 M allocations: 80.473 GiB, 8.22% gc time, 7.46% compilation time: 100% of which was recompilation)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.003498155353281487
 -0.00297745115099812
 -0.002977451150687266
  0.004302230622402073
  0.004302230622466645
  0.004353201755018048