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.916402576079                   -0.69    4.8    113ms
  2   -7.921196023968       -2.32       -1.52    1.0   63.8ms
  3   -7.921401835675       -3.69       -2.49    1.4   65.2ms
  4   -7.921440886991       -4.41       -2.81    2.4   86.5ms
  5   -7.921441537718       -6.19       -2.95    1.1   59.7ms
  6   -7.921442007059       -6.33       -4.39    1.0   75.0ms
  7   -7.921442021647       -7.84       -4.54    2.5   84.7ms
  8   -7.921442022124       -9.32       -5.27    1.0   59.4ms
  9   -7.921442022143      -10.74       -5.92    1.9   69.7ms
 10   -7.921442022144      -11.87       -5.96    2.0   73.3ms
 11   -7.921442022144      -12.54       -7.17    1.0   59.5ms
 12   -7.921442022144      -13.91       -7.19    2.5   82.8ms
 13   -7.921442022144      -15.05       -7.66    1.0   60.6ms
 14   -7.921442022144   +  -15.05       -9.51    1.0   60.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.04s  Non-interacting
   1        0       1        0.31     52.6   3.78s
   2        0       2       -0.52     47.2   1.33s
   3        0       3       -2.40     41.9   1.23s
   4        0       4       -4.46     30.0   1.02s
   5        0       5       -6.46     17.6   718ms
   6        0       6       -8.91      4.0   439ms
   7        1       1       -7.86     55.6   1.91s  Restart
   8        1       2       -9.22      5.6   465ms
                                      72.8   1.76s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.60s  Non-interacting
   1        0       1        0.31     52.6   1.54s
   2        0       2       -0.52     47.2   1.34s
   3        0       3       -2.40     41.9   1.25s
   4        0       4       -4.46     30.0   985ms
   5        0       5       -6.46     17.6   717ms
   6        0       6       -8.91      4.0   424ms
   7        1       1       -7.86     55.6   1.89s  Restart
   8        1       2       -9.22      5.6   467ms
                                      72.8   1.79s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.64s  Non-interacting
   1        0       1        0.31     52.6   1.58s
   2        0       2       -0.52     47.2   1.34s
   3        0       3       -2.40     41.9   1.23s
   4        0       4       -4.46     30.0   996ms
   5        0       5       -6.46     17.6   715ms
   6        0       6       -8.91      4.0   426ms
   7        1       1       -7.86     55.6   1.87s  Restart
   8        1       2       -9.22      5.6   460ms
                                      72.8   1.79s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.65s  Non-interacting
   1        0       1        0.31     52.6   2.90s
   2        0       2       -0.52     47.2   1.39s
   3        0       3       -2.40     41.9   1.19s
   4        0       4       -4.46     30.0   962ms
   5        0       5       -6.46     17.6   709ms
   6        0       6       -8.91      4.0   434ms
   7        1       1       -7.90     55.4   1.86s  Restart
   8        1       2       -9.27      5.5   460ms
                                      72.8   1.75s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.60s  Non-interacting
   1        0       1        0.31     52.6   1.55s
   2        0       2       -0.52     47.2   1.35s
   3        0       3       -2.40     41.9   1.22s
   4        0       4       -4.46     30.0   979ms
   5        0       5       -6.46     17.6   712ms
   6        0       6       -8.91      4.0   414ms
   7        1       1       -7.90     55.4   1.83s  Restart
   8        1       2       -9.27      5.5   454ms
                                      72.8   1.75s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.61s  Non-interacting
   1        0       1        0.31     52.6   1.54s
   2        0       2       -0.52     47.2   1.38s
   3        0       3       -2.40     41.9   1.25s
   4        0       4       -4.46     30.0   964ms
   5        0       5       -6.46     17.6   705ms
   6        0       6       -8.91      4.0   428ms
   7        1       1       -7.90     55.4   1.84s  Restart
   8        1       2       -9.27      5.5   451ms
                                      72.8   1.76s  Final orbitals
 87.032570 seconds (101.48 M allocations: 80.478 GiB, 6.86% gc time, 8.61% compilation time: 100% of which was recompilation)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.003498155358367355
 -0.002977451159900199
 -0.0029774511597451814
  0.004302230631246928
  0.004302230631581521
  0.004353201760972836