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.916460522208                   -0.69    4.8    114ms
  2   -7.921206943514       -2.32       -1.52    1.0   54.6ms
  3   -7.921405754784       -3.70       -2.49    1.4   61.9ms
  4   -7.921441086457       -4.45       -2.83    2.5   79.4ms
  5   -7.921441639291       -6.26       -2.99    1.0   89.0ms
  6   -7.921442009789       -6.43       -4.52    1.0   58.0ms
  7   -7.921442021845       -7.92       -4.61    3.0   83.7ms
  8   -7.921442022131       -9.54       -5.26    1.0   55.6ms
  9   -7.921442022143      -10.92       -5.77    1.4   64.3ms
 10   -7.921442022144      -11.99       -6.00    1.8   69.7ms
 11   -7.921442022144      -12.37       -7.31    1.0   91.6ms
 12   -7.921442022144      -13.65       -7.09    2.8   88.0ms
 13   -7.921442022144   +  -15.05       -7.65    1.0   61.2ms
 14   -7.921442022144      -14.75       -9.19    1.1    112ms

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
----  -------  ------  ----------  -------  ------  ---------------
                                      20.0   2.65s  Non-interacting
   1        0       1        0.31     14.8   13.3s  
   2        0       2       -0.52     13.1   1.23s  
   3        0       3       -2.40     11.7   1.12s  
   4        0       4       -4.46      8.6   872ms  
   5        0       5       -6.46      5.2   626ms  
   6        0       6       -8.92      1.0   359ms  
   7        1       1       -7.84     16.6   1.86s  Restart
   8        1       2       -8.98      2.1   408ms  
                                      18.7   2.22s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      20.0   1.51s  Non-interacting
   1        0       1        0.31     14.8   1.39s  
   2        0       2       -0.52     13.1   1.21s  
   3        0       3       -2.40     11.7   1.10s  
   4        0       4       -4.46      8.6   871ms  
   5        0       5       -6.46      5.2   647ms  
   6        0       6       -8.92      1.0   365ms  
   7        1       1       -7.84     16.6   1.69s  Restart
   8        1       2       -8.98      2.1   397ms  
                                      18.7   1.63s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      20.0   1.52s  Non-interacting
   1        0       1        0.31     14.8   1.41s  
   2        0       2       -0.52     13.1   1.20s  
   3        0       3       -2.40     11.7   1.10s  
   4        0       4       -4.46      8.6   901ms  
   5        0       5       -6.46      5.2   631ms  
   6        0       6       -8.92      1.0   439ms  
   7        1       1       -7.84     16.6   2.30s  Restart
   8        1       2       -8.98      2.1   370ms  
                                      18.7   1.62s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      20.0   1.44s  Non-interacting
   1        0       1        0.31     14.8   1.41s  
   2        0       2       -0.52     13.1   1.18s  
   3        0       3       -2.40     11.7   1.06s  
   4        0       4       -4.46      8.6   864ms  
   5        0       5       -6.46      5.2   628ms  
   6        0       6       -8.92      1.0   372ms  
   7        1       1       -7.84     16.6   1.64s  Restart
   8        1       2       -8.96      2.1   406ms  
                                      18.7   1.59s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      20.0   1.47s  Non-interacting
   1        0       1        0.31     14.8   1.47s  
   2        0       2       -0.52     13.1   1.24s  
   3        0       3       -2.40     11.7   1.13s  
   4        0       4       -4.46      8.6   884ms  
   5        0       5       -6.46      5.2   637ms  
   6        0       6       -8.92      1.0   341ms  
   7        1       1       -7.84     16.6   1.75s  Restart
   8        1       2       -8.96      2.1   394ms  
                                      18.7   1.66s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      20.0   1.57s  Non-interacting
   1        0       1        0.31     14.8   1.41s  
   2        0       2       -0.52     13.1   1.24s  
   3        0       3       -2.40     11.7   1.11s  
   4        0       4       -4.46      8.6   879ms  
   5        0       5       -6.46      5.2   634ms  
   6        0       6       -8.92      1.0   368ms  
   7        1       1       -7.84     16.6   1.70s  Restart
   8        1       2       -8.96      2.1   454ms  
                                      18.7   2.33s  Final orbitals
108.236910 seconds (137.41 M allocations: 23.483 GiB, 3.95% gc time, 31.98% compilation time)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.0034981553583671807
 -0.0029774511595321365
 -0.0029774511595236433
  0.004302230630494961
  0.004302230630659632
  0.004353201760104519