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.916400691256                   -0.69    4.8    109ms
  2   -7.921198973371       -2.32       -1.52    1.0   54.9ms
  3   -7.921399630753       -3.70       -2.49    1.2   57.9ms
  4   -7.921440862374       -4.38       -2.79    2.5   77.6ms
  5   -7.921441419687       -6.25       -2.89    1.1   90.0ms
  6   -7.921442005617       -6.23       -4.48    1.0   55.6ms
  7   -7.921442021430       -7.80       -4.44    3.0   85.4ms
  8   -7.921442022117       -9.16       -5.23    1.0   56.0ms
  9   -7.921442022141      -10.61       -5.43    1.5   61.9ms
 10   -7.921442022143      -11.74       -5.90    1.1   59.3ms
 11   -7.921442022144      -12.04       -6.31    1.1   84.7ms
 12   -7.921442022144      -13.27       -6.48    1.4    221ms
 13   -7.921442022144      -13.91       -7.22    1.0   57.2ms
 14   -7.921442022144      -14.57       -7.21    1.8    118ms
 15   -7.921442022144      -15.05       -7.69    1.0   57.9ms
 16   -7.921442022144   +  -14.57       -8.11    1.0   57.0ms

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.77s  Non-interacting
   1        0       1        0.31     14.7   12.8s  
   2        0       2       -0.52     13.1   1.23s  
   3        0       3       -2.40     11.6   1.09s  
   4        0       4       -4.46      8.6   870ms  
   5        0       5       -6.46      5.1   624ms  
   6        0       6       -8.91      1.0   350ms  
   7        1       1       -7.82     16.5   1.85s  Restart
   8        1       2       -8.84      2.1   412ms  
                                      19.9   1.67s  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.42s  
   2        0       2       -0.52     13.1   1.21s  
   3        0       3       -2.40     11.6   1.13s  
   4        0       4       -4.46      8.6   885ms  
   5        0       5       -6.46      5.1   639ms  
   6        0       6       -8.91      1.0   360ms  
   7        1       1       -7.82     16.5   1.68s  Restart
   8        1       2       -8.84      2.1   396ms  
                                      19.9   1.63s  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.42s  
   2        0       2       -0.52     13.1   1.23s  
   3        0       3       -2.40     11.6   1.12s  
   4        0       4       -4.46      8.6   871ms  
   5        0       5       -6.46      5.1   634ms  
   6        0       6       -8.91      1.0   361ms  
   7        1       1       -7.82     16.5   2.42s  Restart
   8        1       2       -8.84      2.1   409ms  
                                      19.9   1.51s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      20.0   1.48s  Non-interacting
   1        0       1        0.31     14.7   1.38s  
   2        0       2       -0.52     13.1   1.21s  
   3        0       3       -2.40     11.6   1.12s  
   4        0       4       -4.46      8.6   863ms  
   5        0       5       -6.46      5.1   635ms  
   6        0       6       -8.91      1.0   359ms  
   7        1       1       -7.83     16.5   1.70s  Restart
   8        1       2       -8.84      2.1   396ms  
                                      19.9   1.63s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      20.0   1.54s  Non-interacting
   1        0       1        0.31     14.7   1.43s  
   2        0       2       -0.52     13.1   1.23s  
   3        0       3       -2.40     11.6   1.12s  
   4        0       4       -4.46      8.6   873ms  
   5        0       5       -6.46      5.1   636ms  
   6        0       6       -8.91      1.0   361ms  
   7        1       1       -7.83     16.5   1.68s  Restart
   8        1       2       -8.84      2.1   397ms  
                                      19.9   1.64s  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.43s  
   2        0       2       -0.52     13.1   1.23s  
   3        0       3       -2.40     11.6   1.12s  
   4        0       4       -4.46      8.6   878ms  
   5        0       5       -6.46      5.1   714ms  
   6        0       6       -8.91      1.0   1.03s  
   7        1       1       -7.83     16.5   1.62s  Restart
   8        1       2       -8.84      2.1   353ms  
                                      19.9   1.62s  Final orbitals
106.924746 seconds (136.90 M allocations: 23.467 GiB, 4.23% gc time, 31.13% compilation time)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.00349815535744551
 -0.002977451156881334
 -0.002977451156336011
  0.0043022306242041985
  0.004302230624331132
  0.004353201754680059