Hybrid DFT band structures
In this example we discuss how to compute hybrid DFT bands structures using DFTK.
Hybrid-DFT in DFTK is still in its early stages. MPI parallelisation does not work and all treatment of $k$-point symmetry is disabled when using exact exchange terms. We appreciate any issues, bug reports or PRs.
using AtomsBuilder
using DFTK
using PseudoPotentialData
using Wannier
using Brillouin
using CairoMakie
using Unitful
using UnitfulAtomic
pseudopotentials = PseudoFamily("dojo.nc.sr.pbe.v0_5.stringent.upf")
system = bulk(:Si)FlexibleSystem(Si₂, periodicity = TTT):
cell_vectors : [ 0 2.715 2.715;
2.715 0 2.715;
2.715 2.715 0]u"Å"
Atom(Si, [ 0, 0, 0]u"Å")
Atom(Si, [ 1.3575, 1.3575, 1.3575]u"Å")
SCF calculation
We first perform a PBE calculation to get a good starting point. Since we will later Wannierise we make sure to converge 16 orbitals throughout the computational procedure. Exact exchange does not yet support symmetry-reduced k-point grids, hence we use the full grid already for PBE.
model_PBE = model_DFT(system; pseudopotentials, functionals=PBE())
basis_PBE = PlaneWaveBasis(model_PBE; Ecut=10, kgrid=[3, 3, 3], # Not converged !
use_symmetries_for_kpoint_reduction=false)
nbandsalg = AdaptiveBands(model_PBE; n_bands_converge=16)
scfres_PBE = self_consistent_field(basis_PBE; tol=1e-4, nbandsalg)
nothing # hiden Energy log10(ΔE) log10(Δρ) Diag Δtime
--- --------------- --------- --------- ---- ------
1 -8.436111228236 -0.91 5.6 27.4s
2 -8.438610026515 -2.60 -1.78 1.0 7.29s
3 -8.438665076929 -4.26 -2.70 2.5 401ms
4 -8.438668837272 -5.42 -3.54 3.1 542ms
5 -8.438668912678 -7.12 -4.65 2.9 482ms
Next we converge an HSE calculation with the default number of bands, again in two steps. First using a more aggressive ACE compression techniques that is more memory efficient and slightly faster (by ignoring all unoccupied orbitals), but that gives the wrong unoccupied bands.
model = model_DFT(system; pseudopotentials, functionals=HSE())
basis = PlaneWaveBasis(model; basis_PBE.Ecut, basis_PBE.kgrid,
use_symmetries_for_kpoint_reduction=false)
exxalg = AceExx(; sketch_with_extra_orbitals=false)
scfres = self_consistent_field(basis; tol=1e-6, scfres_PBE.ρ, scfres_PBE.ψ, scfres_PBE.occupation, exxalg,
scfres_PBE.eigenvalues, solver=ScfDampingSolver(), scfres_PBE.nbandsalg,
diagtolalg=AdaptiveDiagtol(; diagtol_max=1e-2, ratio_ρdiff=0.0005));
nothing # hiden Energy log10(ΔE) log10(Δρ) Diag Δtime
--- --------------- --------- --------- ---- ------
1 -8.310625349988 -2.16 1.0 10.7s
2 -8.310675922563 -4.30 -2.60 1.0 8.74s
3 -8.310679198653 -5.48 -3.14 11.0 9.69s
4 -8.310679222367 -7.62 -3.82 7.2 9.18s
5 -8.310679224037 -8.78 -4.59 7.7 9.37s
6 -8.310679224148 -9.95 -5.41 9.1 10.1s
7 -8.310679224295 -9.83 -6.20 11.0 9.77s
Finally converge the HSE calculation with laxer ACE compression, that also takes the unoccupied orbitals into account (such that virtual bands are accurate)
exxalg = AceExx(; sketch_with_extra_orbitals=true)
scfres = self_consistent_field(basis; tol=1e-7, scfres.ρ, scfres.ψ, scfres.occupation, exxalg,
scfres.eigenvalues, scfres.solver, scfres.nbandsalg, miniter=2,
diagtolalg=AdaptiveDiagtol(; diagtol_max=1e-6, ratio_ρdiff=0.0005))
nothing # hiden Energy log10(ΔE) log10(Δρ) Diag Δtime
--- --------------- --------- --------- ---- ------
1 -8.310679224181 -7.36 8.8 26.6s
2 -8.310679224079 + -9.99 -7.84 4.7 29.2s
Band structure computation
For the PBE model we can directly use the compute_bands function of DFTK:
kpath = irrfbz_path(model)
bands_PBE = compute_bands(scfres_PBE, kpath; n_bands=12)
# Convert band data to format expected by Brillouin and to eV:
E_PBE = reduce(hcat, bands_PBE.eigenvalues)
E_PBE = ustrip.(auconvert.(u"eV", E_PBE))
E_PBE = E_PBE .- maximum(E_PBE[1:4, :])
nothing # hideFor HSE we proceed via wannierization. For this we setup SP3 projectors for silicon atoms:
projections = [DFTK.wannier_projectors_sp3(model.positions[1]);
DFTK.wannier_projectors_sp3(model.positions[2])]
# Set the frozen window size. Since this is an insulator, about 2eV above the Fermi level
# should be good.
dis_froz_max = scfres.εF + austrip(2u"eV")
wannier_model = Wannier.Model(scfres;
n_wannier=length(projections),
n_bands=12,
projections,
dis_froz_max)
# Run disentanglement, returns a (n_bands, n_wann, n_kpts) array
U = disentangle(wannier_model; max_iter=500);
# InterpModel builds H(R) from model.U, so we store the U giving maximal localisation there
wannier_model.U .= U
nothing # hideb-vector shell 1 weight = 0.84022
1 -0.38571 0.38571 -0.38571
2 0.38571 0.38571 -0.38571
3 0.38571 -0.38571 0.38571
4 0.38571 -0.38571 -0.38571
5 0.38571 0.38571 0.38571
6 -0.38571 -0.38571 -0.38571
7 -0.38571 -0.38571 0.38571
8 -0.38571 0.38571 0.38571
Finite difference condition satisfied
[ Info: Initial spread
WF center [rx, ry, rz]/Šspread/Ų
1 0.23539 0.23511 0.23538 1.91974
2 0.23655 -0.23706 -0.23711 1.92362
3 -0.23694 0.23608 -0.23693 1.92301
4 -0.23712 -0.23706 0.23653 1.92362
5 1.74201 1.74219 1.74203 1.68462
6 1.74057 0.97478 0.97479 1.69209
7 0.97458 1.74098 0.97456 1.69092
8 0.97481 0.97477 1.74060 1.69208
Sum spread: Ω = ΩI + Ω̃, Ω̃ = ΩOD + ΩD
ΩI = 9.51576
Ω̃ = 4.93394
ΩOD = 4.85681
ΩD = 0.07713
Ω = 14.44970
[ Info: Initial spread (with states freezed)
WF center [rx, ry, rz]/Šspread/Ų
1 0.24231 0.24232 0.24230 1.94248
2 0.24231 -0.24232 -0.24230 1.94248
3 -0.24231 0.24232 -0.24230 1.94248
4 -0.24231 -0.24232 0.24230 1.94248
5 1.72517 1.72515 1.72518 1.75897
6 1.72517 0.98985 0.98982 1.75897
7 0.98983 1.72515 0.98982 1.75897
8 0.98983 0.98985 1.72518 1.75897
Sum spread: Ω = ΩI + Ω̃, Ω̃ = ΩOD + ΩD
ΩI = 9.95815
Ω̃ = 4.84765
ΩOD = 4.77514
ΩD = 0.07251
Ω = 14.80580
┌ Warning: f_tol is deprecated. Use f_abstol or f_reltol instead. The provided value (1.0e-7) will be used as f_reltol.
└ @ Optim ~/.julia/packages/Optim/gmigl/src/types.jl:120
Iter Function value Gradient norm
0 1.480580e+01 6.653993e-01
* time: 0.0011200904846191406
1 1.338353e+01 6.584362e-02
* time: 0.5244240760803223
2 1.301391e+01 4.349027e-02
* time: 0.5313401222229004
3 1.292971e+01 1.911976e-02
* time: 0.5410189628601074
4 1.290487e+01 1.023391e-02
* time: 0.5544099807739258
5 1.289481e+01 6.130904e-03
* time: 0.5687119960784912
6 1.288966e+01 6.099641e-03
* time: 0.6559081077575684
7 1.288662e+01 3.786489e-03
* time: 0.664531946182251
8 1.288530e+01 2.800881e-03
* time: 0.6729140281677246
9 1.288482e+01 1.712853e-03
* time: 0.6812291145324707
10 1.288470e+01 9.798209e-04
* time: 0.6873669624328613
11 1.288463e+01 5.373361e-04
* time: 0.7006990909576416
12 1.288460e+01 4.281492e-04
* time: 0.7143280506134033
13 1.288459e+01 3.119719e-04
* time: 0.7276380062103271
14 1.288458e+01 3.315773e-04
* time: 0.7412910461425781
15 1.288457e+01 1.340888e-04
* time: 0.754626989364624
16 1.288457e+01 2.121142e-04
* time: 0.8176600933074951
17 1.288457e+01 2.063867e-04
* time: 0.8260941505432129
18 1.288456e+01 2.540948e-04
* time: 0.8344380855560303
19 1.288455e+01 1.504892e-04
* time: 0.842656135559082
20 1.288455e+01 8.673187e-05
* time: 0.8489689826965332
21 1.288455e+01 8.977074e-05
* time: 0.8611011505126953
22 1.288455e+01 1.779330e-04
* time: 0.8743979930877686
23 1.288454e+01 3.617957e-04
* time: 0.8877370357513428
24 1.288451e+01 8.972112e-04
* time: 0.9047970771789551
25 1.288440e+01 1.476399e-03
* time: 0.9180760383605957
26 1.288435e+01 1.794753e-03
* time: 0.9275171756744385
27 1.288419e+01 2.459966e-03
* time: 0.93709397315979
28 1.288391e+01 3.364460e-03
* time: 0.971764087677002
29 1.288263e+01 5.010165e-03
* time: 0.9801161289215088
30 1.287841e+01 9.893518e-03
* time: 0.9883980751037598
31 1.286630e+01 2.019251e-02
* time: 0.9967761039733887
32 1.284632e+01 2.233012e-02
* time: 1.005566120147705
33 1.280166e+01 2.634991e-02
* time: 1.015160083770752
34 1.270534e+01 5.436489e-02
* time: 1.0286469459533691
35 1.257646e+01 3.115697e-02
* time: 1.0420920848846436
36 1.250884e+01 1.873911e-02
* time: 1.067397117614746
37 1.245650e+01 1.819997e-02
* time: 1.0734431743621826
38 1.242358e+01 2.012622e-02
* time: 1.0818390846252441
39 1.237962e+01 2.339968e-02
* time: 1.0900790691375732
40 1.232386e+01 3.561202e-02
* time: 1.0983760356903076
41 1.224739e+01 4.133344e-02
* time: 1.1049489974975586
42 1.214542e+01 3.508910e-02
* time: 1.1144969463348389
43 1.207287e+01 2.808222e-02
* time: 1.1362690925598145
44 1.201245e+01 1.755089e-02
* time: 1.1447770595550537
45 1.197841e+01 1.762946e-02
* time: 1.153109073638916
46 1.195268e+01 1.618348e-02
* time: 1.1616110801696777
47 1.193708e+01 1.173416e-02
* time: 1.1698839664459229
48 1.192764e+01 6.912925e-03
* time: 1.1805319786071777
49 1.192254e+01 6.500755e-03
* time: 1.2010290622711182
50 1.191930e+01 5.567467e-03
* time: 1.2095179557800293
51 1.191699e+01 5.529490e-03
* time: 1.2178621292114258
52 1.191521e+01 3.226402e-03
* time: 1.226196050643921
53 1.191384e+01 3.131208e-03
* time: 1.2344470024108887
54 1.191292e+01 3.231453e-03
* time: 1.2568550109863281
55 1.191232e+01 2.354888e-03
* time: 1.2651700973510742
56 1.191187e+01 1.801957e-03
* time: 1.2733721733093262
57 1.191153e+01 1.590562e-03
* time: 1.2816030979156494
58 1.191132e+01 1.251791e-03
* time: 1.2897231578826904
59 1.191115e+01 1.606033e-03
* time: 1.3005330562591553
60 1.191105e+01 1.252105e-03
* time: 1.3193609714508057
61 1.191096e+01 6.937394e-04
* time: 1.3275530338287354
62 1.191089e+01 7.796842e-04
* time: 1.3357911109924316
63 1.191085e+01 5.678645e-04
* time: 1.343991994857788
64 1.191082e+01 5.068214e-04
* time: 1.3527860641479492
65 1.191080e+01 4.344873e-04
* time: 1.3748650550842285
66 1.191079e+01 2.673175e-04
* time: 1.3831870555877686
67 1.191078e+01 1.324783e-04
* time: 1.3913471698760986
68 1.191078e+01 1.257266e-04
* time: 1.3994970321655273
69 1.191078e+01 1.027796e-04
* time: 1.407560110092163
70 1.191078e+01 8.272630e-05
* time: 1.4191761016845703
71 1.191078e+01 5.578092e-05
* time: 1.4371631145477295
[ Info: Final spread
WF center [rx, ry, rz]/Šspread/Ų
1 -0.45361 -0.45364 -0.45383 1.48878
2 0.45367 0.45361 -0.45382 1.48897
3 -0.45359 0.45371 0.45365 1.48875
4 0.45385 -0.45363 0.45353 1.48881
5 1.81129 1.81115 1.81106 1.48901
6 1.81127 0.90394 0.90367 1.48893
7 0.90394 1.81122 0.90366 1.48884
8 0.90387 0.90378 1.81114 1.48868
Sum spread: Ω = ΩI + Ω̃, Ω̃ = ΩOD + ΩD
ΩI = 9.65330
Ω̃ = 2.25747
ΩOD = 2.16572
ΩD = 0.09175
Ω = 11.91078
Based on the Wannier functions compute the bands via Wannier interpolation
interp_model = Wannier.InterpModel(wannier_model; kpath)
kinter = Brillouin.interpolate(kpath, density=40) # same density as in DFTK by default
data = Wannier.interpolate(interp_model, kinter)
E_HSE = data .- maximum(data[1:4, :])
nothing # hidePlot the bands
Finally we plot the bands using the Makie interface of Brillouin:
fig = Figure(size=(700, 500))
CairoMakie.plot(fig[1, 1], kinter, permutedims(E_HSE), permutedims(E_PBE);
label=["HSE", "PBE"],
ylabel="E - E_VBM (eV)",
ylims=(-13.0, 10.0),
linewidth=2,
linestyle=[:solid, :dash],
color=[:royalblue, :black])
figFurther reading
For more details on Wannierisation, see also Wannierization using Wannier.jl or Wannier90.