Phonon computations

This is a quick sketch how to run a simple phonon calculation using DFTK. 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.916463056860                   -0.69    4.9    106ms
  2   -7.921210017892       -2.32       -1.52    1.0   53.9ms
  3   -7.921405585055       -3.71       -2.49    1.2   56.7ms
  4   -7.921440931071       -4.45       -2.84    2.5   74.3ms
  5   -7.921441632834       -6.15       -3.01    1.1   55.8ms
  6   -7.921442006013       -6.43       -4.44    1.0   55.4ms
  7   -7.921442021815       -7.80       -4.64    2.8   89.8ms
  8   -7.921442022124       -9.51       -5.23    1.0   55.8ms
  9   -7.921442022126      -11.95       -4.94    1.9   65.7ms
 10   -7.921442022143      -10.75       -5.86    1.0   55.8ms
 11   -7.921442022144      -12.13       -6.88    1.4   59.6ms
 12   -7.921442022144      -13.37       -6.81    2.6   84.7ms
 13   -7.921442022144      -14.10       -7.24    1.0   55.2ms
 14   -7.921442022144   +  -14.35       -7.87    1.0   56.6ms
 15   -7.921442022144      -14.75       -8.98    1.1   64.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.0   2.02s  Non-interacting
   1        0       1        0.31     52.3   2.39s
   2        0       2       -0.52     47.0   1.54s
   3        0       3       -2.40     41.7   1.43s
   4        0       4       -4.46     29.7   1.98s
   5        0       5       -6.46     17.4   760ms
   6        0       6       -8.91      4.0   427ms
   7        1       1       -7.83     55.7   2.05s  Restart
   8        1       2       -8.84      5.6   527ms
                                      72.8   2.11s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.96s  Non-interacting
   1        0       1        0.31     52.3   1.78s
   2        0       2       -0.52     47.0   1.52s
   3        0       3       -2.40     41.7   1.37s
   4        0       4       -4.46     29.7   1.11s
   5        0       5       -6.46     17.4   765ms
   6        0       6       -8.91      4.0   430ms
   7        1       1       -7.83     55.7   2.12s  Restart
   8        1       2       -8.84      5.6   466ms
                                      72.8   2.09s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.94s  Non-interacting
   1        0       1        0.31     52.3   1.78s
   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.09s
   5        0       5       -6.46     17.4   1.67s
   6        0       6       -8.91      4.0   462ms
   7        1       1       -7.83     55.7   2.01s  Restart
   8        1       2       -8.84      5.6   469ms
                                      72.8   2.14s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.95s  Non-interacting
   1        0       1        0.31     52.4   1.79s
   2        0       2       -0.52     47.0   1.53s
   3        0       3       -2.40     41.7   1.46s
   4        0       4       -4.46     29.7   1.11s
   5        0       5       -6.46     17.4   821ms
   6        0       6       -8.91      4.0   439ms
   7        1       1       -7.83     55.7   2.12s  Restart
   8        1       2       -8.84      5.6   468ms
                                      72.8   2.07s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.93s  Non-interacting
   1        0       1        0.31     52.4   1.77s
   2        0       2       -0.52     47.0   1.61s
   3        0       3       -2.40     41.7   1.43s
   4        0       4       -4.46     29.7   1.07s
   5        0       5       -6.46     17.4   1.65s
   6        0       6       -8.91      4.0   391ms
   7        1       1       -7.83     55.7   1.99s  Restart
   8        1       2       -8.84      5.6   452ms
                                      72.8   2.00s  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.69s
   2        0       2       -0.52     47.0   1.47s
   3        0       3       -2.40     41.7   1.37s
   4        0       4       -4.46     29.7   1.04s
   5        0       5       -6.46     17.4   747ms
   6        0       6       -8.91      4.0   413ms
   7        1       1       -7.83     55.7   2.00s  Restart
   8        1       2       -8.84      5.6   453ms
                                      72.8   1.98s  Final orbitals
 91.678301 seconds (92.55 M allocations: 80.307 GiB, 8.34% gc time, 1.24% compilation time: 100% of which was recompilation)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.0034981553566071073
 -0.0029774511571575963
 -0.0029774511568780564
  0.0043022306305581575
  0.004302230630641481
  0.004353201760953733
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.