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.916428680021                   -0.69    5.0    124ms
  2   -7.921200727955       -2.32       -1.52    1.0   55.5ms
  3   -7.921404085716       -3.69       -2.49    1.4   60.4ms
  4   -7.921440921932       -4.43       -2.82    2.5   77.0ms
  5   -7.921441581941       -6.18       -2.98    1.1   57.5ms
  6   -7.921442007561       -6.37       -4.56    1.0   56.0ms
  7   -7.921442021654       -7.85       -4.52    2.9   97.3ms
  8   -7.921442022127       -9.32       -5.33    1.0   56.8ms
  9   -7.921442022141      -10.86       -5.66    2.0   69.3ms
 10   -7.921442022144      -11.61       -5.92    1.0   57.3ms
 11   -7.921442022144      -12.43       -7.16    1.0   58.1ms
 12   -7.921442022144      -13.53       -7.73    2.5   80.1ms
 13   -7.921442022144      -14.57       -7.94    1.8   75.8ms
 14   -7.921442022144   +  -14.75       -8.43    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]);
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.95s  Non-interacting
   1        0       1        0.31     52.7   3.61s
   2        0       2       -0.52     47.2   1.33s
   3        0       3       -2.40     41.8   1.20s
   4        0       4       -4.46     29.9   954ms
   5        0       5       -6.46     17.6   692ms
   6        0       6       -8.92      4.0   419ms
   7        1       1       -7.88     55.6   1.85s  Restart
   8        1       2       -9.07      5.4   452ms
                                      72.9   1.72s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.57s  Non-interacting
   1        0       1        0.31     52.7   1.51s
   2        0       2       -0.52     47.2   1.32s
   3        0       3       -2.40     41.8   1.19s
   4        0       4       -4.46     29.9   941ms
   5        0       5       -6.46     17.6   694ms
   6        0       6       -8.92      4.0   412ms
   7        1       1       -7.88     55.6   3.04s  Restart
   8        1       2       -9.07      5.4   411ms
                                      72.8   1.80s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.54s  Non-interacting
   1        0       1        0.31     52.7   1.52s
   2        0       2       -0.52     47.2   1.32s
   3        0       3       -2.40     41.8   1.20s
   4        0       4       -4.46     29.9   959ms
   5        0       5       -6.46     17.6   698ms
   6        0       6       -8.92      4.0   413ms
   7        1       1       -7.88     55.6   1.82s  Restart
   8        1       2       -9.07      5.4   465ms
                                      72.9   1.75s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.58s  Non-interacting
   1        0       1        0.31     52.7   1.55s
   2        0       2       -0.52     47.2   1.32s
   3        0       3       -2.40     41.9   1.21s
   4        0       4       -4.46     29.9   958ms
   5        0       5       -6.46     17.5   708ms
   6        0       6       -8.92      4.0   421ms
   7        1       1       -7.89     55.5   1.84s  Restart
   8        1       2       -9.09      5.4   455ms
                                      72.9   1.73s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.58s  Non-interacting
   1        0       1        0.31     52.7   1.55s
   2        0       2       -0.52     47.2   1.32s
   3        0       3       -2.40     41.9   1.21s
   4        0       4       -4.46     29.9   959ms
   5        0       5       -6.46     17.5   712ms
   6        0       6       -8.92      4.0   425ms
   7        1       1       -7.89     55.5   1.81s  Restart
   8        1       2       -9.09      5.4   459ms
                                      72.9   1.73s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.57s  Non-interacting
   1        0       1        0.31     52.7   1.53s
   2        0       2       -0.52     47.2   1.31s
   3        0       3       -2.40     41.9   1.20s
   4        0       4       -4.46     29.9   953ms
   5        0       5       -6.46     17.5   930ms
   6        0       6       -8.92      4.0   1.56s
   7        1       1       -7.89     55.5   1.95s  Restart
   8        1       2       -9.09      5.4   420ms
                                      72.9   1.73s  Final orbitals
 86.511626 seconds (101.45 M allocations: 80.467 GiB, 8.07% gc time, 8.23% compilation time: 100% of which was recompilation)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.003498155356790449
 -0.0029774511589978157
 -0.0029774511586413525
  0.0043022306356310935
  0.004302230635768646
  0.00435320176561137