diff --git a/src/iterDiag.jl b/src/iterDiag.jl index cdd53c4..fc8a7f6 100644 --- a/src/iterDiag.jl +++ b/src/iterDiag.jl @@ -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 @@ -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 @@ -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 @@ -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 @@ -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