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.916419745218                   -0.69    5.0    169ms
  2   -7.921203771765       -2.32       -1.52    1.0   57.4ms
  3   -7.921403946230       -3.70       -2.49    1.2   60.5ms
  4   -7.921440947470       -4.43       -2.82    2.4   77.2ms
  5   -7.921441589860       -6.19       -2.97    1.1   58.9ms
  6   -7.921442007108       -6.38       -4.52    1.0   56.5ms
  7   -7.921442021665       -7.84       -4.54    2.8   84.6ms
  8   -7.921442022123       -9.34       -5.26    1.0   81.4ms
  9   -7.921442022143      -10.70       -5.87    1.6   64.3ms
 10   -7.921442022144      -12.03       -6.08    1.8   67.6ms
 11   -7.921442022144      -12.60       -7.13    1.0   58.4ms
 12   -7.921442022144      -13.73       -7.17    2.6   80.2ms
 13   -7.921442022144      -14.57       -7.50    1.0   58.4ms
 14   -7.921442022144   +  -14.75       -8.12    1.0    116ms

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
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   2.18s  Non-interacting
   1        0       1        0.31     52.5   9.93s  
   2        0       2       -0.52     47.1   1.48s  
   3        0       3       -2.40     41.7   1.30s  
   4        0       4       -4.46     29.6   1.02s  
   5        0       5       -6.46     17.4   745ms  
   6        0       6       -8.91      4.0   452ms  
   7        1       1       -7.81     55.6   2.12s  Restart
   8        1       2       -8.81      5.5   487ms  
                                      72.7   2.64s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.71s  Non-interacting
   1        0       1        0.31     52.5   1.69s  
   2        0       2       -0.52     47.1   1.46s  
   3        0       3       -2.40     41.7   1.33s  
   4        0       4       -4.46     29.6   1.04s  
   5        0       5       -6.46     17.4   758ms  
   6        0       6       -8.91      4.0   443ms  
   7        1       1       -7.81     55.6   2.01s  Restart
   8        1       2       -8.81      5.5   482ms  
                                      72.7   1.82s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.66s  Non-interacting
   1        0       1        0.31     52.5   1.59s  
   2        0       2       -0.52     47.1   1.36s  
   3        0       3       -2.40     41.7   1.24s  
   4        0       4       -4.46     29.6   988ms  
   5        0       5       -6.46     17.4   720ms  
   6        0       6       -8.91      4.0   423ms  
   7        1       1       -7.81     55.6   1.97s  Restart
   8        1       2       -8.81      5.5   1.18s  
                                      72.7   1.74s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.71s  Non-interacting
   1        0       1        0.31     52.5   1.65s  
   2        0       2       -0.52     47.1   1.44s  
   3        0       3       -2.40     41.7   1.31s  
   4        0       4       -4.46     29.6   1.04s  
   5        0       5       -6.46     17.4   747ms  
   6        0       6       -8.91      4.0   447ms  
   7        1       1       -7.82     55.6   1.95s  Restart
   8        1       2       -8.82      5.5   473ms  
                                      72.6   1.86s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.69s  Non-interacting
   1        0       1        0.31     52.5   1.56s  
   2        0       2       -0.52     47.1   1.35s  
   3        0       3       -2.40     41.7   1.24s  
   4        0       4       -4.46     29.6   996ms  
   5        0       5       -6.46     17.4   713ms  
   6        0       6       -8.91      4.0   414ms  
   7        1       1       -7.82     55.6   1.94s  Restart
   8        1       2       -8.82      5.5   1.20s  
                                      72.7   1.71s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.70s  Non-interacting
   1        0       1        0.31     52.5   1.66s  
   2        0       2       -0.52     47.1   1.42s  
   3        0       3       -2.40     41.7   1.30s  
   4        0       4       -4.46     29.6   1.03s  
   5        0       5       -6.46     17.4   753ms  
   6        0       6       -8.91      4.0   437ms  
   7        1       1       -7.82     55.6   1.96s  Restart
   8        1       2       -8.82      5.5   490ms  
                                      72.7   1.83s  Final orbitals
115.882178 seconds (151.06 M allocations: 82.592 GiB, 7.36% gc time, 27.50% compilation time)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.003498155357707393
 -0.0029774511619171983
 -0.002977451161135081
  0.004302230639869209
  0.004302230640348434
  0.004353201768976597