Skip to content

Commit 6cda810

Browse files
committed
Function for discrete spectral density
1 parent b387d5a commit 6cda810

File tree

2 files changed

+90
-4
lines changed

2 files changed

+90
-4
lines changed

src/MPSDynamics.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export MPOtoVector
173173

174174
export rhoreduced_2sites, rhoreduced_1site, protontransfermpo
175175

176-
export chaincoeffs_finiteT, chaincoeffs_fermionic, fermionicspectraldensity_finiteT
176+
export chaincoeffs_finiteT, chaincoeffs_fermionic, fermionicspectraldensity_finiteT, chaincoeffs_finiteT_discrete
177177

178178
end
179179

src/finitetemperature.jl

Lines changed: 89 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function chaincoeffs_finiteT(nummodes, β, ohmic=true; α=1, s=1, J=nothing, ωc
3838
else
3939
throw(ArgumentError("An interval AB with mc = $mc components should have been provided."))
4040
end
41-
elseif length(AB) != 2*mc
41+
elseif size(AB)[1] != mc
4242
throw(ArgumentError("AB has a different number of intervals than mc = $mc."))
4343
end
4444

@@ -118,7 +118,7 @@ function chaincoeffs_finiteT(nummodes, β, ohmic=true; α=1, s=1, J=nothing, ωc
118118
end
119119

120120
"""
121-
chaincoeffs_fermionic(nummodes, β, chain; ϵ=nothing, J=nothing, ωc=1, mc=4, mp=0, AB=nothing, iq=1, idelta=2, procedure=:Lanczos, Mmax=5000, save=true)
121+
chaincoeffs_fermionic(nummodes, β, chain; ϵ=x, ωc=1, mc=4, mp=0, AB=nothing, iq=1, idelta=2, procedure=:Lanczos, Mmax=5000, save=true)
122122
123123
Generate chain coefficients ``[[ϵ_0,ϵ_1,...],[t_0,t_1,...],c_0]`` for a fermionic bath at the inverse temperature β.
124124
@@ -148,7 +148,7 @@ function chaincoeffs_fermionic(nummodes, β, chain; ϵ=nothing, J=nothing, ωc=1
148148
else
149149
throw(ArgumentError("An interval AB with mc = $mc components should have been provided."))
150150
end
151-
elseif length(AB) != 2* mc
151+
elseif size(AB)[1] != mc
152152
throw(ArgumentError("AB has a different number of intervals than mc = $mc."))
153153
end
154154

@@ -208,3 +208,89 @@ function chaincoeffs_fermionic(nummodes, β, chain; ϵ=nothing, J=nothing, ωc=1
208208

209209
return [jacerg[:,1], jacerg[1:N-1,2],jacerg[N,2]]
210210
end
211+
212+
213+
"""
214+
chaincoeffs_finiteT_discrete(β, ωdiscrete, Jωdiscrete; procedure=:Lanczos, Mmax=5000, save=true)
215+
216+
Generate chain coefficients ``[[ϵ_0,ϵ_1,...],[t_0,t_1,...],c_0]`` for a discrete harmonic bath at the inverse temperature β.
217+
218+
# Arguments
219+
* β: inverse temperature. For 0 Kelvin, put Inf as β
220+
* ωdiscrete: discrete frequency corresponding to the Jωdiscrete values
221+
* Jωdiscrete: amplitude of the spectral density at the corresponding ωdiscrete
222+
* procedure: choice between the Stieltjes and the Lanczos procedure
223+
* Mmax: maximum number of integration points
224+
* save: if true the coefficients are saved
225+
"""
226+
function chaincoeffs_finiteT_discrete(β, ωdiscrete, Jωdiscrete; procedure=:Lanczos, Mmax=5000, save=true)
227+
228+
ω = ωdiscrete
229+
= Jωdiscrete
230+
length(ω)== length(Jω) || throw(ErrorException("J(ω) has $(length(Jω)) values while there is $(length(ω)) frequecencies"))
231+
N=length(ω) #Number of bath modes
232+
if β != Inf
233+
ω_pos = ω
234+
Jω_pos =.* (coth.((β/2).*ω_pos[:]) .+ 1) ./2
235+
236+
ω_neg = -ω
237+
Jω_neg = -.* (coth.((β/2).*ω_neg[:]) .+ 1) ./2
238+
239+
ω = vcat(ω_neg,ω_pos)
240+
= vcat(Jω_neg,Jω_pos)
241+
end
242+
mp=length(ω) # the number of points in the discrete part of the measure
243+
244+
DM =Array{Float64}(undef,mp,2)
245+
for i=1:mp
246+
DM[i,1] = ω[i]
247+
DM[i,2] = Jω[i]
248+
end
249+
250+
eps0=1e7*eps(Float64)
251+
252+
jacerg = zeros(N,2)
253+
254+
ab = Array{Float64}(undef, N, 2)
255+
ab[:,2] = zeros(N,1)
256+
257+
if procedure==:Lanczos # choice between the Stieltjes and the Lanczos procedure
258+
ab = lanczos(N,DM)
259+
elseif procedure==:Stieltjes
260+
ab = stieltjes(N,DM)
261+
else
262+
throw(ArgumentError("Procedure should be either Lanczos or Stieltjes."))
263+
end
264+
265+
for m = 1:N-1
266+
jacerg[m,1] = ab[m,1] #site energy
267+
jacerg[m,2] = sqrt(ab[m+1,2]) #hopping parameter
268+
end
269+
jacerg[N,1] = ab[N,1]
270+
271+
eta = sum(Jω)
272+
273+
jacerg[N,2] = sqrt(eta) #coupling coeficient
274+
275+
if save==true
276+
# Write a HDF5 file
277+
#curdir = @__DIR__
278+
dir = @__DIR__
279+
curdir = abspath(joinpath(dir, "../ChainOhmT"))
280+
281+
Nstr = string(N)
282+
bstr = string(β)
283+
# the "path" to the data inside of the h5 file is N -> ωc -> beta -> data (e, t or c)
284+
285+
# Write onsite energies
286+
h5write("$curdir/discreteT/chaincoeffs.h5", string("/", Nstr, "/", bstr, "/e"), jacerg[1:N,1])
287+
# Write opping energies
288+
h5write("$curdir/discreteT/chaincoeffs.h5", string("/", Nstr, "/", bstr,"/t"), jacerg[1:N-1,2])
289+
# Write coupling coefficient
290+
h5write("$curdir/discreteT/chaincoeffs.h5", string("/", Nstr, "/", bstr,"/c"), jacerg[N,2])
291+
292+
end
293+
294+
return [jacerg[:,1], jacerg[1:N-1,2],jacerg[N,2]]
295+
end
296+

0 commit comments

Comments
 (0)