Comparison of DFT solvers

We compare four different approaches for solving the DFT minimisation problem, namely a density-based SCF, a potential-based SCF, direct minimisation and Newton.

First we setup our problem

using AtomsBuilder
using DFTK
using LinearAlgebra
using PseudoPotentialData

pseudopotentials = PseudoFamily("dojo.nc.sr.pbesol.v0_4_1.standard.upf")
model = model_DFT(bulk(:Si); functionals=PBEsol(), pseudopotentials)
basis = PlaneWaveBasis(model; Ecut=5, kgrid=[3, 3, 3])

# Convergence we desire in the density
tol = 1e-6
1.0e-6

Density-based self-consistent field

scfres_scf = self_consistent_field(basis; tol);
n     Energy            log10(ΔE)   log10(Δρ)   Diag   Δtime 
---   ---------------   ---------   ---------   ----   ------
  1   -8.397586700588                   -0.90    5.5   23.0ms
  2   -8.400211697244       -2.58       -1.72    1.0   15.8ms
  3   -8.400389540141       -3.75       -2.95    1.2   16.6ms
  4   -8.400427704519       -4.42       -2.88    3.2   20.4ms
  5   -8.400428060072       -6.45       -3.24    1.0   15.5ms
  6   -8.400428148820       -7.05       -4.64    1.0   15.6ms
  7   -8.400428151975       -8.50       -4.62    2.5   18.6ms
  8   -8.400428152165       -9.72       -4.96    1.0   49.2ms
  9   -8.400428152206      -10.38       -6.01    1.0   15.6ms

Potential-based SCF

scfres_scfv = DFTK.scf_potential_mixing(basis; tol);
n     Energy            log10(ΔE)   log10(Δρ)   α      Diag   Δtime 
---   ---------------   ---------   ---------   ----   ----   ------
  1   -8.397558396196                   -0.90           5.2    1.57s
  2   -8.400387427603       -2.55       -1.79   0.80    2.0    604ms
  3   -8.400423567488       -4.44       -3.00   0.80    1.0    218ms
  4   -8.400428108650       -5.34       -3.50   0.80    2.5    120ms
  5   -8.400428150604       -7.38       -4.96   0.80    1.2   15.1ms
  6   -8.400428152198       -8.80       -5.62   0.80    3.2   18.9ms
  7   -8.400428152209      -10.98       -6.12   0.80    2.0   16.3ms

Direct minimization

scfres_dm = direct_minimization(basis; tol);
┌ Warning: x_tol is deprecated. Use x_abstol or x_reltol instead. The provided value (-1) will be used as x_abstol.
└ @ Optim ~/.julia/packages/Optim/gmigl/src/types.jl:110
┌ Warning: f_tol is deprecated. Use f_abstol or f_reltol instead. The provided value (-1) will be used as f_reltol.
└ @ Optim ~/.julia/packages/Optim/gmigl/src/types.jl:120
n     Energy            log10(ΔE)   log10(Δρ)   Δtime 
---   ---------------   ---------   ---------   ------
  1   +1.225305626499                   -1.11    3.06s
  2   -1.512120997416        0.44       -0.70    139ms
  3   -4.271703248990        0.44       -0.39    108ms
  4   -5.735104225364        0.17       -0.52   36.9ms
  5   -7.420407378585        0.23       -0.64   36.8ms
  6   -7.504104115091       -1.08       -1.33   27.3ms
  7   -8.061717002537       -0.25       -1.53   27.0ms
  8   -8.146249932824       -1.07       -2.03   26.9ms
  9   -8.303585226188       -0.80       -1.77   60.3ms
 10   -8.332200499727       -1.54       -2.25   27.0ms
 11   -8.361017235410       -1.54       -2.10   27.5ms
 12   -8.381327850360       -1.69       -2.08   26.7ms
 13   -8.391207670380       -2.01       -2.68   26.6ms
 14   -8.397020910974       -2.24       -2.90   26.8ms
 15   -8.398820912712       -2.74       -2.92   35.0ms
 16   -8.399836233807       -2.99       -3.07   26.8ms
 17   -8.400117924045       -3.55       -3.64   26.7ms
 18   -8.400319112769       -3.70       -3.81   26.8ms
 19   -8.400369169359       -4.30       -3.66   26.8ms
 20   -8.400409059778       -4.40       -3.90   26.7ms
 21   -8.400416861139       -5.11       -4.21   35.2ms
 22   -8.400424452358       -5.12       -4.22   26.8ms
 23   -8.400426215929       -5.75       -4.87   26.5ms
 24   -8.400427275297       -5.97       -4.76   26.7ms
 25   -8.400427772125       -6.30       -4.96   26.8ms
 26   -8.400428006943       -6.63       -5.49   35.6ms
 27   -8.400428092472       -7.07       -5.36   26.8ms
 28   -8.400428130396       -7.42       -5.45   26.6ms
 29   -8.400428139030       -8.06       -6.08   26.5ms

Newton algorithm

Start not too far from the solution to ensure convergence: We run first a very crude SCF to get close and then switch to Newton.

scfres_start = self_consistent_field(basis; tol=0.5);
n     Energy            log10(ΔE)   log10(Δρ)   Diag   Δtime 
---   ---------------   ---------   ---------   ----   ------
  1   -8.397498427839                   -0.90    5.0   22.4ms

Remove the virtual orbitals (which Newton cannot treat yet)

ψ = DFTK.select_occupied_orbitals(basis, scfres_start.ψ, scfres_start.occupation).ψ
scfres_newton = newton(basis, ψ; tol);
n     Energy            log10(ΔE)   log10(Δρ)   Δtime 
---   ---------------   ---------   ---------   ------
  1   -8.400427985828                   -1.80    10.6s
  2   -8.400428152209       -6.78       -4.04    3.27s
  3   -8.400428152209      -14.75       -7.86   62.8ms

Comparison of results

println("|ρ_newton - ρ_scf|  = ", norm(scfres_newton.ρ - scfres_scf.ρ))
println("|ρ_newton - ρ_scfv| = ", norm(scfres_newton.ρ - scfres_scfv.ρ))
println("|ρ_newton - ρ_dm|   = ", norm(scfres_newton.ρ - scfres_dm.ρ))
|ρ_newton - ρ_scf|  = 8.667897229563328e-7
|ρ_newton - ρ_scfv| = 3.0334470752850154e-7
|ρ_newton - ρ_dm|   = 5.319357532967616e-6