Skip to content

Commit

Permalink
added gaussian broadening option to spec func
Browse files Browse the repository at this point in the history
  • Loading branch information
abhirup-m committed Dec 9, 2024
1 parent f22690f commit 2b88baf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/correlations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,14 @@ function SpecFunc(
degenTol::Float64=0.,
normalise::Bool=true,
silent::Bool=false,
broadFuncType::String="lorentz",
)

@assert length(eigVals) == length(eigVecs)

@assert broadFuncType ("lorentz", "gauss")
@assert issorted(freqValues)

broadeningFunc(x, standDev) = standDev ./ (x .^ 2 .+ standDev .^ 2)
broadeningFunc(x, standDev) = ifelse(broadFuncType=="lorentz", standDev ./ (x .^ 2 .+ standDev .^ 2), exp.(-0.5 .* ((x ./ standDev).^2)) ./ (standDev .* ((2π)^0.5)))

energyGs = minimum(eigVals)
specFunc = 0 .* freqValues
Expand Down Expand Up @@ -426,6 +427,7 @@ function SpecFunc(
degenTol::Float64=0.,
normalise::Bool=true,
silent::Bool=false,
broadFuncType::String="lorentz",
)
eigenStates = Vector{Float64}[]
for vector in eigVecs
Expand All @@ -437,7 +439,7 @@ function SpecFunc(
end

return SpecFunc(eigVals, eigenStates, probeMatrices, freqValues, standDev;
normalise=normalise, degenTol=degenTol, silent=silent)
normalise=normalise, degenTol=degenTol, silent=silent, broadFuncType=broadFuncType)
end
export SpecFunc

Expand All @@ -463,6 +465,7 @@ function SpecFunc(
degenTol::Float64=0.,
normalise::Bool=true,
silent::Bool=false,
broadFuncType::String="lorentz",
)
classifiedSpectrum, classifiedEnergies = ClassifyBasis(eigVecs, symmetries; energies=eigVals)
groundStateEnergy = minimum(eigVals)
Expand All @@ -487,7 +490,7 @@ function SpecFunc(
@assert groundStateEnergy == minimum(minimalEigVals)

return SpecFunc(minimalEigVals, minimalEigVecs, probes, freqValues, basisStates, standDev;
normalise=normalise, degenTol=degenTol, silent=silent)
normalise=normalise, degenTol=degenTol, silent=silent, broadFuncType=broadFuncType)
end
export SpecFunc

Expand Down Expand Up @@ -516,6 +519,7 @@ function SpecFunc(
degenTol::Float64=0.,
normalise::Bool=true,
silent::Bool=false,
broadFuncType::String="lorentz",
)
classifiedSpectrum, classifiedEnergies = ClassifyBasis(eigVecs, symmetries; energies=eigVals)
minimalEigVecs = Dict{BitVector,Float64}[]
Expand All @@ -542,7 +546,7 @@ function SpecFunc(
@assert groundStateEnergy == minimum(minimalEigVals)

return SpecFunc(minimalEigVals, minimalEigVecs, probes, freqValues, basisStates, standDev;
normalise=normalise, degenTol=degenTol, silent=silent)
normalise=normalise, degenTol=degenTol, silent=silent, broadFuncType=broadFuncType)
end
export SpecFunc

Expand All @@ -562,10 +566,11 @@ function SpecFunc(
degenTol::Float64=0.,
normalise::Bool=true,
silent::Bool=false,
broadFuncType::String="lorentz",
)

eigVecs = [collect(vec) for vec in eachcol(eigVecMatrix)]
return SpecFunc(eigVals, eigVecs, probes, freqValues, standDev;
normalise=normalise, degenTol=degenTol, silent=silent)
normalise=normalise, degenTol=degenTol, silent=silent, broadFuncType=broadFuncType)
end
export SpecFunc
3 changes: 2 additions & 1 deletion src/iterDiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,7 @@ function IterSpecFunc(
excMagzReq::Union{Nothing,Function}=nothing,
normEveryStep::Bool=false,
silent::Bool=false,
broadFuncType::String="lorentz",
)
@assert issetequal(keys(specFuncOperators), ["create", "destroy"])
quantumNoReq = CombineRequirements(occReq, magzReq)
Expand Down Expand Up @@ -887,7 +888,7 @@ function IterSpecFunc(
specFunc = SpecFunc(minimalEigVals, minimalEigVecs,
Dict(name => specFuncOperators[name][i] for name in keys(specFuncOperators)),
freqValues, standDev; silent=silent,
normalise=normEveryStep, degenTol=degenTol)
normalise=normEveryStep, degenTol=degenTol, broadFuncType=broadFuncType)
totalSpecFunc .+= specFunc
end
return totalSpecFunc
Expand Down

0 comments on commit 2b88baf

Please sign in to comment.