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);
n     Energy            log10(ΔE)   log10(Δρ)   Diag   Δtime
---   ---------------   ---------   ---------   ----   ------
  1   -7.916444498671                   -0.69    4.6    104ms
  2   -7.921209994689       -2.32       -1.52    1.0   50.7ms
  3   -7.921404980662       -3.71       -2.49    1.4   54.5ms
  4   -7.921440967947       -4.44       -2.82    2.6   70.8ms
  5   -7.921441631478       -6.18       -3.00    1.1   57.5ms
  6   -7.921442007657       -6.42       -4.55    1.0   51.1ms
  7   -7.921442021854       -7.85       -4.63    2.9   77.2ms
  8   -7.921442022128       -9.56       -5.29    1.0   51.7ms
  9   -7.921442022143      -10.81       -6.15    1.6   63.0ms
 10   -7.921442022144      -12.26       -6.04    2.4   69.4ms
 11   -7.921442022144      -12.75       -6.62    1.0   52.5ms
 12   -7.921442022144      -14.10       -7.18    1.1   52.9ms
 13   -7.921442022144      -14.35       -7.43    1.2   56.1ms
 14   -7.921442022144   +  -14.75       -8.27    1.1   58.2ms

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]);
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.89s  Non-interacting
   1        0       1        0.31     52.5   2.84s
   2        0       2       -0.52     47.0   1.39s
   3        0       3       -2.40     41.7   1.29s
   4        0       4       -4.46     29.6   997ms
   5        0       5       -6.46     17.4   721ms
   6        0       6       -8.91      4.0   397ms
   7        1       1       -7.82     55.5   1.92s  Restart
   8        1       2       -8.90      5.5   432ms
                                      72.7   1.93s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.80s  Non-interacting
   1        0       1        0.31     52.5   1.67s
   2        0       2       -0.52     47.0   1.43s
   3        0       3       -2.40     41.7   1.31s
   4        0       4       -4.46     29.6   1.02s
   5        0       5       -6.46     17.4   724ms
   6        0       6       -8.91      4.0   404ms
   7        1       1       -7.82     55.5   1.93s  Restart
   8        1       2       -8.90      5.5   439ms
                                      72.7   1.92s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.78s  Non-interacting
   1        0       1        0.31     52.5   1.64s
   2        0       2       -0.52     47.0   1.42s
   3        0       3       -2.40     41.7   2.04s
   4        0       4       -4.46     29.6   1.03s
   5        0       5       -6.46     17.4   714ms
   6        0       6       -8.91      4.0   401ms
   7        1       1       -7.82     55.5   1.96s  Restart
   8        1       2       -8.90      5.5   442ms
                                      72.8   1.95s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.81s  Non-interacting
   1        0       1        0.31     52.5   1.66s
   2        0       2       -0.52     47.0   1.42s
   3        0       3       -2.40     41.7   1.29s
   4        0       4       -4.46     29.6   1.02s
   5        0       5       -6.46     17.4   725ms
   6        0       6       -8.91      4.0   413ms
   7        1       1       -7.81     55.6   1.95s  Restart
   8        1       2       -8.87      5.5   444ms
                                      72.7   1.94s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.81s  Non-interacting
   1        0       1        0.31     52.5   1.68s
   2        0       2       -0.52     47.0   1.45s
   3        0       3       -2.40     41.7   1.32s
   4        0       4       -4.46     29.6   1.02s
   5        0       5       -6.46     17.4   727ms
   6        0       6       -8.91      4.0   1.13s
   7        1       1       -7.81     55.6   1.95s  Restart
   8        1       2       -8.87      5.5   435ms
                                      72.7   1.96s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.82s  Non-interacting
   1        0       1        0.31     52.5   1.68s
   2        0       2       -0.52     47.0   1.45s
   3        0       3       -2.40     41.7   1.33s
   4        0       4       -4.46     29.6   1.03s
   5        0       5       -6.46     17.4   731ms
   6        0       6       -8.91      4.0   409ms
   7        1       1       -7.81     55.6   1.97s  Restart
   8        1       2       -8.87      5.5   443ms
                                      72.8   1.95s  Final orbitals
 85.966155 seconds (91.75 M allocations: 79.896 GiB, 7.59% gc time, 1.23% compilation time: 100% of which was recompilation)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.0034981553603667674
 -0.0029774511634283875
 -0.0029774511628361208
  0.004302230632567693
  0.004302230633013164
  0.004353201764570384