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.916441726278                   -0.69    4.8    115ms
  2   -7.921210947970       -2.32       -1.52    1.0   58.6ms
  3   -7.921405598457       -3.71       -2.49    1.4   60.1ms
  4   -7.921440963664       -4.45       -2.82    2.6   80.8ms
  5   -7.921441617604       -6.18       -2.99    1.0   59.8ms
  6   -7.921442009293       -6.41       -4.53    1.0   60.4ms
  7   -7.921442021738       -7.90       -4.56    2.8   91.0ms
  8   -7.921442022126       -9.41       -5.34    1.0   64.4ms
  9   -7.921442022143      -10.78       -5.97    1.9   70.1ms
 10   -7.921442022144      -12.15       -6.11    1.8   66.3ms
 11   -7.921442022144      -12.73       -6.71    1.0    221ms
 12   -7.921442022144      -13.82       -7.10    1.8   64.7ms
 13   -7.921442022144      -14.75       -7.54    1.4   61.5ms
 14   -7.921442022144      -14.75       -8.03    1.2    109ms

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   1.97s  Non-interacting
   1        0       1        0.31     14.7   12.9s  
   2        0       2       -0.52     13.1   1.27s  
   3        0       3       -2.40     11.7   1.12s  
   4        0       4       -4.46      8.6   889ms  
   5        0       5       -6.46      5.1   632ms  
   6        0       6       -8.91      1.0   370ms  
   7        1       1       -7.81     16.5   1.88s  Restart
   8        1       2       -8.90      2.1   394ms  
                                      18.6   2.22s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      20.0   1.52s  Non-interacting
   1        0       1        0.31     14.7   1.44s  
   2        0       2       -0.52     13.1   1.24s  
   3        0       3       -2.40     11.7   1.13s  
   4        0       4       -4.46      8.6   884ms  
   5        0       5       -6.46      5.1   718ms  
   6        0       6       -8.91      1.0   1.02s  
   7        1       1       -7.81     16.5   1.57s  Restart
   8        1       2       -8.90      2.1   387ms  
                                      18.6   1.56s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      20.0   1.50s  Non-interacting
   1        0       1        0.31     14.7   1.44s  
   2        0       2       -0.52     13.1   1.25s  
   3        0       3       -2.40     11.7   1.12s  
   4        0       4       -4.46      8.6   891ms  
   5        0       5       -6.46      5.1   633ms  
   6        0       6       -8.91      1.0   365ms  
   7        1       1       -7.81     16.5   1.70s  Restart
   8        1       2       -8.90      2.1   395ms  
                                      18.6   1.63s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      20.0   1.53s  Non-interacting
   1        0       1        0.31     14.7   1.44s  
   2        0       2       -0.52     13.1   1.24s  
   3        0       3       -2.40     11.7   1.12s  
   4        0       4       -4.46      8.6   881ms  
   5        0       5       -6.46      5.1   638ms  
   6        0       6       -8.91      1.0   364ms  
   7        1       1       -7.81     16.5   1.72s  Restart
   8        1       2       -8.89      2.1   404ms  
                                      18.6   1.64s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      20.0   1.53s  Non-interacting
   1        0       1        0.31     14.7   1.44s  
   2        0       2       -0.52     13.1   1.97s  
   3        0       3       -2.40     11.7   1.06s  
   4        0       4       -4.46      8.6   823ms  
   5        0       5       -6.46      5.1   623ms  
   6        0       6       -8.91      1.0   333ms  
   7        1       1       -7.81     16.5   1.68s  Restart
   8        1       2       -8.89      2.1   396ms  
                                      18.6   1.63s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      20.0   1.53s  Non-interacting
   1        0       1        0.31     14.7   1.44s  
   2        0       2       -0.52     13.1   1.24s  
   3        0       3       -2.40     11.7   1.14s  
   4        0       4       -4.46      8.6   900ms  
   5        0       5       -6.46      5.1   637ms  
   6        0       6       -8.91      1.0   356ms  
   7        1       1       -7.81     16.5   1.70s  Restart
   8        1       2       -8.89      2.1   395ms  
                                      18.6   1.63s  Final orbitals
107.262952 seconds (137.38 M allocations: 23.451 GiB, 3.26% gc time, 31.53% compilation time)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.0034981553584147885
 -0.0029774511634385664
 -0.0029774511629175257
  0.004302230641198312
  0.004302230642142157
  0.0043532017689935755