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);
nothing  # hide
n     Energy            log10(ΔE)   log10(Δρ)   Diag   Δtime 
---   ---------------   ---------   ---------   ----   ------
  1   -7.916453895262                   -0.69    4.6    157ms
  2   -7.921210082539       -2.32       -1.52    1.0   57.3ms
  3   -7.921403460094       -3.71       -2.49    1.2   59.4ms
  4   -7.921440833972       -4.43       -2.81    2.8   81.6ms
  5   -7.921441555468       -6.14       -2.96    1.1   59.6ms
  6   -7.921442006479       -6.35       -4.50    1.0   58.2ms
  7   -7.921442021555       -7.82       -4.47    2.9   87.8ms
  8   -7.921442022114       -9.25       -5.12    1.0    154ms
  9   -7.921442022137      -10.64       -5.25    1.4   61.9ms
 10   -7.921442022143      -11.22       -5.87    1.0   58.3ms
 11   -7.921442022144      -11.88       -6.11    1.5   65.0ms
 12   -7.921442022144      -13.01       -6.36    1.1   59.6ms
 13   -7.921442022144      -13.57       -7.01    1.0   58.2ms
 14   -7.921442022144      -14.15       -7.44    1.5    798ms
 15   -7.921442022144   +    -Inf       -8.07    1.6    120ms

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]);
nothing  # hide
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   2.09s  Non-interacting
   1        0       1        0.31     52.5   9.34s  
   2        0       2       -0.52     47.0   1.47s  
   3        0       3       -2.40     41.6   1.27s  
   4        0       4       -4.46     29.6   1.01s  
   5        0       5       -6.46     17.4   743ms  
   6        0       6       -8.91      4.0   432ms  
   7        1       1       -7.77     56.2   2.05s  Restart
   8        1       2       -8.70      5.7   474ms  
                                      72.8   1.86s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.68s  Non-interacting
   1        0       1        0.31     52.5   1.58s  
   2        0       2       -0.52     47.0   1.39s  
   3        0       3       -2.40     41.6   1.27s  
   4        0       4       -4.46     29.6   1.77s  
   5        0       5       -6.46     17.4   682ms  
   6        0       6       -8.91      4.0   415ms  
   7        1       1       -7.77     56.2   1.90s  Restart
   8        1       2       -8.70      5.7   483ms  
                                      72.7   1.80s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.65s  Non-interacting
   1        0       1        0.31     52.5   1.57s  
   2        0       2       -0.52     47.0   1.37s  
   3        0       3       -2.40     41.6   1.24s  
   4        0       4       -4.46     29.6   980ms  
   5        0       5       -6.46     17.4   722ms  
   6        0       6       -8.91      4.0   432ms  
   7        1       1       -7.77     56.2   1.90s  Restart
   8        1       2       -8.70      5.7   457ms  
                                      72.7   1.81s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.66s  Non-interacting
   1        0       1        0.31     52.5   1.57s  
   2        0       2       -0.52     47.0   1.36s  
   3        0       3       -2.40     41.6   1.26s  
   4        0       4       -4.46     29.6   1.68s  
   5        0       5       -6.46     17.4   682ms  
   6        0       6       -8.90      4.0   414ms  
   7        1       1       -7.77     56.2   1.96s  Restart
   8        1       2       -8.70      5.7   482ms  
                                      72.7   1.85s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.68s  Non-interacting
   1        0       1        0.31     52.5   1.60s  
   2        0       2       -0.52     47.0   1.38s  
   3        0       3       -2.40     41.6   1.26s  
   4        0       4       -4.46     29.6   1.00s  
   5        0       5       -6.46     17.4   739ms  
   6        0       6       -8.90      4.0   436ms  
   7        1       1       -7.77     56.2   1.92s  Restart
   8        1       2       -8.70      5.7   460ms  
                                      72.8   1.78s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.62s  Non-interacting
   1        0       1        0.31     52.5   1.57s  
   2        0       2       -0.52     47.0   1.34s  
   3        0       3       -2.40     41.6   1.24s  
   4        0       4       -4.46     29.6   1.74s  
   5        0       5       -6.46     17.4   685ms  
   6        0       6       -8.90      4.0   420ms  
   7        1       1       -7.77     56.2   1.93s  Restart
   8        1       2       -8.70      5.7   474ms  
                                      72.8   1.83s  Final orbitals
112.970271 seconds (151.11 M allocations: 82.676 GiB, 7.97% gc time, 26.95% compilation time)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.0034981553640066054
 -0.0029774511675373454
 -0.0029774511674652898
  0.004302230628242684
  0.004302230628598805
  0.004353201757301661