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.916449063987                   -0.69    4.9    146ms
  2   -7.921204668594       -2.32       -1.51    1.0   57.2ms
  3   -7.921402792775       -3.70       -2.49    1.2   60.5ms
  4   -7.921440938442       -4.42       -2.82    2.4   78.1ms
  5   -7.921441601908       -6.18       -2.98    1.0   57.6ms
  6   -7.921442007089       -6.39       -4.53    1.0   57.7ms
  7   -7.921442021846       -7.83       -4.63    2.9    112ms
  8   -7.921442022130       -9.55       -5.35    1.0   58.4ms
  9   -7.921442022140      -11.02       -5.47    1.6   66.5ms
 10   -7.921442022144      -11.43       -5.92    1.0   59.3ms
 11   -7.921442022144      -12.43       -6.60    1.2    226ms
 12   -7.921442022144      -13.43       -7.52    1.9   69.8ms
 13   -7.921442022144      -14.75       -7.94    1.9   93.4ms
 14   -7.921442022144   +    -Inf       -8.21    1.2   61.6ms

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.04s  Non-interacting
   1        0       1        0.31     52.4   14.2s  
   2        0       2       -0.52     47.0   1.35s  
   3        0       3       -2.40     41.8   1.21s  
   4        0       4       -4.46     29.8   965ms  
   5        0       5       -6.46     17.4   693ms  
   6        0       6       -8.91      4.0   411ms  
   7        1       1       -7.87     55.4   1.96s  Restart
   8        1       2       -9.03      5.5   442ms  
                                      72.7   1.78s  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.51s  
   2        0       2       -0.52     47.0   1.31s  
   3        0       3       -2.40     41.8   1.19s  
   4        0       4       -4.46     29.8   940ms  
   5        0       5       -6.46     17.4   686ms  
   6        0       6       -8.91      4.0   404ms  
   7        1       1       -7.87     55.4   2.50s  Restart
   8        1       2       -9.03      5.5   430ms  
                                      72.7   1.78s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.64s  Non-interacting
   1        0       1        0.31     52.4   1.55s  
   2        0       2       -0.52     47.0   1.34s  
   3        0       3       -2.40     41.8   1.23s  
   4        0       4       -4.46     29.8   968ms  
   5        0       5       -6.46     17.4   707ms  
   6        0       6       -8.91      4.0   415ms  
   7        1       1       -7.87     55.4   1.86s  Restart
   8        1       2       -9.03      5.5   438ms  
                                      72.8   1.79s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.64s  Non-interacting
   1        0       1        0.31     52.4   1.54s  
   2        0       2       -0.52     47.0   2.04s  
   3        0       3       -2.40     41.8   1.17s  
   4        0       4       -4.46     29.8   983ms  
   5        0       5       -6.46     17.4   704ms  
   6        0       6       -8.91      4.0   427ms  
   7        1       1       -7.86     55.4   1.86s  Restart
   8        1       2       -9.00      5.5   449ms  
                                      72.7   1.80s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.64s  Non-interacting
   1        0       1        0.31     52.4   1.53s  
   2        0       2       -0.52     47.0   1.33s  
   3        0       3       -2.40     41.8   1.22s  
   4        0       4       -4.46     29.8   962ms  
   5        0       5       -6.46     17.4   703ms  
   6        0       6       -8.91      4.0   409ms  
   7        1       1       -7.86     55.4   2.59s  Restart
   8        1       2       -9.00      5.5   410ms  
                                      72.7   1.69s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.63s  Non-interacting
   1        0       1        0.31     52.4   1.52s  
   2        0       2       -0.52     47.0   1.33s  
   3        0       3       -2.40     41.8   1.21s  
   4        0       4       -4.46     29.8   949ms  
   5        0       5       -6.46     17.4   694ms  
   6        0       6       -8.91      4.0   418ms  
   7        1       1       -7.86     55.4   1.82s  Restart
   8        1       2       -9.00      5.5   440ms  
                                      72.8   1.78s  Final orbitals
115.402579 seconds (159.99 M allocations: 83.318 GiB, 8.23% gc time, 29.62% compilation time)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.0034981553593321983
 -0.0029774511581928415
 -0.0029774511580578185
  0.004302230620866517
  0.004302230621116968
  0.004353201752854081