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-61.0e-6Density-based self-consistent field
scfres_scf = self_consistent_field(basis; tol);n Energy log10(ΔE) log10(Δρ) Diag Δtime
--- --------------- --------- --------- ---- ------
1 -8.397902078475 -0.90 5.2 27.9ms
2 -8.400252313138 -2.63 -1.74 1.0 19.9ms
3 -8.400406949396 -3.81 -2.98 1.5 20.7ms
4 -8.400427864530 -4.68 -3.00 3.0 24.6ms
5 -8.400427950102 -7.07 -3.05 1.0 19.7ms
6 -8.400428145974 -6.71 -4.68 1.0 31.6ms
7 -8.400428151816 -8.23 -4.47 2.8 24.9ms
8 -8.400428152183 -9.43 -5.19 1.0 20.1ms
9 -8.400428152207 -10.63 -6.29 1.2 20.6msPotential-based SCF
scfres_scfv = DFTK.scf_potential_mixing(basis; tol);n Energy log10(ΔE) log10(Δρ) α Diag Δtime
--- --------------- --------- --------- ---- ---- ------
1 -8.397887450077 -0.90 5.5 28.4ms
2 -8.400385295625 -2.60 -1.79 0.80 2.0 30.3ms
3 -8.400422663555 -4.43 -3.01 0.80 1.0 17.4ms
4 -8.400428118605 -5.26 -3.44 0.80 2.5 21.9ms
5 -8.400428149791 -7.51 -4.85 0.80 1.2 17.8ms
6 -8.400428152203 -8.62 -5.76 0.80 3.0 23.1ms
7 -8.400428152209 -11.26 -6.35 0.80 1.8 19.3msDirect 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.327526420825 -1.06 58.6ms
2 -1.205858674623 0.40 -0.67 42.4ms
3 -4.266569519889 0.49 -0.35 44.9ms
4 -5.832031466196 0.19 -0.44 44.5ms
5 -7.412025995759 0.20 -0.66 44.6ms
6 -7.858547694203 -0.35 -1.26 41.9ms
7 -8.218725022551 -0.44 -1.51 33.2ms
8 -8.315445717108 -1.01 -1.88 32.9ms
9 -8.370729146880 -1.26 -2.23 33.0ms
10 -8.383710138994 -1.89 -2.46 33.2ms
11 -8.392941080978 -2.03 -2.58 33.2ms
12 -8.397244605412 -2.37 -3.30 41.6ms
13 -8.399182412687 -2.71 -3.00 33.9ms
14 -8.399960931300 -3.11 -3.42 33.6ms
15 -8.400170385799 -3.68 -3.52 32.9ms
16 -8.400349865189 -3.75 -4.02 32.8ms
17 -8.400384313982 -4.46 -3.78 32.8ms
18 -8.400412018397 -4.56 -4.09 41.1ms
19 -8.400419101520 -5.15 -4.19 33.1ms
20 -8.400423949656 -5.31 -4.97 33.3ms
21 -8.400425599965 -5.78 -4.64 32.9ms
22 -8.400427192402 -5.80 -4.81 32.9ms
23 -8.400427738293 -6.26 -4.89 32.7ms
24 -8.400427983221 -6.61 -5.11 41.7ms
25 -8.400428075070 -7.04 -5.20 33.1ms
26 -8.400428121973 -7.33 -5.42 32.7ms
27 -8.400428139799 -7.75 -5.42 32.7ms
28 -8.400428146791 -8.16 -5.71 33.0ms
29 -8.400428150322 -8.45 -6.13 33.0msNewton 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.397861761834 -0.90 5.0 27.2msRemove 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.400427942446 -1.78 555ms
2 -8.400428152209 -6.68 -3.97 353ms
3 -8.400428152209 -14.27 -7.73 92.2msComparison 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.4171283963674658e-6
|ρ_newton - ρ_scfv| = 3.1610814103727794e-7
|ρ_newton - ρ_dm| = 1.950184023618165e-6