Skip to content

Commit

Permalink
added new file for defining standard Hamiltonians
Browse files Browse the repository at this point in the history
  • Loading branch information
abhirup-m committed Nov 1, 2024
1 parent 4759df8 commit 2c9f956
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/correlations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,14 @@ function SpecFunc(
freqValues::Vector{Float64},
standDev::Union{Vector{Float64}, Float64};
normalise::Bool=true,

)

println("E: ", round.(eigVals, digits=5), length(eigVals))

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

#=println("EM: ", sort(round.(eigVals, digits=5)), length(eigVals))=#
@assert issorted(freqValues)

groundState = eigVecs[sortperm(eigVals)[1]]
energyGs = round(minimum(eigVals), digits=10)
Expand All @@ -293,6 +297,7 @@ function SpecFunc(
specFunc .+= spectralWeights[index][1] * deltaFunction(freqValues .+ energyGs .- eigVals[index], standDev) # standDev ./ ((freqValues .+ energyGs .- eigVals[index]) .^ 2 .+ standDev^2)
specFunc .+= spectralWeights[index][2] * deltaFunction(freqValues .- energyGs .+ eigVals[index], standDev) # standDev ./ ((freqValues .- energyGs .+ eigVals[index]) .^ 2 .+ standDev^2)
end

if sum(specFunc .* (maximum(freqValues) - minimum(freqValues[1])) / (length(freqValues) - 1)) > 1e-10 && normalise
return specFunc ./ sum(specFunc .* (maximum(freqValues) - minimum(freqValues[1])) / (length(freqValues) - 1))
else
Expand Down Expand Up @@ -346,6 +351,7 @@ function SpecFunc(
basisStates::Vector{Dict{BitVector,Float64}},
standDev::Union{Vector{Float64}, Float64};
normalise::Bool=true,

)

eigenStates = [ExpandIntoBasis(vector, basisStates) for vector in eigVecs]
Expand Down Expand Up @@ -376,8 +382,8 @@ function SpecFunc(
standDev::Union{Vector{Float64}, Float64},
symmetries::Vector{Char};
normalise::Bool=true,
)

)
classifiedSpectrum, classifiedEnergies = ClassifyBasis(eigVecs, symmetries; energies=eigVals)
groundStateEnergy = minimum(eigVals)
groundState = eigVecs[sortperm(eigVals)[1]]
Expand Down Expand Up @@ -411,6 +417,7 @@ function SpecFunc(
symmetries::Vector{Char},
groundStateSector::Union{Tuple{Int64}, Tuple{Int64,Int64}};
normalise::Bool=true,

)

#=println("E: ", round.(eigVals, digits=5))=#
Expand Down
1 change: 1 addition & 0 deletions src/fermions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ include("reverseUnitaries.jl")
include("stateExpansion.jl")
include("iterDiag.jl")
include("thermalisation.jl")
include("modelHamiltonians.jl")

end
35 changes: 35 additions & 0 deletions src/modelHamiltonians.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
function KondoModel(
numBathSites::Int64,
hop_t::Float64,
kondoJ::Float64;
globalField::Float64=0.,
)
hamiltonian = Tuple{String, Vector{Int64}, Float64}[]

# intra-bath hopping
for site in 1:(numBathSites-1)
push!(hamiltonian, ("+-", [1 + 2 * site, 3 + 2 * site], -hop_t)) # c^†_{j,up} c_{j+1,up}
push!(hamiltonian, ("+-", [3 + 2 * site, 1 + 2 * site], -hop_t)) # c^†_{j+1,up} c_{j,up}
push!(hamiltonian, ("+-", [2 + 2 * site, 4 + 2 * site], -hop_t)) # c^†_{j,dn} c_{j+1,dn}
push!(hamiltonian, ("+-", [4 + 2 * site, 2 + 2 * site], -hop_t)) # c^†_{j+1,dn} c_{j,dn}
end

# kondo terms
push!(hamiltonian, ("nn", [1, 3], kondoJ/4)) # n_{d up, n_{0 up}
push!(hamiltonian, ("nn", [1, 4], -kondoJ/4)) # n_{d up, n_{0 down}
push!(hamiltonian, ("nn", [2, 3], -kondoJ/4)) # n_{d down, n_{0 up}
push!(hamiltonian, ("nn", [2, 4], kondoJ/4)) # n_{d down, n_{0 down}
push!(hamiltonian, ("+-+-", [1, 2, 4, 3], kondoJ/2)) # S_d^+ S_0^-
push!(hamiltonian, ("+-+-", [2, 1, 3, 4], kondoJ/2)) # S_d^- S_0^+

# global magnetic field (to lift any trivial degeneracy)
if globalField 0
for site in 0:numBathSites
push!(hamiltonian, ("n", [1 + 2 * site], field))
push!(hamiltonian, ("n", [2 + 2 * site], -field))
end
end

return hamiltonian
end
export KondoModel

0 comments on commit 2c9f956

Please sign in to comment.