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.916428963766                   -0.69    4.9    112ms
  2   -7.921206146301       -2.32       -1.52    1.0   55.3ms
  3   -7.921405441312       -3.70       -2.49    1.4   57.5ms
  4   -7.921440942806       -4.45       -2.83    2.5   74.1ms
  5   -7.921441604380       -6.18       -2.98    1.1   54.5ms
  6   -7.921442007858       -6.39       -4.51    1.0   53.1ms
  7   -7.921442021677       -7.86       -4.54    2.8   90.9ms
  8   -7.921442022125       -9.35       -5.35    1.0   54.2ms
  9   -7.921442022143      -10.74       -5.98    1.6   61.3ms
 10   -7.921442022144      -12.18       -6.13    1.6   62.6ms
 11   -7.921442022144      -12.63       -6.91    1.0   54.6ms
 12   -7.921442022144      -13.97       -7.17    1.6   62.0ms
 13   -7.921442022144   +    -Inf       -7.87    1.0   64.3ms
 14   -7.921442022144   +  -14.75       -8.13    1.6   62.8ms

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.01s  Non-interacting
   1        0       1        0.31     52.4   3.69s
   2        0       2       -0.52     46.9   1.29s
   3        0       3       -2.40     41.6   1.20s
   4        0       4       -4.46     29.6   938ms
   5        0       5       -6.46     17.4   678ms
   6        0       6       -8.91      4.0   412ms
   7        1       1       -7.80     55.7   1.87s  Restart
   8        1       2       -8.83      5.7   469ms
                                      72.7   1.74s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.58s  Non-interacting
   1        0       1        0.31     52.4   1.53s
   2        0       2       -0.52     46.9   1.31s
   3        0       3       -2.40     41.6   1.19s
   4        0       4       -4.46     29.6   950ms
   5        0       5       -6.46     17.4   699ms
   6        0       6       -8.91      4.0   416ms
   7        1       1       -7.80     55.7   3.37s  Restart
   8        1       2       -8.83      5.7   412ms
                                      72.7   1.66s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.56s  Non-interacting
   1        0       1        0.31     52.4   1.49s
   2        0       2       -0.52     46.9   1.30s
   3        0       3       -2.40     41.6   1.18s
   4        0       4       -4.46     29.6   937ms
   5        0       5       -6.46     17.4   690ms
   6        0       6       -8.91      4.0   399ms
   7        1       1       -7.80     55.7   1.79s  Restart
   8        1       2       -8.83      5.7   446ms
                                      72.7   1.71s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.59s  Non-interacting
   1        0       1        0.31     52.4   1.51s
   2        0       2       -0.52     46.9   1.30s
   3        0       3       -2.40     41.6   1.20s
   4        0       4       -4.46     29.6   964ms
   5        0       5       -6.46     17.4   698ms
   6        0       6       -8.91      4.0   414ms
   7        1       1       -7.79     55.7   1.85s  Restart
   8        1       2       -8.84      5.7   464ms
                                      72.7   1.76s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.59s  Non-interacting
   1        0       1        0.31     52.4   1.52s
   2        0       2       -0.52     46.9   1.33s
   3        0       3       -2.40     41.6   1.20s
   4        0       4       -4.46     29.6   984ms
   5        0       5       -6.46     17.4   693ms
   6        0       6       -8.91      4.0   415ms
   7        1       1       -7.79     55.7   1.83s  Restart
   8        1       2       -8.84      5.7   456ms
                                      72.7   1.76s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.60s  Non-interacting
   1        0       1        0.31     52.4   1.52s
   2        0       2       -0.52     46.9   1.32s
   3        0       3       -2.40     41.6   1.21s
   4        0       4       -4.46     29.6   2.37s
   5        0       5       -6.46     17.4   859ms
   6        0       6       -8.91      4.0   433ms
   7        1       1       -7.79     55.7   1.77s  Restart
   8        1       2       -8.84      5.7   434ms
                                      72.7   1.71s  Final orbitals
 86.169771 seconds (101.21 M allocations: 80.243 GiB, 8.53% gc time, 7.77% compilation time: 100% of which was recompilation)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.003498155362030899
 -0.002977451160266179
 -0.0029774511600920454
  0.004302230615404216
  0.004302230615706432
  0.004353201747680393