Skip to content

Commit

Permalink
restore G2MomCorrelator for SingleComponentFockAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimbrand committed Dec 3, 2024
1 parent cd3cd91 commit 571e1dd
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/src/hamiltonians.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ AbstractHamiltonian{T} <: AbstractOperator{T} <: AbstractObservable{T}
ParticleNumberOperator
G2RealCorrelator
G2RealSpace
G2MomCorrelator
SuperfluidCorrelator
StringCorrelator
DensityMatrixDiagonal
Expand Down
77 changes: 77 additions & 0 deletions src/Hamiltonians/G2MomCorrelator.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@

import Rimu.Hamiltonians: num_offdiagonals, diagonal_element, get_offdiagonal

"""
G2MomCorrelator(d::Int) <: AbstractOperator{ComplexF64}
Two-body correlation operator representing the density-density
correlation at distance `d`. It returns a `Complex` value.
Correlation within a single component:
```math
\\hat{G}^{(2)}(d) = \\frac{1}{M}\\sum_{spqr=1}^M e^{-id(p-q)2π/M} a^†_{s} a^†_{p} a_q a_r δ_{s+p,q+r}
```
The diagonal element, where `(p-q)=0`, is
```math
\\frac{1}{M}\\sum_{k,p=1}^M a^†_{k} b^†_{p} b_p a_k .
```
# Arguments
- `d::Integer`: the distance between two particles.
# See also
* [`Rimu.G2RealCorrelator`](@ref)
* [`Rimu.G2RealSpace`](@ref)
* [`Rimu.AbstractOperator`](@ref)
* [`Rimu.AllOverlaps`](@ref)
"""
struct G2MomCorrelator{C} <: AbstractOperator{ComplexF64}
d::Int
end
# The type parameter `C` is not used here, but may be used for future extensions.
# It is kept here for consistency with `RimuLegacyHamiltonians.jl`.
function G2MomCorrelator(d::Int)
return G2MomCorrelator{3}(d)
end

function Rimu.Interfaces.allows_address_type(g2m::G2MomCorrelator, ::Type{A}) where {A}
return num_modes(A) > g2m.d && A <: SingleComponentFockAddress
end

function Base.show(io::IO, g::G2MomCorrelator{3})
# 3 is the default value for the type parameter
print(io, "G2MomCorrelator($(g.d))")
end

function num_offdiagonals(g::G2MomCorrelator, addr::SingleComponentFockAddress)
m = num_modes(addr)
singlies, doublies = num_singly_doubly_occupied_sites(addr)
return singlies * (singlies - 1) * (m - 2) + doublies * (m - 1)
end

function diagonal_element(g::G2MomCorrelator, addr::SingleComponentFockAddress)
M = num_modes(addr)
onrep = onr(addr)
gd = 0
for p in 1:M
iszero(onrep[p]) && continue
for k in 1:M
gd += onrep[k] * onrep[p] # a†_p a_p a†_k a_k
end
end
return ComplexF64(gd / M)
end

function get_offdiagonal(
g::G2MomCorrelator,
addr::A,
chosen,
)::Tuple{A,ComplexF64} where {A<:SingleComponentFockAddress}
M = num_modes(addr)
new_add, gamma, Δp = momentum_transfer_excitation(addr, chosen, OccupiedModeMap(addr))
gd = exp(-im * g.d * Δp * 2π / M) * gamma
return new_add, ComplexF64(gd / M)
end
4 changes: 3 additions & 1 deletion src/Hamiltonians/Hamiltonians.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Other
## [Observables](#Observables)
- [`ParticleNumberOperator`](@ref)
- [`G2RealCorrelator`](@ref)
- [`G2MomCorrelator`](@ref)
- [`G2RealSpace`](@ref)
- [`DensityMatrixDiagonal`](@ref)
- [`SingleParticleExcitation`](@ref)
Expand Down Expand Up @@ -83,7 +84,7 @@ export ParticleNumberOperator

export G2RealCorrelator, G2RealSpace, SuperfluidCorrelator, DensityMatrixDiagonal, Momentum
export SingleParticleExcitation, TwoParticleExcitation, ReducedDensityMatrix
export StringCorrelator
export StringCorrelator, G2MomCorrelator

export CubicGrid, PeriodicBoundaries, HardwallBoundaries, LadderBoundaries

Expand Down Expand Up @@ -124,6 +125,7 @@ include("Stoquastic.jl")

include("Transcorrelated1D.jl")
include("correlation_functions.jl")
include("G2MomCorrelator.jl")
include("DensityMatrixDiagonal.jl")
include("reduced_density_matrix.jl")
include("Momentum.jl")
Expand Down
1 change: 1 addition & 0 deletions test/Hamiltonians.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ end
(SingleParticleExcitation(2, 3), BoseFS(1, 2, 3, 4)),
(TwoParticleExcitation(3, 2, 1, 4), BoseFS(1, 2, 3, 4)),
(Momentum(1), BoseFS(1, 2, 3, 4)),
(G2MomCorrelator(3), BoseFS(1, 2, 0, 3, 0, 4, 0, 1))
]
test_operator_interface(op, addr)
# Check that the result of show can be pasted into the REPL
Expand Down

0 comments on commit 571e1dd

Please sign in to comment.