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.916462411600                   -0.69    4.9    109ms
  2   -7.921203989672       -2.32       -1.52    1.0   55.2ms
  3   -7.921403882676       -3.70       -2.49    1.4   59.1ms
  4   -7.921441018267       -4.43       -2.82    2.5   78.2ms
  5   -7.921441605597       -6.23       -2.98    1.2   60.0ms
  6   -7.921442007078       -6.40       -4.45    1.0   56.4ms
  7   -7.921442021788       -7.83       -4.58    2.9   86.4ms
  8   -7.921442022125       -9.47       -5.15    1.0   55.6ms
  9   -7.921442022139      -10.83       -5.41    1.1   56.8ms
 10   -7.921442022143      -11.42       -5.82    1.4   59.9ms
 11   -7.921442022144      -12.00       -7.22    1.1   58.0ms
 12   -7.921442022144      -13.15       -7.12    2.9    167ms
 13   -7.921442022144      -14.45       -7.51    1.0   60.5ms
 14   -7.921442022144   +  -14.75       -8.13    1.0   59.7ms

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
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   2.07s  Non-interacting
   1        0       1        0.31     52.5   9.15s  
   2        0       2       -0.52     46.9   1.39s  
   3        0       3       -2.40     41.7   1.25s  
   4        0       4       -4.46     29.6   988ms  
   5        0       5       -6.46     17.3   719ms  
   6        0       6       -8.91      4.0   429ms  
   7        1       1       -7.86     55.5   2.02s  Restart
   8        1       2       -8.91      5.6   485ms  
                                      72.7   2.63s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.61s  Non-interacting
   1        0       1        0.31     52.5   1.60s  
   2        0       2       -0.52     46.9   1.37s  
   3        0       3       -2.40     41.7   1.26s  
   4        0       4       -4.46     29.6   984ms  
   5        0       5       -6.46     17.3   717ms  
   6        0       6       -8.91      4.0   440ms  
   7        1       1       -7.86     55.5   1.90s  Restart
   8        1       2       -8.91      5.6   463ms  
                                      72.8   1.81s  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     46.9   1.36s  
   3        0       3       -2.40     41.7   1.26s  
   4        0       4       -4.46     29.6   978ms  
   5        0       5       -6.46     17.3   1.58s  
   6        0       6       -8.91      4.0   404ms  
   7        1       1       -7.86     55.5   1.79s  Restart
   8        1       2       -8.91      5.6   465ms  
                                      72.8   1.80s  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.60s  
   2        0       2       -0.52     46.9   1.37s  
   3        0       3       -2.40     41.7   1.28s  
   4        0       4       -4.46     29.6   984ms  
   5        0       5       -6.46     17.3   742ms  
   6        0       6       -8.91      4.0   428ms  
   7        1       1       -7.86     55.5   1.88s  Restart
   8        1       2       -8.91      5.6   457ms  
                                      72.8   1.79s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.64s  Non-interacting
   1        0       1        0.31     52.5   2.38s  
   2        0       2       -0.52     46.9   1.29s  
   3        0       3       -2.40     41.7   1.25s  
   4        0       4       -4.46     29.6   975ms  
   5        0       5       -6.46     17.3   723ms  
   6        0       6       -8.91      4.0   431ms  
   7        1       1       -7.86     55.5   1.88s  Restart
   8        1       2       -8.91      5.6   467ms  
                                      72.8   1.81s  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.58s  
   2        0       2       -0.52     46.9   1.36s  
   3        0       3       -2.40     41.7   1.24s  
   4        0       4       -4.46     29.6   964ms  
   5        0       5       -6.46     17.3   714ms  
   6        0       6       -8.91      4.0   426ms  
   7        1       1       -7.86     55.5   2.72s  Restart
   8        1       2       -8.91      5.6   429ms  
                                      72.8   1.69s  Final orbitals
112.442069 seconds (151.08 M allocations: 82.616 GiB, 8.47% gc time, 26.18% compilation time)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.003498155352349171
 -0.0029774511551668627
 -0.002977451155069899
  0.0043022306431483755
  0.00430223064323123
  0.004353201771464269