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.916405435282                   -0.69    4.8    117ms
  2   -7.921197646033       -2.32       -1.52    1.0   76.2ms
  3   -7.921403437948       -3.69       -2.49    1.4   64.7ms
  4   -7.921440935434       -4.43       -2.82    2.4   81.6ms
  5   -7.921441596058       -6.18       -2.99    1.1   60.4ms
  6   -7.921442006529       -6.39       -4.41    1.0   58.9ms
  7   -7.921442021833       -7.82       -4.63    2.5   85.4ms
  8   -7.921442022131       -9.52       -5.31    1.0   60.0ms
  9   -7.921442022137      -11.29       -5.21    1.8   68.5ms
 10   -7.921442022144      -11.14       -6.01    1.0   77.9ms
 11   -7.921442022144      -12.42       -6.82    1.4   65.0ms
 12   -7.921442022144      -13.45       -7.30    2.1   75.1ms
 13   -7.921442022144   +    -Inf       -7.69    1.2   62.9ms
 14   -7.921442022144      -15.05       -8.32    1.4   65.5ms

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.22s  Non-interacting
   1        0       1        0.31     52.7   3.57s
   2        0       2       -0.52     47.2   1.54s
   3        0       3       -2.40     41.8   1.39s
   4        0       4       -4.46     29.9   1.11s
   5        0       5       -6.46     17.5   787ms
   6        0       6       -8.92      4.0   446ms
   7        1       1       -7.88     55.6   2.15s  Restart
   8        1       2       -9.15      5.5   669ms
                                      72.9   3.49s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.86s  Non-interacting
   1        0       1        0.31     52.7   1.77s
   2        0       2       -0.52     47.2   1.56s
   3        0       3       -2.40     41.8   1.42s
   4        0       4       -4.46     29.9   1.11s
   5        0       5       -6.46     17.5   815ms
   6        0       6       -8.92      4.0   456ms
   7        1       1       -7.88     55.6   2.10s  Restart
   8        1       2       -9.15      5.5   490ms
                                      72.9   2.04s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   2.00s  Non-interacting
   1        0       1        0.31     52.7   1.80s
   2        0       2       -0.52     47.2   1.57s
   3        0       3       -2.40     41.8   1.42s
   4        0       4       -4.46     29.9   1.12s
   5        0       5       -6.46     17.5   796ms
   6        0       6       -8.92      4.0   446ms
   7        1       1       -7.88     55.6   2.13s  Restart
   8        1       2       -9.15      5.5   501ms
                                      72.9   2.10s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.1   1.92s  Non-interacting
   1        0       1        0.31     52.7   1.76s
   2        0       2       -0.52     47.2   1.53s
   3        0       3       -2.40     41.8   1.42s
   4        0       4       -4.46     29.9   1.12s
   5        0       5       -6.46     17.5   808ms
   6        0       6       -8.92      4.0   453ms
   7        1       1       -7.87     55.7   2.09s  Restart
   8        1       2       -9.08      5.5   492ms
                                      72.9   2.05s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.93s  Non-interacting
   1        0       1        0.31     52.7   1.77s
   2        0       2       -0.52     47.2   1.53s
   3        0       3       -2.40     41.8   1.41s
   4        0       4       -4.46     29.9   1.09s
   5        0       5       -6.46     17.5   794ms
   6        0       6       -8.92      4.0   454ms
   7        1       1       -7.87     55.7   2.08s  Restart
   8        1       2       -9.08      5.5   665ms
                                      72.9   3.46s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.85s  Non-interacting
   1        0       1        0.31     52.7   1.82s
   2        0       2       -0.52     47.2   1.57s
   3        0       3       -2.40     41.8   1.42s
   4        0       4       -4.46     29.9   1.11s
   5        0       5       -6.46     17.5   812ms
   6        0       6       -8.92      4.0   456ms
   7        1       1       -7.87     55.7   2.11s  Restart
   8        1       2       -9.08      5.5   483ms
                                      72.9   2.04s  Final orbitals
 98.263860 seconds (101.45 M allocations: 80.492 GiB, 10.28% gc time, 6.26% compilation time: 100% of which was recompilation)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.003498155354127892
 -0.0029774511524706753
 -0.0029774511524324116
  0.0043022306246891205
  0.00430223062506777
  0.004353201756956134