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.916350006263                   -0.69    4.9    119ms
  2   -7.921204959321       -2.31       -1.52    1.0   54.2ms
  3   -7.921408251064       -3.69       -2.49    1.5   59.8ms
  4   -7.921440990160       -4.48       -2.85    2.5   74.2ms
  5   -7.921441733877       -6.13       -3.10    1.1   55.5ms
  6   -7.921442009725       -6.56       -4.52    1.1   55.8ms
  7   -7.921442021923       -7.91       -4.70    3.0   83.8ms
  8   -7.921442022133       -9.68       -5.36    1.0   64.6ms
  9   -7.921442022142      -11.05       -5.48    1.6   62.4ms
 10   -7.921442022144      -11.65       -6.14    1.0   55.3ms
 11   -7.921442022144      -12.75       -7.16    1.4   59.8ms
 12   -7.921442022144      -13.71       -7.56    2.8   77.9ms
 13   -7.921442022144   +    -Inf       -8.56    1.4   60.5ms

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.94s  Non-interacting
   1        0       1        0.31     52.7   3.58s
   2        0       2       -0.52     47.2   1.31s
   3        0       3       -2.40     41.9   1.19s
   4        0       4       -4.46     29.9   936ms
   5        0       5       -6.46     17.6   708ms
   6        0       6       -8.91      4.0   411ms
   7        1       1       -7.84     55.7   1.84s  Restart
   8        1       2       -9.13      5.6   1.66s
                                      72.9   1.90s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.1   1.53s  Non-interacting
   1        0       1        0.31     52.7   1.49s
   2        0       2       -0.52     47.2   1.31s
   3        0       3       -2.40     41.9   1.18s
   4        0       4       -4.46     29.9   944ms
   5        0       5       -6.46     17.6   689ms
   6        0       6       -8.91      4.0   415ms
   7        1       1       -7.84     55.7   1.80s  Restart
   8        1       2       -9.13      5.6   452ms
                                      72.9   1.72s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.57s  Non-interacting
   1        0       1        0.31     52.7   1.51s
   2        0       2       -0.52     47.2   1.32s
   3        0       3       -2.40     41.9   1.20s
   4        0       4       -4.46     29.9   946ms
   5        0       5       -6.46     17.6   699ms
   6        0       6       -8.91      4.0   412ms
   7        1       1       -7.84     55.7   1.82s  Restart
   8        1       2       -9.13      5.6   439ms
                                      72.8   1.71s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.1   1.56s  Non-interacting
   1        0       1        0.31     52.7   1.60s
   2        0       2       -0.52     47.2   1.30s
   3        0       3       -2.40     41.9   1.19s
   4        0       4       -4.46     29.9   941ms
   5        0       5       -6.46     17.6   703ms
   6        0       6       -8.91      4.0   414ms
   7        1       1       -7.84     55.8   1.82s  Restart
   8        1       2       -9.06      5.6   448ms
                                      72.9   1.73s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.56s  Non-interacting
   1        0       1        0.31     52.7   1.51s
   2        0       2       -0.52     47.2   1.30s
   3        0       3       -2.40     41.9   1.18s
   4        0       4       -4.46     29.9   944ms
   5        0       5       -6.46     17.6   1.99s
   6        0       6       -8.91      4.0   427ms
   7        1       1       -7.84     55.8   1.94s  Restart
   8        1       2       -9.06      5.6   438ms
                                      72.9   1.71s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.57s  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.9   1.21s
   4        0       4       -4.46     29.9   955ms
   5        0       5       -6.46     17.6   711ms
   6        0       6       -8.91      4.0   410ms
   7        1       1       -7.84     55.8   1.85s  Restart
   8        1       2       -9.06      5.6   451ms
                                      72.9   1.74s  Final orbitals
 85.325979 seconds (100.55 M allocations: 80.481 GiB, 7.86% gc time, 7.52% compilation time: 100% of which was recompilation)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.003498155352273254
 -0.0029774511535356676
 -0.0029774511530048977
  0.0043022306366989884
  0.00430223063730323
  0.004353201767283339