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.916455961710                   -0.69    4.8    114ms
  2   -7.921209780229       -2.32       -1.52    1.0   55.7ms
  3   -7.921405800210       -3.71       -2.49    1.2   59.5ms
  4   -7.921440934485       -4.45       -2.82    2.4   77.5ms
  5   -7.921441637524       -6.15       -3.01    1.1   69.5ms
  6   -7.921442007786       -6.43       -4.54    1.0   57.6ms
  7   -7.921442021588       -7.86       -4.49    2.8   85.0ms
  8   -7.921442022121       -9.27       -5.25    1.0   58.3ms
  9   -7.921442022142      -10.67       -5.57    1.5   63.8ms
 10   -7.921442022144      -11.79       -6.01    1.4   62.4ms
 11   -7.921442022144      -12.31       -6.49    1.0   58.3ms
 12   -7.921442022144      -13.24       -6.97    1.8   78.1ms
 13   -7.921442022144      -14.45       -7.45    1.5   66.2ms
 14   -7.921442022144      -15.05       -8.15    1.1   62.2ms

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.02s  Non-interacting
   1        0       1        0.31     52.5   4.94s
   2        0       2       -0.52     47.0   1.28s
   3        0       3       -2.40     41.7   1.22s
   4        0       4       -4.46     29.6   980ms
   5        0       5       -6.46     17.5   718ms
   6        0       6       -8.91      4.0   425ms
   7        1       1       -7.83     55.6   1.91s  Restart
   8        1       2       -8.88      5.6   475ms
                                      72.8   1.77s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      73.0   1.61s  Non-interacting
   1        0       1        0.31     52.5   1.57s
   2        0       2       -0.52     47.0   1.36s
   3        0       3       -2.40     41.7   1.24s
   4        0       4       -4.46     29.6   963ms
   5        0       5       -6.46     17.5   735ms
   6        0       6       -8.91      4.0   428ms
   7        1       1       -7.83     55.6   1.87s  Restart
   8        1       2       -8.88      5.6   466ms
                                      72.7   1.76s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.59s  Non-interacting
   1        0       1        0.31     52.5   1.56s
   2        0       2       -0.52     47.0   1.33s
   3        0       3       -2.40     41.7   1.26s
   4        0       4       -4.46     29.6   982ms
   5        0       5       -6.46     17.5   730ms
   6        0       6       -8.91      4.0   417ms
   7        1       1       -7.83     55.6   1.85s  Restart
   8        1       2       -8.88      5.6   465ms
                                      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.5   1.54s
   2        0       2       -0.52     47.0   1.33s
   3        0       3       -2.40     41.7   1.20s
   4        0       4       -4.46     29.6   956ms
   5        0       5       -6.46     17.5   693ms
   6        0       6       -8.91      4.0   436ms
   7        1       1       -7.83     55.6   1.95s  Restart
   8        1       2       -8.87      5.6   1.64s
                                      72.7   1.84s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.57s  Non-interacting
   1        0       1        0.31     52.5   1.53s
   2        0       2       -0.52     47.0   1.33s
   3        0       3       -2.40     41.7   1.22s
   4        0       4       -4.46     29.6   969ms
   5        0       5       -6.46     17.5   715ms
   6        0       6       -8.91      4.0   423ms
   7        1       1       -7.83     55.6   1.84s  Restart
   8        1       2       -8.87      5.6   464ms
                                      72.7   1.75s  Final orbitals
Iter  Restart  Krydim  log10(res)  avg(CG)  Δtime   Comment
----  -------  ------  ----------  -------  ------  ---------------
                                      72.9   1.60s  Non-interacting
   1        0       1        0.31     52.5   1.56s
   2        0       2       -0.52     47.0   1.34s
   3        0       3       -2.40     41.7   1.24s
   4        0       4       -4.46     29.6   971ms
   5        0       5       -6.46     17.5   730ms
   6        0       6       -8.91      4.0   425ms
   7        1       1       -7.83     55.6   1.87s  Restart
   8        1       2       -8.87      5.6   475ms
                                      72.7   1.79s  Final orbitals
 87.154399 seconds (100.36 M allocations: 80.248 GiB, 8.45% gc time, 7.58% compilation time: 100% of which was recompilation)

These are the final phonon frequencies:

phret_q0.frequencies
6-element Vector{Float64}:
 -0.0034981553608677595
 -0.0029774511605626165
 -0.0029774511603546942
  0.004302230616223761
  0.004302230617405771
  0.004353201748920974