Skip to content

Commit

Permalink
refactored and brought entanglement calculations into the direct iter…
Browse files Browse the repository at this point in the history
…ation process
  • Loading branch information
abhirup-m committed Oct 1, 2024
1 parent 9741a98 commit 0d5656f
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 77 deletions.
29 changes: 16 additions & 13 deletions examples/Kondo1CK.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,34 @@ p1 = plot(thickness_scaling=1.6, leftmargin=-6mm, bottommargin=-3mm, label="appr
p2 = plot(thickness_scaling=1.6, leftmargin=-6mm, bottommargin=-3mm, label="approx.", xlabel="sites", ylabel="energy per site")
spinFlipCorrd2 = Tuple{String, Vector{Int64}, Float64}[("+-+-", [1, 2, 8, 7], 1.0), ("+-+-", [2, 1, 7, 8], 1.0)]
spinFlipCorrd0 = Tuple{String, Vector{Int64}, Float64}[("+-+-", [1, 2, 4, 3], 1.0), ("+-+-", [2, 1, 3, 4], 1.0)]
savePaths, resultsDict = IterDiag(hamFlow, maxSize;
vneReq = Dict(
"SEE_Imp" => [1, 2],
"SEE_d2" => [1, 2, 7, 8],
"SEE_0" => [3, 4]
)
@time savePaths, resultsDict = IterDiag(hamFlow, maxSize;
symmetries=Char['N', 'S'],
# symmetries=Char['S'],
# symmetries=Char['N'],
magzReq=(m, N) -> -1 m 3,
occReq=(x, N) -> div(N, 2) - 3 x div(N, 2) + 3,
correlationDefDict=Dict("SF0" => spinFlipCorrd0, "SF2" => spinFlipCorrd2),
vneSets=vneReq,
corrMagzReq=(m,N)->m == ifelse(isodd(div(N, 2)), 1, 0),
corrOccReq=(x,N)->x==div(N, 2),
)
vneReq = Dict(
"SEE_Imp" => [1, 2],
"SEE_d2" => [1, 2, 7, 8],
"SEE_0" => [3, 4]
)
mutInfoReq = Dict(
"MI_d0" => ([1,2],[3,4]),
"MI_d1" => ([1,2],[5,6]),
)
@time vneResults = IterVNE(savePaths, vneReq; occReq=(x,N)->x==div(N, 2), magzReq=(m,N)->m == ifelse(isodd(div(N, 2)), 1, 0))
#=@time IterCorrelation(savePaths, spinFlipCorrd2, Dict(); occReq=(x,N)->x==div(N, 2), magzReq=(m,N)->m == ifelse(isodd(div(N, 2)), 1, 0))=#
#=@time vneResults = IterVNE(savePaths, vneReq; occReq=(x,N)->x==div(N, 2), magzReq=(m,N)->m == ifelse(isodd(div(N, 2)), 1, 0))=#
# @time mutInfoResults = IterMutInfo(savePaths, mutInfoReq; occReq=(x,N)->x==div(N, 2), magzReq=(m,N)->m == ifelse(isodd(div(N, 2)), 1, 0))
display([deserialize(path)["results"]["SF2"] for path in savePaths[1:end-1] if !isnothing(deserialize(path)["results"]["SF2"])])
display([deserialize(path)["eigVals"][1] / (initSites + i) for (i, path) in enumerate(savePaths[1:end-1])])
display(vneResults)
# @time display(IterCorrelation(savePaths, spinFlipCorrd2, vneReq; occReq=(x,N)->x==div(N, 2), magzReq=(m,N)->m == ifelse(isodd(div(N, 2)), 1, 0)))
display(resultsDict)
# display(mutInfoResults)
scatter!(p1, [deserialize(path)["results"]["SF2"] for path in savePaths[1:end-1] if !isnothing(deserialize(path)["results"]["SF2"])])
scatter!(p2, initSites:totalSites, [deserialize(path)["eigVals"][1] / (initSites + i) for (i, path) in enumerate(savePaths[1:end-1])])
# scatter!(p1, [deserialize(path)["results"]["SF2"] for path in savePaths[1:end-1] if !isnothing(deserialize(path)["results"]["SF2"])])
# scatter!(p2, initSites:totalSites, [deserialize(path)["eigVals"][1] / (initSites + i) for (i, path) in enumerate(savePaths[1:end-1])])

corrExact = []
energyExact = []
Expand All @@ -77,7 +80,7 @@ mutInfoExact = Dict(k => [] for k in keys(mutInfoReq))
basis = BasisStates(2 * (1 + num); totOccReq=[1 + num], magzReq=[ifelse(isodd(i), 0, 1)], localCriteria=x->x[1]+x[2]==1)
fullHam = vcat(hamFlow[1:i]...)
eigenVals, eigenStates = Spectrum(fullHam, basis)
push!(energyExact, minimum(eigenVals)/(1 + num))
push!(energyExact, minimum(eigenVals)/(2*(1 + num)))
for (k, m) in vneReq
try
push!(vneExact[k], VonNEntropy(eigenStates[1], m))
Expand Down
14 changes: 11 additions & 3 deletions examples/KondoKSpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ totalSites = 7
initSites = 1
kondoJ = 1.
bathInt = -1.5
maxSize = 500
maxSize = 50
dispersion = [ifelse(i % 2 == 1, -1., 1.) for i in 1:totalSites]

function getHamFlow(initSites::Int64, totalSites::Int64, dispersion::Vector{Float64}, kondoJ::Float64, bathInt::Float64)
Expand Down Expand Up @@ -58,13 +58,21 @@ p1 = plot(thickness_scaling=1.6, leftmargin=-6mm, bottommargin=-3mm, label="appr
p2 = plot(thickness_scaling=1.6, leftmargin=-6mm, bottommargin=-3mm, label="approx.", xlabel="sites", ylabel="energy per site")
spinFlipCorrd2 = Tuple{String, Vector{Int64}, Float64}[("+-+-", [1, 2, 8, 7], 1.0), ("+-+-", [2, 1, 7, 8], 1.0)]
spinFlipCorrd0 = Tuple{String, Vector{Int64}, Float64}[("+-+-", [1, 2, 4, 3], 1.0), ("+-+-", [2, 1, 3, 4], 1.0)]

vneReq = Dict(
"SEE_Imp" => [1, 2],
"SEE_1" => [5, 6],
)
savePaths, resultsDict = IterDiag(hamFlow, maxSize;
symmetries=Char['N', 'S'],
# symmetries=Char['S'],
# symmetries=Char['N'],
#=magzReq=(m, N) -> -1 ≤ m ≤ 1,=#
#=occReq=(x, N) -> div(N, 2) - 3 ≤ x ≤ div(N, 2) + 3,=#
magzReq=(m, N) -> -1 m 3,
occReq=(x, N) -> div(N, 2) - 3 x div(N, 2) + 3,
correlationDefDict=Dict("SF0" => spinFlipCorrd0, "SF2" => spinFlipCorrd2),
vneSets=vneReq,
corrMagzReq=(m,N)->m == ifelse(isodd(div(N, 2)), 1, 0),
corrOccReq=(x,N)->x==div(N, 2),
)
display(vneResults)
display(resultsDict["energyPerSite"])
Expand Down
Loading

0 comments on commit 0d5656f

Please sign in to comment.