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.916428216966                   -0.69    5.1    109ms
  2   -7.921204833581       -2.32       -1.52    1.0   53.6ms
  3   -7.921404426437       -3.70       -2.49    1.4   56.7ms
  4   -7.921440913583       -4.44       -2.82    2.8   76.0ms
  5   -7.921441575019       -6.18       -2.97    1.1   66.6ms
  6   -7.921442007863       -6.36       -4.51    1.0   54.3ms
  7   -7.921442021779       -7.86       -4.58    2.9   83.2ms
  8   -7.921442022127       -9.46       -5.21    1.0   54.4ms
  9   -7.921442022142      -10.84       -5.69    1.4   58.4ms
 10   -7.921442022144      -11.74       -5.92    1.1   55.6ms
 11   -7.921442022144      -12.42       -6.55    1.1   56.4ms
 12   -7.921442022144      -13.26       -7.39    1.8   76.3ms
 13   -7.921442022144      -14.75       -7.47    2.1   70.6ms
 14   -7.921442022144   +    -Inf       -8.15    1.0   55.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   2.05s  Non-interacting
   1        0       1        0.31     52.7   3.91s
   2        0       2       -0.52     47.2   1.30s
   3        0       3       -2.40     41.8   1.19s
   4        0       4       -4.46     30.0   2.36s
   5        0       5       -6.46     17.6   776ms
   6        0       6       -8.92      4.0   420ms
   7        1       1       -7.86     55.7   1.79s  Restart
   8        1       2       -8.97      5.5   451ms
                                      72.9   1.71s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.58s  Non-interacting
   1        0       1        0.31     52.7   1.54s
   2        0       2       -0.52     47.2   1.31s
   3        0       3       -2.40     41.8   1.21s
   4        0       4       -4.46     30.0   954ms
   5        0       5       -6.46     17.6   710ms
   6        0       6       -8.92      4.0   404ms
   7        1       1       -7.86     55.7   1.91s  Restart
   8        1       2       -8.97      5.5   452ms
                                      72.9   1.82s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.68s  Non-interacting
   1        0       1        0.31     52.7   1.59s
   2        0       2       -0.52     47.2   1.36s
   3        0       3       -2.40     41.8   1.24s
   4        0       4       -4.46     30.0   991ms
   5        0       5       -6.46     17.6   707ms
   6        0       6       -8.92      4.0   420ms
   7        1       1       -7.86     55.7   1.89s  Restart
   8        1       2       -8.97      5.5   445ms
                                      72.9   1.81s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.64s  Non-interacting
   1        0       1        0.31     52.7   1.58s
   2        0       2       -0.52     47.2   1.34s
   3        0       3       -2.40     41.8   1.22s
   4        0       4       -4.46     30.0   976ms
   5        0       5       -6.46     17.5   716ms
   6        0       6       -8.92      4.0   422ms
   7        1       1       -7.85     55.7   1.87s  Restart
   8        1       2       -9.02      5.5   450ms
                                      72.9   1.80s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.62s  Non-interacting
   1        0       1        0.31     52.7   1.56s
   2        0       2       -0.52     47.2   2.85s
   3        0       3       -2.40     41.8   1.19s
   4        0       4       -4.46     30.0   929ms
   5        0       5       -6.46     17.5   675ms
   6        0       6       -8.92      4.0   414ms
   7        1       1       -7.85     55.7   1.83s  Restart
   8        1       2       -9.02      5.5   444ms
                                      72.9   1.74s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.59s  Non-interacting
   1        0       1        0.31     52.7   1.53s
   2        0       2       -0.52     47.2   1.32s
   3        0       3       -2.40     41.8   1.21s
   4        0       4       -4.46     30.0   963ms
   5        0       5       -6.46     17.5   692ms
   6        0       6       -8.92      4.0   415ms
   7        1       1       -7.85     55.7   1.84s  Restart
   8        1       2       -9.02      5.5   442ms
                                      72.9   1.80s  Final orbitals
 88.812998 seconds (101.47 M allocations: 80.490 GiB, 9.70% gc time, 8.86% compilation time: 100% of which was recompilation)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.0034981553636715262
 -0.002977451164211976
 -0.002977451163924873
  0.004302230616714109
  0.0043022306167319405
  0.004353201747521175