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.916421912380                   -0.69    4.8    109ms
  2   -7.921201736048       -2.32       -1.52    1.0   54.8ms
  3   -7.921403779909       -3.69       -2.49    1.5   59.8ms
  4   -7.921440779818       -4.43       -2.82    2.5   75.2ms
  5   -7.921441573806       -6.10       -2.97    1.2   57.4ms
  6   -7.921442004811       -6.37       -4.41    1.0   54.6ms
  7   -7.921442021706       -7.77       -4.55    2.8    100ms
  8   -7.921442022123       -9.38       -5.16    1.0   57.6ms
  9   -7.921442022143      -10.71       -5.87    1.5   63.6ms
 10   -7.921442022144      -11.94       -5.86    1.9   69.8ms
 11   -7.921442022144      -12.39       -6.55    1.0   59.1ms
 12   -7.921442022144      -13.65       -7.30    1.1   60.7ms
 13   -7.921442022144      -14.75       -7.56    2.0   73.6ms
 14   -7.921442022144   +  -15.05       -8.79    1.1   62.5ms

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   2.00s  Non-interacting
   1        0       1        0.31     52.4   3.66s
   2        0       2       -0.52     47.0   1.31s
   3        0       3       -2.40     41.7   1.20s
   4        0       4       -4.46     29.7   972ms
   5        0       5       -6.46     17.4   721ms
   6        0       6       -8.91      4.0   420ms
   7        1       1       -7.84     55.5   1.89s  Restart
   8        1       2       -8.97      5.6   458ms
                                      72.8   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.4   1.52s
   2        0       2       -0.52     47.0   1.31s
   3        0       3       -2.40     41.7   1.21s
   4        0       4       -4.46     29.7   975ms
   5        0       5       -6.46     17.4   713ms
   6        0       6       -8.91      4.0   420ms
   7        1       1       -7.84     55.5   1.84s  Restart
   8        1       2       -8.97      5.6   451ms
                                      72.8   1.74s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.57s  Non-interacting
   1        0       1        0.31     52.4   1.53s
   2        0       2       -0.52     47.0   1.32s
   3        0       3       -2.40     41.7   1.22s
   4        0       4       -4.46     29.7   966ms
   5        0       5       -6.46     17.4   710ms
   6        0       6       -8.91      4.0   425ms
   7        1       1       -7.84     55.5   1.85s  Restart
   8        1       2       -8.97      5.6   466ms
                                      72.7   1.75s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.60s  Non-interacting
   1        0       1        0.31     52.4   1.56s
   2        0       2       -0.52     47.0   2.51s
   3        0       3       -2.40     41.7   1.37s
   4        0       4       -4.46     29.7   915ms
   5        0       5       -6.46     17.4   700ms
   6        0       6       -8.91      4.0   434ms
   7        1       1       -7.84     55.4   1.84s  Restart
   8        1       2       -9.00      5.6   464ms
                                      72.7   1.73s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.57s  Non-interacting
   1        0       1        0.31     52.4   1.54s
   2        0       2       -0.52     47.0   1.31s
   3        0       3       -2.40     41.7   1.21s
   4        0       4       -4.46     29.7   980ms
   5        0       5       -6.46     17.4   698ms
   6        0       6       -8.91      4.0   418ms
   7        1       1       -7.84     55.4   1.85s  Restart
   8        1       2       -9.00      5.6   469ms
                                      72.7   1.72s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.59s  Non-interacting
   1        0       1        0.31     52.4   1.54s
   2        0       2       -0.52     47.0   1.33s
   3        0       3       -2.40     41.7   1.25s
   4        0       4       -4.46     29.7   957ms
   5        0       5       -6.46     17.4   700ms
   6        0       6       -8.91      4.0   420ms
   7        1       1       -7.84     55.4   1.84s  Restart
   8        1       2       -9.00      5.6   466ms
                                      72.7   1.73s  Final orbitals
 85.635723 seconds (101.40 M allocations: 80.325 GiB, 7.16% gc time, 8.34% compilation time: 100% of which was recompilation)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.003498155361767803
 -0.002977451163613997
 -0.0029774511634847733
  0.004302230624195357
  0.004302230624457564
  0.00435320175543643