Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsch committed May 7, 2024
1 parent c37a748 commit 46a488f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
1 change: 0 additions & 1 deletion docs/src/hamiltonians.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ Lattices in higher dimensions are defined here for [`HubbardRealSpace`](@ref) an

```@docs
Geometry
num_dimensions
Hamiltonians.UnitVectors
Hamiltonians.Offsets
Hamiltonians.neighbor_site
Expand Down
43 changes: 23 additions & 20 deletions src/Hamiltonians/correlation_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ equivalent to stacking all components into a single Fock state.
# See also
* [`HubbardReal1D`](@ref)
* [`G2RealSpace`](@ref)
* [`G2MomCorrelator`](@ref)
* [`AbstractHamiltonian`](@ref)
* [`AllOverlaps`](@ref)
Expand Down Expand Up @@ -103,17 +104,22 @@ num_offdiagonals(::G2RealCorrelator, ::SingleComponentFockAddress) = 0
num_offdiagonals(::G2RealCorrelator, ::CompositeFS) = 0

"""
G2RealSpace(g::Geometry) <: AbstractHamiltonian{SArray}
G2RealSpace(::Geometry, σ=1, τ=1; sum_components=false) <: AbstractHamiltonian{SArray}
Two-body operator for density-density correlation for all displacements.
Two-body operator for density-density correlation for all displacements ``d`` in the
specified geometry.
```math
\\hat{G}^{(2)}(d) = \\frac{1}{M} ∑_i^M∑_v \\hat{n}_i (\\hat{n}_{i+v} - \\delta_{0d}).
\\hat{G}^{(2)}(d) = \\frac{1}{M} ∑_i^M∑_v \\hat{n}_{σ,i} (\\hat{n}_{τ,i+v} - δ_{0,v}δ_{σ,τ}).
```
For multicomponent addresses, `σ` and `τ` control the components involved. Alternatively, `sum_components` can be set to true, which treats all particles as
belonging to the same component.
# See also
* [`HubbardReal1D`](@ref)
* [`Geometry`](@ref)
* [`HubbardRealSpace`](@ref)
* [`G2MomCorrelator`](@ref)
* [`G2RealCorrelator`](@ref)
* [`AbstractHamiltonian`](@ref)
Expand All @@ -123,23 +129,19 @@ struct G2RealSpace{A,B,G<:Geometry,S} <: AbstractHamiltonian{S}
geometry::G
init::S
end
function G2RealSpace(
geometry::Geometry, source::Int=1, target::Int=source; sum_components=false
)
if source < 1 || target < 1
throw(ArgumentError("`source` and `target` must be positive integers"))
function G2RealSpace(geometry::Geometry, σ::Int=1, τ::Int=σ; sum_components=false)
if σ < 1 || τ < 1
throw(ArgumentError("`σ` and `τ` must be positive integers"))
end
if sum_components
if source 1 || target 1
throw(
ArgumentError("`source` or `target` can't be set if `sum_components=true`")
)
if σ 1 || τ 1
throw(ArgumentError("`σ` or `τ` can't be set if `sum_components=true`"))
end
source = target = 0
σ = τ = 0
end

init = zeros(SArray{Tuple{size(geometry)...}})
return G2RealSpace{source,target,typeof(geometry),typeof(init)}(geometry, init)
return G2RealSpace{σ,τ,typeof(geometry),typeof(init)}(geometry, init)
end

function Base.show(io::IO, g2::G2RealSpace{A,B}) where {A,B}
Expand All @@ -158,14 +160,14 @@ num_offdiagonals(g2::G2RealSpace, _) = 0

@inbounds for i in eachindex(result)
res_i = 0.0
δ_vec = Offsets(geo)[i]
displacement = Offsets(geo)[i]

# Case of n_i(n_i - 1) on the same component
if A == B && all(==(0), δ_vec)
onr1_offset = max.(onr1 .- 1, 0)
result = setindex(result, dot(onr2, onr1_offset), i)
if A == B && is_zero(displacement)
onr1_minus_1 = max.(onr1 .- 1, 0)
result = setindex(result, dot(onr2, onr1_minus_1), i)
else
result = setindex(result, circshift_dot(onr2, onr1, δ_vec), i)
result = setindex(result, circshift_dot(onr2, onr1, displacement), i)
end
end
return result ./ length(geo)
Expand Down Expand Up @@ -225,6 +227,7 @@ and let it be the default value.
* [`BoseHubbardMom1D2C`](@ref)
* [`BoseFS2C`](@ref)
* [`G2RealCorrelator`](@ref)
* [`G2RealSpace`](@ref)
* [`AbstractHamiltonian`](@ref)
* [`AllOverlaps`](@ref)
"""
Expand Down
6 changes: 3 additions & 3 deletions src/Hamiltonians/geometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
Geometry(dims::NTuple{D,Int}, fold::NTuple{D,Bool})
Represents a `D`-dimensional grid. Used to convert between cartesian vector indices (tuples
or `SVector`s) and linear indices (integers).
or `SVector`s) and linear indices (integers). When indexed with vectors, it folds them back
into the grid if the out-of-bounds dimension is periodic and 0 otherwise (see example
below).
* `dims` controls the size of the grid in each dimension.
* `fold` controls whether the boundaries in each dimension are periodic (or folded in the
case of momentum space).
`Base.getindex` can be used to convert between linear indices and vectors.
```julia
julia> geo = Geometry((2,3), (true,false))
Geometry{2}((2, 3), (true, false))
Expand Down

0 comments on commit 46a488f

Please sign in to comment.