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.916466529626                   -0.69    4.9    114ms
  2   -7.921211961042       -2.32       -1.52    1.0   56.5ms
  3   -7.921407357331       -3.71       -2.49    1.4   72.3ms
  4   -7.921441045493       -4.47       -2.83    2.6   80.8ms
  5   -7.921441690942       -6.19       -3.04    1.1   58.8ms
  6   -7.921442010310       -6.50       -4.57    1.0   56.8ms
  7   -7.921442021824       -7.94       -4.61    2.9   88.3ms
  8   -7.921442022125       -9.52       -5.27    1.0   58.0ms
  9   -7.921442022142      -10.77       -5.53    1.5   76.2ms
 10   -7.921442022144      -11.67       -6.17    1.4   62.8ms
 11   -7.921442022144      -12.47       -6.55    1.5   62.9ms
 12   -7.921442022144      -13.59       -6.94    1.4   59.8ms
 13   -7.921442022144      -14.15       -7.33    1.9   66.7ms
 14   -7.921442022144      -14.75       -7.97    1.5   63.9ms
 15   -7.921442022144   +  -14.75       -9.01    1.8   75.9ms

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.34s  Non-interacting
   1        0       1        0.31     52.4   3.88s
   2        0       2       -0.52     47.0   1.55s
   3        0       3       -2.40     41.7   1.38s
   4        0       4       -4.46     29.7   2.40s
   5        0       5       -6.46     17.4   743ms
   6        0       6       -8.91      4.0   530ms
   7        1       1       -7.79     55.9   2.06s  Restart
   8        1       2       -8.79      5.7   472ms
                                      72.8   2.07s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.92s  Non-interacting
   1        0       1        0.31     52.4   1.77s
   2        0       2       -0.52     47.0   1.54s
   3        0       3       -2.40     41.7   1.38s
   4        0       4       -4.46     29.7   1.09s
   5        0       5       -6.46     17.4   779ms
   6        0       6       -8.91      4.0   432ms
   7        1       1       -7.79     55.9   2.07s  Restart
   8        1       2       -8.79      5.7   461ms
                                      72.8   2.03s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.91s  Non-interacting
   1        0       1        0.31     52.4   1.75s
   2        0       2       -0.52     47.0   1.51s
   3        0       3       -2.40     41.7   1.37s
   4        0       4       -4.46     29.7   1.08s
   5        0       5       -6.46     17.4   768ms
   6        0       6       -8.91      4.0   417ms
   7        1       1       -7.79     55.9   2.08s  Restart
   8        1       2       -8.79      5.7   467ms
                                      72.8   2.06s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.92s  Non-interacting
   1        0       1        0.31     52.4   1.76s
   2        0       2       -0.52     47.0   1.52s
   3        0       3       -2.40     41.7   1.39s
   4        0       4       -4.46     29.7   1.07s
   5        0       5       -6.46     17.4   762ms
   6        0       6       -8.91      4.0   414ms
   7        1       1       -7.79     55.9   2.07s  Restart
   8        1       2       -8.79      5.7   464ms
                                      72.7   3.67s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.89s  Non-interacting
   1        0       1        0.31     52.4   1.77s
   2        0       2       -0.52     47.0   1.54s
   3        0       3       -2.40     41.7   1.40s
   4        0       4       -4.46     29.7   1.10s
   5        0       5       -6.46     17.4   777ms
   6        0       6       -8.91      4.0   431ms
   7        1       1       -7.79     55.9   2.08s  Restart
   8        1       2       -8.79      5.7   476ms
                                      72.8   2.05s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.92s  Non-interacting
   1        0       1        0.31     52.4   1.76s
   2        0       2       -0.52     47.0   1.53s
   3        0       3       -2.40     41.7   1.38s
   4        0       4       -4.46     29.7   1.09s
   5        0       5       -6.46     17.4   775ms
   6        0       6       -8.91      4.0   431ms
   7        1       1       -7.79     55.9   2.08s  Restart
   8        1       2       -8.79      5.7   479ms
                                      72.8   2.06s  Final orbitals
 97.427161 seconds (101.39 M allocations: 80.348 GiB, 7.55% gc time, 7.34% compilation time: 100% of which was recompilation)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.0034981553545630185
 -0.0029774511563761966
 -0.002977451156077501
  0.004302230636694282
  0.004302230636942272
  0.004353201765856324