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.916446916728                   -0.69    4.8    101ms
  2   -7.921208108816       -2.32       -1.52    1.0   57.6ms
  3   -7.921407099179       -3.70       -2.49    1.2   55.1ms
  4   -7.921440896390       -4.47       -2.83    2.6   72.7ms
  5   -7.921441676517       -6.11       -3.05    1.1   53.9ms
  6   -7.921442008256       -6.48       -4.52    1.1   59.2ms
  7   -7.921442021879       -7.87       -4.66    2.9   79.6ms
  8   -7.921442022136       -9.59       -5.34    1.1   54.3ms
  9   -7.921442022142      -11.25       -5.61    1.4   57.4ms
 10   -7.921442022144      -11.63       -6.15    1.0   59.2ms
 11   -7.921442022144      -12.67       -6.71    1.6   60.5ms
 12   -7.921442022144      -13.62       -7.64    1.9   64.3ms
 13   -7.921442022144      -14.75       -7.87    2.1   71.3ms
 14   -7.921442022144      -14.75       -8.97    1.0   60.1ms

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.1   1.98s  Non-interacting
   1        0       1        0.31     52.8   2.22s
   2        0       2       -0.52     47.2   1.47s
   3        0       3       -2.40     41.9   1.33s
   4        0       4       -4.46     30.0   1.04s
   5        0       5       -6.46     17.5   735ms
   6        0       6       -8.92      4.0   416ms
   7        1       1       -7.83     55.9   2.00s  Restart
   8        1       2       -9.04      5.5   454ms
                                      72.9   1.99s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.86s  Non-interacting
   1        0       1        0.31     52.8   1.73s
   2        0       2       -0.52     47.2   1.53s
   3        0       3       -2.40     41.9   1.36s
   4        0       4       -4.46     30.0   1.06s
   5        0       5       -6.46     17.5   747ms
   6        0       6       -8.92      4.0   419ms
   7        1       1       -7.83     55.9   2.02s  Restart
   8        1       2       -9.04      5.5   449ms
                                      72.9   2.00s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.85s  Non-interacting
   1        0       1        0.31     52.8   2.59s
   2        0       2       -0.52     47.2   1.47s
   3        0       3       -2.40     41.9   1.34s
   4        0       4       -4.46     30.0   1.05s
   5        0       5       -6.46     17.5   751ms
   6        0       6       -8.92      4.0   411ms
   7        1       1       -7.83     55.9   2.00s  Restart
   8        1       2       -9.04      5.5   450ms
                                      72.8   1.96s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.1   1.83s  Non-interacting
   1        0       1        0.31     52.8   1.70s
   2        0       2       -0.52     47.2   1.47s
   3        0       3       -2.40     41.9   1.34s
   4        0       4       -4.46     29.9   1.06s
   5        0       5       -6.46     17.5   737ms
   6        0       6       -8.92      4.0   443ms
   7        1       1       -7.86     55.8   1.99s  Restart
   8        1       2       -9.01      5.5   444ms
                                      72.8   1.97s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.80s  Non-interacting
   1        0       1        0.31     52.8   1.68s
   2        0       2       -0.52     47.2   1.45s
   3        0       3       -2.40     41.9   2.10s
   4        0       4       -4.46     29.9   1.04s
   5        0       5       -6.46     17.5   748ms
   6        0       6       -8.92      4.0   416ms
   7        1       1       -7.86     55.8   1.99s  Restart
   8        1       2       -9.01      5.5   447ms
                                      72.9   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.8   1.70s
   2        0       2       -0.52     47.2   1.46s
   3        0       3       -2.40     41.9   1.33s
   4        0       4       -4.46     29.9   1.03s
   5        0       5       -6.46     17.5   726ms
   6        0       6       -8.92      4.0   408ms
   7        1       1       -7.86     55.8   2.00s  Restart
   8        1       2       -9.01      5.5   451ms
                                      72.8   1.95s  Final orbitals
 88.008628 seconds (92.54 M allocations: 80.118 GiB, 7.41% gc time, 1.21% compilation time: 100% of which was recompilation)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.0034981553586376987
 -0.002977451159967826
 -0.0029774511598599264
  0.004302230630658052
  0.004302230630775612
  0.0043532017611905135