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.916437099022                   -0.69    4.5    102ms
  2   -7.921209419540       -2.32       -1.52    1.0   57.8ms
  3   -7.921405232816       -3.71       -2.49    1.4   62.5ms
  4   -7.921440943449       -4.45       -2.82    2.6   84.3ms
  5   -7.921441628238       -6.16       -3.00    1.1   53.4ms
  6   -7.921442006616       -6.42       -4.52    1.0   52.6ms
  7   -7.921442021705       -7.82       -4.53    2.9   78.3ms
  8   -7.921442022119       -9.38       -5.16    1.0   52.7ms
  9   -7.921442022140      -10.69       -5.42    1.2   55.2ms
 10   -7.921442022143      -11.48       -5.81    1.2   55.1ms
 11   -7.921442022144      -12.03       -6.42    1.1   54.9ms
 12   -7.921442022144      -13.04       -7.09    2.0   63.9ms
 13   -7.921442022144      -14.45       -7.35    1.9   63.9ms
 14   -7.921442022144      -15.05       -7.97    1.2   58.3ms
 15   -7.921442022144   +  -15.05       -8.66    1.9   63.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   1.94s  Non-interacting
   1        0       1        0.31     52.3   2.21s
   2        0       2       -0.52     47.0   1.47s
   3        0       3       -2.40     41.7   1.33s
   4        0       4       -4.46     29.6   1.03s
   5        0       5       -6.46     17.4   740ms
   6        0       6       -8.91      4.0   425ms
   7        1       1       -7.80     55.8   1.98s  Restart
   8        1       2       -8.81      5.7   456ms
                                      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.3   1.68s
   2        0       2       -0.52     47.0   1.47s
   3        0       3       -2.40     41.7   1.33s
   4        0       4       -4.46     29.6   1.04s
   5        0       5       -6.46     17.4   747ms
   6        0       6       -8.91      4.0   468ms
   7        1       1       -7.80     55.8   2.66s  Restart
   8        1       2       -8.81      5.7   444ms
                                      72.7   1.99s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.85s  Non-interacting
   1        0       1        0.31     52.3   1.72s
   2        0       2       -0.52     47.0   1.51s
   3        0       3       -2.40     41.7   1.36s
   4        0       4       -4.46     29.6   1.05s
   5        0       5       -6.46     17.4   759ms
   6        0       6       -8.91      4.0   441ms
   7        1       1       -7.80     55.8   2.02s  Restart
   8        1       2       -8.81      5.7   469ms
                                      72.8   2.02s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.84s  Non-interacting
   1        0       1        0.31     52.3   1.71s
   2        0       2       -0.52     47.0   1.48s
   3        0       3       -2.40     41.7   1.35s
   4        0       4       -4.46     29.6   1.04s
   5        0       5       -6.46     17.4   759ms
   6        0       6       -8.91      4.0   434ms
   7        1       1       -7.81     55.6   2.00s  Restart
   8        1       2       -8.86      5.7   456ms
                                      72.7   2.61s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.84s  Non-interacting
   1        0       1        0.31     52.3   1.69s
   2        0       2       -0.52     47.0   1.47s
   3        0       3       -2.40     41.7   1.33s
   4        0       4       -4.46     29.6   1.04s
   5        0       5       -6.46     17.4   755ms
   6        0       6       -8.91      4.0   417ms
   7        1       1       -7.81     55.6   1.99s  Restart
   8        1       2       -8.86      5.7   458ms
                                      72.8   2.00s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.84s  Non-interacting
   1        0       1        0.31     52.3   1.70s
   2        0       2       -0.52     47.0   1.47s
   3        0       3       -2.40     41.7   1.35s
   4        0       4       -4.46     29.6   1.03s
   5        0       5       -6.46     17.4   736ms
   6        0       6       -8.91      4.0   411ms
   7        1       1       -7.81     55.6   2.00s  Restart
   8        1       2       -8.86      5.7   454ms
                                      72.8   1.95s  Final orbitals
 87.863349 seconds (92.44 M allocations: 79.929 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.0034981553547732895
 -0.002977451156053137
 -0.002977451155832413
  0.004302230635489251
  0.00430223063565305
  0.0043532017650495395