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.916454152220                   -0.69    4.8    109ms
  2   -7.921208997004       -2.32       -1.52    1.0   52.5ms
  3   -7.921405199455       -3.71       -2.49    1.5   58.2ms
  4   -7.921440940362       -4.45       -2.83    2.5   73.5ms
  5   -7.921441594597       -6.18       -2.99    1.1   56.6ms
  6   -7.921442005989       -6.39       -4.48    1.0   57.6ms
  7   -7.921442021773       -7.80       -4.57    3.1   85.0ms
  8   -7.921442022128       -9.45       -5.22    1.0   54.1ms
  9   -7.921442022138      -10.96       -5.32    1.4   58.4ms
 10   -7.921442022144      -11.28       -5.96    1.0   59.4ms
 11   -7.921442022144      -12.40       -7.29    1.4   57.7ms
 12   -7.921442022144      -13.55       -6.79    2.9   81.9ms
 13   -7.921442022144      -14.27       -7.57    1.0   56.0ms
 14   -7.921442022144   +  -15.05       -8.36    1.1   68.6ms

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
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   2.59s  Non-interacting
   1        0       1        0.31     52.3   2.16s
   2        0       2       -0.52     46.9   1.45s
   3        0       3       -2.40     41.6   1.32s
   4        0       4       -4.46     29.6   1.02s
   5        0       5       -6.46     17.4   737ms
   6        0       6       -8.91      4.0   409ms
   7        1       1       -7.83     55.5   1.97s  Restart
   8        1       2       -8.89      5.6   454ms
                                      72.7   1.94s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.81s  Non-interacting
   1        0       1        0.31     52.3   1.67s
   2        0       2       -0.52     46.9   1.43s
   3        0       3       -2.40     41.6   1.30s
   4        0       4       -4.46     29.6   1.02s
   5        0       5       -6.46     17.4   731ms
   6        0       6       -8.91      4.0   415ms
   7        1       1       -7.83     55.5   1.95s  Restart
   8        1       2       -8.89      5.6   450ms
                                      72.7   1.94s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.79s  Non-interacting
   1        0       1        0.31     52.3   1.65s
   2        0       2       -0.52     46.9   2.12s
   3        0       3       -2.40     41.6   1.28s
   4        0       4       -4.46     29.6   1.03s
   5        0       5       -6.46     17.4   727ms
   6        0       6       -8.91      4.0   420ms
   7        1       1       -7.83     55.5   1.95s  Restart
   8        1       2       -8.89      5.6   447ms
                                      72.7   1.97s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.81s  Non-interacting
   1        0       1        0.31     52.3   1.66s
   2        0       2       -0.52     46.9   1.45s
   3        0       3       -2.40     41.6   1.32s
   4        0       4       -4.46     29.6   1.03s
   5        0       5       -6.46     17.4   729ms
   6        0       6       -8.91      4.0   412ms
   7        1       1       -7.83     55.5   1.96s  Restart
   8        1       2       -8.89      5.6   446ms
                                      72.7   1.95s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.80s  Non-interacting
   1        0       1        0.31     52.3   1.65s
   2        0       2       -0.52     46.9   1.42s
   3        0       3       -2.40     41.6   1.29s
   4        0       4       -4.46     29.6   1.70s
   5        0       5       -6.46     17.4   731ms
   6        0       6       -8.91      4.0   402ms
   7        1       1       -7.83     55.5   1.98s  Restart
   8        1       2       -8.89      5.6   459ms
                                      72.7   1.95s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.81s  Non-interacting
   1        0       1        0.31     52.3   1.66s
   2        0       2       -0.52     46.9   1.44s
   3        0       3       -2.40     41.6   1.30s
   4        0       4       -4.46     29.6   1.02s
   5        0       5       -6.46     17.4   733ms
   6        0       6       -8.91      4.0   408ms
   7        1       1       -7.83     55.5   1.96s  Restart
   8        1       2       -8.89      5.6   444ms
                                      72.7   1.94s  Final orbitals
 86.178965 seconds (92.51 M allocations: 80.234 GiB, 7.18% 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.0034981553549682243
 -0.0029774511578985054
 -0.002977451157775467
  0.004302230641911374
  0.004302230642162484
  0.004353201769536378