Skip to content

Commit a0b0bdb

Browse files
committed
spectral functio response
1 parent 565292c commit a0b0bdb

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

src/SpectralResponse.jl

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
module SpecResponse
2+
3+
using LinearAlgebra
4+
5+
using ..TightBindingToolkit.BZone: BZ, GetQIndex
6+
using ..TightBindingToolkit.Hams: Hamiltonian
7+
using ..TightBindingToolkit.Useful: DistFunction
8+
9+
export spectral, response
10+
11+
12+
13+
function spectral(omega::Float64, eta::Float64, ham::Hamiltonian)
14+
15+
G = Ref((omega+im*eta)*I) .- ham.H
16+
G = inv.(G)
17+
18+
return (G - adjoint.(G)) / (2*im)
19+
end
20+
21+
function spectral(eta::Float64, ham::Hamiltonian ; n_w::Int = 101)
22+
23+
omegas = collect(range(ham.bandwidth..., n_w))
24+
return spectral.(omegas, eta, Ref(ham))
25+
end
26+
27+
28+
function response(omega::Float64, eta::Float64, QIndex::Vector{Int64}, Aws, bandwidth::Tuple{Float64, Float64} ;
29+
n_w::Int = 101, mu::Float64 = 0.0, T::Float64 = 0.001)
30+
31+
es = collect(range(bandwidth..., n_w))
32+
response = zeros(Complex{Float64}, size(Aws[1][1, 1]) .^ 2)
33+
for (i1, e1) in enumerate(es)
34+
for (i2, e2) in enumerate(es)
35+
Ak1 = Aws[i1]
36+
AQk2 = circshift(Aws[i2], -QIndex)
37+
Aksum = sum(kron.(AQk2, Ak1))
38+
nfs = (DistFunction(e1 ; T=T, mu=mu, stat=-1) - DistFunction(e2 ; T=T, mu=mu, stat=1))/(omega +im*eta + e1 - e2)
39+
response += nfs * Aksum
40+
41+
end
42+
end
43+
println("response done")
44+
return response
45+
end
46+
47+
48+
function response(omegas::Vector{Float64}, eta::Float64, Qs::Vector{Vector{Float64}}, ham::Hamiltonian, bz::BZ ;
49+
n_w::Int = 101, mu::Float64 = 0.0, T::Float64 = 0.001)
50+
51+
QIndices = GetQIndex.(Qs, Ref(bz)) .- Ref(GetQIndex(zeros(length(bz.basis)), bz))
52+
Aws = spectral(eta, ham; n_w=n_w)
53+
println("Aws done")
54+
return response.(omegas', Ref(eta), QIndices, Ref(Aws), Ref(ham.bandwidth); n_w=n_w, mu=mu, T=T)
55+
end
56+
57+
58+
59+
60+
61+
62+
63+
64+
65+
66+
67+
68+
69+
70+
71+
72+
73+
74+
75+
76+
77+
78+
79+
80+
81+
82+
83+
84+
85+
86+
87+
end

0 commit comments

Comments
 (0)