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.397595547823                   -0.90    5.2   14.9ms
  2   -8.400216132026       -2.58       -1.72    1.0   11.1ms
  3   -8.400396567672       -3.74       -2.98    1.2   11.1ms
  4   -8.400427718628       -4.51       -2.92    3.2   13.7ms
  5   -8.400428059405       -6.47       -3.26    1.0   11.0ms
  6   -8.400428149456       -7.05       -4.75    1.0   11.1ms
  7   -8.400428151897       -8.61       -4.55    2.2   12.6ms
  8   -8.400428152174       -9.56       -5.08    1.0   11.0ms
  9   -8.400428152206      -10.49       -6.49    1.0   11.1ms

Potential-based SCF

scfres_scfv = DFTK.scf_potential_mixing(basis; tol);
n     Energy            log10(ΔE)   log10(Δρ)   α      Diag   Δtime 
---   ---------------   ---------   ---------   ----   ----   ------
  1   -8.397625698085                   -0.90           5.2    1.18s
  2   -8.400387844917       -2.56       -1.78   0.80    2.0    705ms
  3   -8.400423929274       -4.44       -2.95   0.80    1.0    138ms
  4   -8.400428114082       -5.38       -3.51   0.80    2.2   11.9ms
  5   -8.400428149348       -7.45       -4.80   0.80    1.2   10.8ms
  6   -8.400428152198       -8.55       -5.42   0.80    2.8   13.0ms
  7   -8.400428152208      -10.97       -6.20   0.80    1.5   11.0ms

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   +0.798691096991                   -1.05    2.43s
  2   -1.727161992186        0.40       -0.67    102ms
  3   -4.661543199845        0.47       -0.43   28.5ms
  4   -6.364598854318        0.23       -0.48   28.8ms
  5   -7.642801777551        0.11       -0.89   28.4ms
  6   -7.996806777181       -0.45       -1.34   20.7ms
  7   -8.112638170658       -0.94       -1.83   20.5ms
  8   -8.190080996304       -1.11       -1.80   20.7ms
  9   -8.255381515125       -1.19       -1.88   23.8ms
 10   -8.320371474723       -1.19       -1.78    118ms
 11   -8.360032709374       -1.40       -1.92   20.8ms
 12   -8.384207434286       -1.62       -1.90   20.6ms
 13   -8.392402163180       -2.09       -2.58   21.0ms
 14   -8.397051975563       -2.33       -2.42   21.2ms
 15   -8.398974586163       -2.72       -2.79   21.2ms
 16   -8.399805053972       -3.08       -2.80   21.4ms
 17   -8.400201033174       -3.40       -3.43   21.1ms
 18   -8.400332849774       -3.88       -3.24   21.0ms
 19   -8.400390340171       -4.24       -4.18   20.7ms
 20   -8.400406606308       -4.79       -3.71   53.0ms
 21   -8.400420133518       -4.87       -3.99   21.5ms
 22   -8.400423965956       -5.42       -4.09   21.4ms
 23   -8.400426360960       -5.62       -4.24   21.2ms
 24   -8.400427335453       -6.01       -4.43   21.9ms
 25   -8.400427845705       -6.29       -4.60   21.8ms
 26   -8.400428021619       -6.75       -4.77   22.6ms
 27   -8.400428095171       -7.13       -5.10   21.6ms
 28   -8.400428125284       -7.52       -5.36   21.5ms
 29   -8.400428139485       -7.85       -5.31   35.3ms
 30   -8.400428146888       -8.13       -6.13   21.7ms

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.397522027056                   -0.90    4.8   14.9ms

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.400427946106                   -1.78    6.28s
  2   -8.400428152209       -6.69       -3.97    2.41s
  3   -8.400428152209      -14.27       -7.76   94.5ms

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|  = 1.0816203963578513e-6
|ρ_newton - ρ_scfv| = 4.319023640616002e-7
|ρ_newton - ρ_dm|   = 4.07218150184119e-6