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.916423666610                   -0.69    4.8    167ms
  2   -7.921206361341       -2.32       -1.52    1.0   60.3ms
  3   -7.921402683565       -3.71       -2.49    1.2   64.0ms
  4   -7.921440892003       -4.42       -2.81    2.4   83.1ms
  5   -7.921441523412       -6.20       -2.94    1.0   60.2ms
  6   -7.921442006823       -6.32       -4.48    1.0   59.4ms
  7   -7.921442021502       -7.83       -4.46    3.0   94.9ms
  8   -7.921442022120       -9.21       -5.30    1.0   64.8ms
  9   -7.921442022143      -10.65       -5.69    1.6   72.9ms
 10   -7.921442022144      -12.08       -6.10    1.4   72.1ms
 11   -7.921442022144      -12.38       -6.73    1.2   69.5ms
 12   -7.921442022144      -13.51       -6.96    1.9   75.9ms
 13   -7.921442022144      -14.75       -7.58    1.0   89.2ms
 14   -7.921442022144   +    -Inf       -7.90    1.5   67.9ms
 15   -7.921442022144   +  -15.05       -8.61    1.1   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]);
nothing  # hide
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      20.0   2.04s  Non-interacting
   1        0       1        0.31     14.7   13.6s  
   2        0       2       -0.52     13.1   1.27s  
   3        0       3       -2.40     11.6   1.13s  
   4        0       4       -4.46      8.6   910ms  
   5        0       5       -6.46      5.1   648ms  
   6        0       6       -8.91      1.0   359ms  
   7        1       1       -7.82     16.5   1.92s  Restart
   8        1       2       -8.84      2.1   424ms  
                                      18.6   2.29s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      20.0   1.61s  Non-interacting
   1        0       1        0.31     14.7   2.32s  
   2        0       2       -0.52     13.1   1.15s  
   3        0       3       -2.40     11.6   1.04s  
   4        0       4       -4.46      8.6   856ms  
   5        0       5       -6.46      5.1   612ms  
   6        0       6       -8.91      1.0   350ms  
   7        1       1       -7.82     16.5   1.65s  Restart
   8        1       2       -8.84      2.1   379ms  
                                      18.6   1.63s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      20.0   1.60s  Non-interacting
   1        0       1        0.31     14.7   1.45s  
   2        0       2       -0.52     13.1   1.22s  
   3        0       3       -2.40     11.6   1.17s  
   4        0       4       -4.46      8.6   871ms  
   5        0       5       -6.46      5.1   653ms  
   6        0       6       -8.91      1.0   360ms  
   7        1       1       -7.82     16.5   1.73s  Restart
   8        1       2       -8.84      2.1   411ms  
                                      18.6   1.68s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      20.0   1.59s  Non-interacting
   1        0       1        0.31     14.7   1.46s  
   2        0       2       -0.52     13.1   1.25s  
   3        0       3       -2.40     11.6   1.16s  
   4        0       4       -4.46      8.6   917ms  
   5        0       5       -6.46      5.1   656ms  
   6        0       6       -8.91      1.0   371ms  
   7        1       1       -7.83     16.5   1.74s  Restart
   8        1       2       -8.87      2.1   480ms  
                                      18.6   2.35s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      20.0   1.47s  Non-interacting
   1        0       1        0.31     14.7   1.42s  
   2        0       2       -0.52     13.1   1.19s  
   3        0       3       -2.40     11.6   1.12s  
   4        0       4       -4.46      8.6   889ms  
   5        0       5       -6.46      5.1   651ms  
   6        0       6       -8.91      1.0   349ms  
   7        1       1       -7.83     16.5   1.70s  Restart
   8        1       2       -8.87      2.1   417ms  
                                      18.6   1.60s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      20.0   1.60s  Non-interacting
   1        0       1        0.31     14.7   1.44s  
   2        0       2       -0.52     13.1   1.27s  
   3        0       3       -2.40     11.6   1.13s  
   4        0       4       -4.46      8.6   912ms  
   5        0       5       -6.46      5.1   647ms  
   6        0       6       -8.91      1.0   366ms  
   7        1       1       -7.83     16.5   1.73s  Restart
   8        1       2       -8.87      2.1   414ms  
                                      18.6   1.66s  Final orbitals
110.843711 seconds (137.48 M allocations: 23.450 GiB, 4.23% gc time, 32.05% compilation time)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.00349815535456781
 -0.0029774511552699513
 -0.0029774511551703005
  0.004302230632495941
  0.004302230632502189
  0.004353201762861478