-
Notifications
You must be signed in to change notification settings - Fork 83
/
DFTKWannierExt.jl
43 lines (36 loc) · 1.18 KB
/
DFTKWannierExt.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
module DFTKWannierExt
using DFTK
import Wannier
"""
Use Wannier.jl to read a .win file and produce the nnkp data (i.e. the b-vectors used in the Mmn matrix).
"""
function get_nnkpt_from_wannier(fileprefix)
model = Wannier.read_w90(fileprefix; amn=false, mmn=false, eig=false)
bvectors = model.bvectors
nnkpts = reduce(vcat,
map(1:model.n_kpts) do ik
zp = zip(bvectors.kpb_k[:, ik], eachcol(bvectors.kpb_b[:, :, ik]))
map(zp) do (ikpb, G_shift)
(ik, ikpb, G_shift=copy(G_shift))
end
end)
(; nntot=model.n_bvecs, nnkpts)
end
"""
Build a Wannier.jl model that can be used for Wannierization.
"""
@DFTK.timing function Wannier.Model(scfres;
n_bands=scfres.n_bands_converge,
n_wannier=n_bands,
projections=DFTK.default_wannier_centers(n_wannier),
fileprefix=joinpath("wannierjl", "wannier"),
wannier_plot=false,
kwargs...)
# Write the files
DFTK.write_wannier90_files(scfres; n_bands, n_wannier, projections, fileprefix, wannier_plot, kwargs...) do
get_nnkpt_from_wannier(fileprefix)
end
# Read Wannier.jl model
Wannier.read_w90(fileprefix)
end
end