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.916429695588                   -0.69    4.8    174ms
  2   -7.921209261904       -2.32       -1.52    1.0   60.9ms
  3   -7.921405376871       -3.71       -2.49    1.4   67.0ms
  4   -7.921440910007       -4.45       -2.82    2.6   87.5ms
  5   -7.921441626003       -6.15       -3.00    1.1   76.3ms
  6   -7.921442006231       -6.42       -4.56    1.0   84.1ms
  7   -7.921442021672       -7.81       -4.52    3.0    122ms
  8   -7.921442022123       -9.35       -5.25    1.0   61.3ms
  9   -7.921442022143      -10.69       -5.91    1.8   70.0ms
 10   -7.921442022144      -12.24       -6.01    1.9   73.1ms
 11   -7.921442022144      -12.53       -6.49    1.0   61.3ms
 12   -7.921442022144      -13.62       -6.94    1.2   63.7ms
 13   -7.921442022144   +    -Inf       -7.41    1.1   64.1ms
 14   -7.921442022144      -15.05       -7.77    1.2    136ms
 15   -7.921442022144      -15.05       -9.64    1.1   62.4ms

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.14s  Non-interacting
   1        0       1        0.31     52.2   9.76s  
   2        0       2       -0.52     46.9   1.45s  
   3        0       3       -2.40     41.5   1.28s  
   4        0       4       -4.46     29.5   1.03s  
   5        0       5       -6.46     17.3   742ms  
   6        0       6       -8.91      4.0   445ms  
   7        1       1       -7.84     55.3   2.10s  Restart
   8        1       2       -8.88      5.5   498ms  
                                      72.6   1.87s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.8   1.69s  Non-interacting
   1        0       1        0.31     52.2   1.66s  
   2        0       2       -0.52     46.9   1.38s  
   3        0       3       -2.40     41.5   1.29s  
   4        0       4       -4.46     29.5   1.00s  
   5        0       5       -6.46     17.3   742ms  
   6        0       6       -8.91      4.0   432ms  
   7        1       1       -7.84     55.3   2.64s  Restart
   8        1       2       -8.88      5.5   449ms  
                                      72.7   1.85s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.69s  Non-interacting
   1        0       1        0.31     52.2   1.62s  
   2        0       2       -0.52     46.9   1.40s  
   3        0       3       -2.40     41.5   1.29s  
   4        0       4       -4.46     29.5   1.02s  
   5        0       5       -6.46     17.3   744ms  
   6        0       6       -8.91      4.0   438ms  
   7        1       1       -7.84     55.3   1.90s  Restart
   8        1       2       -8.88      5.5   466ms  
                                      72.7   1.80s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.8   1.67s  Non-interacting
   1        0       1        0.31     52.2   1.57s  
   2        0       2       -0.52     46.9   2.11s  
   3        0       3       -2.40     41.5   1.17s  
   4        0       4       -4.46     29.5   1.01s  
   5        0       5       -6.46     17.4   739ms  
   6        0       6       -8.91      4.0   441ms  
   7        1       1       -7.84     55.3   1.95s  Restart
   8        1       2       -8.89      5.5   481ms  
                                      72.6   1.88s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.8   1.73s  Non-interacting
   1        0       1        0.31     52.2   1.63s  
   2        0       2       -0.52     46.9   1.38s  
   3        0       3       -2.40     41.5   1.26s  
   4        0       4       -4.46     29.5   1.00s  
   5        0       5       -6.46     17.4   721ms  
   6        0       6       -8.91      4.0   431ms  
   7        1       1       -7.84     55.3   1.93s  Restart
   8        1       2       -8.89      5.5   479ms  
                                      72.7   2.63s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.60s  Non-interacting
   1        0       1        0.31     52.2   1.63s  
   2        0       2       -0.52     46.9   1.42s  
   3        0       3       -2.40     41.5   1.28s  
   4        0       4       -4.46     29.5   1.02s  
   5        0       5       -6.46     17.4   752ms  
   6        0       6       -8.91      4.0   460ms  
   7        1       1       -7.84     55.3   1.94s  Restart
   8        1       2       -8.89      5.5   470ms  
                                      72.7   1.87s  Final orbitals
116.651988 seconds (151.00 M allocations: 82.492 GiB, 8.87% gc time, 26.91% compilation time)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.0034981553559870022
 -0.002977451157259467
 -0.0029774511568421294
  0.004302230631526972
  0.004302230631806558
  0.004353201761813051