Skip to content

Commit

Permalink
accounted for the case when specfunc operators are not requested
Browse files Browse the repository at this point in the history
  • Loading branch information
abhirup-m committed Nov 4, 2024
1 parent d4bd0ee commit ef01759
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/iterDiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ function IterDiag(
quantumNos = InitiateQuantumNos(currentSites, symmetries, initBasis)

corrOperatorDict = Dict{String, Union{Nothing, Matrix{Float64}}}(name => nothing for name in keys(correlationDefDict))
specFuncOperators = nothing
if !isempty(specFuncNames)
specFuncOperators = Dict{String, Vector{Matrix{Float64}}}(name => Matrix{Float64}[] for name in specFuncNames)
end
Expand All @@ -354,7 +355,7 @@ function IterDiag(
corrDefKeys = [(type, members) for (type, members, _) in correlationDef]
if isnothing(corrOperatorDict[name]) && all((keys(operators)), corrDefKeys)
corrOperatorDict[name] = sum([coupling * operators[(type, members)] for (type, members, coupling) in correlationDef])
if name in specFuncNames && isempty(specFuncOperators[name])
if !isnothing(specFuncOperators) && name in specFuncNames && isempty(specFuncOperators[name])
push!(specFuncOperators[name], corrOperatorDict[name])
end
end
Expand Down Expand Up @@ -432,8 +433,10 @@ function IterDiag(
corrOperatorDict, Tuple{String, Vector{Int64}}[],
)

for name in filter(name -> !isempty(specFuncOperators[name]), specFuncNames)
push!(specFuncOperators[name], corrOperatorDict[name])
if !isnothing(specFuncOperators)
for name in filter(name -> !isempty(specFuncOperators[name]), specFuncNames)
push!(specFuncOperators[name], corrOperatorDict[name])
end
end

# define the qbit operators for the new sites
Expand All @@ -450,7 +453,7 @@ function IterDiag(
corrDefKeys = [(type, members) for (type, members, _) in correlationDef]
if isnothing(corrOperatorDict[name]) && all((keys(operators)), corrDefKeys)
corrOperatorDict[name] = sum([coupling * operators[(type, members)] for (type, members, coupling) in correlationDef])
if name in specFuncNames && isempty(specFuncOperators[name])
if !isnothing(specFuncOperators) && name in specFuncNames && isempty(specFuncOperators[name])
push!(specFuncOperators[name], corrOperatorDict[name])
end
end
Expand All @@ -462,7 +465,12 @@ function IterDiag(
append!(currentSites, newSitesFlow[step+1])
next!(pbar; showvalues=[("Size", size(hamltMatrix))])
end
return savePaths, resultsDict, specFuncOperators

if !isnothing(specFuncOperators)
return savePaths, resultsDict, specFuncOperators
else
return savePaths, resultsDict
end
end
export IterDiag

Expand Down

0 comments on commit ef01759

Please sign in to comment.