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.916441061112                   -0.69    4.8    104ms
  2   -7.921206181712       -2.32       -1.52    1.0   53.6ms
  3   -7.921405805683       -3.70       -2.49    1.5   63.8ms
  4   -7.921440958137       -4.45       -2.84    2.5   72.9ms
  5   -7.921441632298       -6.17       -3.01    1.0   53.9ms
  6   -7.921442006933       -6.43       -4.51    1.1   55.2ms
  7   -7.921442021820       -7.83       -4.62    3.0   82.1ms
  8   -7.921442022130       -9.51       -5.26    1.0   60.7ms
  9   -7.921442022125   +  -11.36       -4.97    2.0   64.9ms
 10   -7.921442022143      -10.74       -5.83    1.0   54.5ms
 11   -7.921442022144      -12.08       -7.08    1.5   59.5ms
 12   -7.921442022144      -13.29       -6.62    2.9   84.5ms
 13   -7.921442022144      -14.10       -8.25    1.0   54.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   1.95s  Non-interacting
   1        0       1        0.31     52.4   2.23s
   2        0       2       -0.52     47.1   1.48s
   3        0       3       -2.40     41.7   1.34s
   4        0       4       -4.46     29.7   1.05s
   5        0       5       -6.46     17.4   750ms
   6        0       6       -8.91      4.0   422ms
   7        1       1       -7.85     55.5   2.01s  Restart
   8        1       2       -8.91      5.5   1.19s
                                      72.8   1.94s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.85s  Non-interacting
   1        0       1        0.31     52.4   1.72s
   2        0       2       -0.52     47.1   1.48s
   3        0       3       -2.40     41.7   1.35s
   4        0       4       -4.46     29.7   1.05s
   5        0       5       -6.46     17.4   750ms
   6        0       6       -8.91      4.0   417ms
   7        1       1       -7.85     55.5   2.02s  Restart
   8        1       2       -8.91      5.5   454ms
                                      72.8   1.98s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.83s  Non-interacting
   1        0       1        0.31     52.4   1.71s
   2        0       2       -0.52     47.1   1.47s
   3        0       3       -2.40     41.7   1.34s
   4        0       4       -4.46     29.7   1.06s
   5        0       5       -6.46     17.4   744ms
   6        0       6       -8.91      4.0   419ms
   7        1       1       -7.85     55.5   2.00s  Restart
   8        1       2       -8.91      5.5   453ms
                                      72.8   1.97s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   2.52s  Non-interacting
   1        0       1        0.31     52.4   1.68s
   2        0       2       -0.52     47.1   1.47s
   3        0       3       -2.40     41.7   1.34s
   4        0       4       -4.46     29.7   1.05s
   5        0       5       -6.46     17.4   746ms
   6        0       6       -8.91      4.0   422ms
   7        1       1       -7.85     55.5   2.02s  Restart
   8        1       2       -8.91      5.5   457ms
                                      72.8   1.99s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.84s  Non-interacting
   1        0       1        0.31     52.4   1.70s
   2        0       2       -0.52     47.1   1.46s
   3        0       3       -2.40     41.7   1.33s
   4        0       4       -4.46     29.7   1.05s
   5        0       5       -6.46     17.4   738ms
   6        0       6       -8.91      4.0   416ms
   7        1       1       -7.85     55.5   2.00s  Restart
   8        1       2       -8.91      5.5   449ms
                                      72.8   1.96s  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.68s
   2        0       2       -0.52     47.1   1.45s
   3        0       3       -2.40     41.7   2.04s
   4        0       4       -4.46     29.7   1.01s
   5        0       5       -6.46     17.4   746ms
   6        0       6       -8.91      4.0   419ms
   7        1       1       -7.85     55.5   2.00s  Restart
   8        1       2       -8.91      5.5   450ms
                                      72.7   1.98s  Final orbitals
 87.884219 seconds (91.77 M allocations: 79.895 GiB, 7.28% gc time, 1.18% compilation time: 100% of which was recompilation)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.0034981553767579996
 -0.0029774511810795505
 -0.002977451180827274
  0.004302230609488668
  0.004302230610278128
  0.0043532017382408895