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 44 45
| function Wannier90Read(filenam) f1 = open(filenam) data = readlines(f1) Hr = zeros(Float64,length(data[5:end]),7) hn = 0 hopnum = 0 degen = [] i0 = 1 for da in data[2:end] if i0 == 1 temp = strip(da) temp = replace(temp,r"\s +"=>",") temp = split(temp,[',']) hn = map(x->parse(Float64,x),temp) elseif i0 == 2 temp = strip(da) temp = replace(temp,r"\s +"=>",") temp = split(temp,[',']) hopnum = map(x->parse(Float64,x),temp) elseif i0==3 temp = strip(da) temp = replace(temp,r"\s +"=>",") temp = split(temp,[',']) degen = map(x->parse(Float64,x),temp) else temp = strip(da) temp = replace(temp,r"\s +"=>",") temp = split(temp,[',']) temp = map(x->parse(Float64,x),temp) Hr[i0 - 3,:] = temp[:] end i0 += 1 end return hn,hopnum,degen,Hr end
function hamset(kx::Float64,ky::Float64,kz::Float64) hn,hopnum,degen,Hr = Wannier90Read("wannier90_hr.dat") for i0 in 1:hopnum H += exp(im*Hr[i0*hn^2,1:3]*[kx,ky,kz])*Hr[i0*hn^2,7:8] end end
a1,a2,a3,a4 = Wannier90Read("wannier90_hr.dat") hamset(0.1,0.1,0.0)
|