You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A structure that describes an excitation-number restricted (ENR) state space, where `N` is the number of sub-systems.
17
+
A structure that describes an excitationnumber restricted (ENR) state space, where `N` is the number of sub-systems.
18
18
19
19
# Fields
20
20
21
-
- `size`: Number of states in the excitation-number restricted state space
21
+
- `size`: Number of states in the excitationnumber restricted state space
22
22
- `dims`: A list of the number of states in each sub-system
23
23
- `n_excitations`: Maximum number of excitations
24
24
- `state2idx`: A dictionary for looking up a state index from a state (`SVector`)
25
25
- `idx2state`: A dictionary for looking up state (`SVector`) from a state index
26
26
27
+
# Functions
28
+
29
+
With this `EnrSpace`, one can use the following functions to construct states or operators in the excitation number restricted (ENR) space:
30
+
31
+
- [`enr_fock`](@ref)
32
+
- [`enr_thermal_dm`](@ref)
33
+
- [`enr_destroy`](@ref)
34
+
- [`enr_identity`](@ref)
35
+
27
36
# Example
28
37
29
38
To construct an `EnrSpace`, we only need to specify the `dims` and `n_excitations`, namely
@@ -36,6 +45,9 @@ julia> n_excitations = 3;
36
45
julia> EnrSpace(dims, n_excitations)
37
46
EnrSpace((2, 2, 3), 3)
38
47
```
48
+
49
+
!!! warning "Beware of type-stability!"
50
+
It is highly recommended to use `EnrSpace(dims, n_excitations)` with `dims` as `Tuple` or `SVector` from [StaticArrays.jl](https://github.com/JuliaArrays/StaticArrays.jl) to keep type stability. See [this link](https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-value-type) and the [related Section](@ref doc:Type-Stability) about type stability for more details.
39
51
"""
40
52
struct EnrSpace{N} <:AbstractSpace
41
53
size::Int
@@ -111,12 +123,19 @@ function enr_state_dictionaries(dims::Union{AbstractVector{T},NTuple{N,T}}, exci
111
123
end
112
124
end
113
125
114
-
functionenr_identity(dims::Union{AbstractVector{T},NTuple{N,T}}, excitations::Int) where {T<:Integer,N}
Generate the Fock state representation ([`Ket`](@ref)) in an excitation number restricted state space ([`EnrSpace`](@ref)).
119
131
132
+
The arguments `dims` and `excitations` are used to generate [`EnrSpace`](@ref).
133
+
134
+
The `state` argument is a list of integers that specifies the state (in the number basis representation) for which to generate the Fock state representation.
135
+
136
+
!!! warning "Beware of type-stability!"
137
+
It is highly recommended to use `enr_fock(dims, excitations, state)` with `dims` as `Tuple` or `SVector` from [StaticArrays.jl](https://github.com/JuliaArrays/StaticArrays.jl) to keep type stability. See [this link](https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-value-type) and the [related Section](@ref doc:Type-Stability) about type stability for more details.
138
+
"""
120
139
functionenr_fock(
121
140
dims::Union{AbstractVector{T},NTuple{N,T}},
122
141
excitations::Int,
@@ -137,6 +156,64 @@ function enr_fock(s_enr::EnrSpace, state::AbstractVector{T}; sparse::Union{Bool,
Generate the thermal state (density [`Operator`](@ref)) in an excitation number restricted state space ([`EnrSpace`](@ref)).
164
+
165
+
The arguments `dims` and `excitations` are used to generate [`EnrSpace`](@ref).
166
+
167
+
The argument `n` is a list that specifies the expectation values for number of particles in each sub-system. If `n` is specified as a real number, it will apply to each sub-system.
168
+
169
+
!!! warning "Beware of type-stability!"
170
+
It is highly recommended to use `enr_thermal_dm(dims, excitations, n)` with `dims` as `Tuple` or `SVector` from [StaticArrays.jl](https://github.com/JuliaArrays/StaticArrays.jl) to keep type stability. See [this link](https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-value-type) and the [related Section](@ref doc:Type-Stability) about type stability for more details.
171
+
"""
172
+
functionenr_thermal_dm(
173
+
dims::Union{AbstractVector{T1},NTuple{N,T1}},
174
+
excitations::Int,
175
+
n::Union{T2,AbstractVector{T2}};
176
+
sparse::Union{Bool,Val}=Val(false),
177
+
) where {T1<:Integer,T2<:Real,N}
178
+
s_enr =EnrSpace(dims, excitations)
179
+
returnenr_thermal_dm(s_enr, n; sparse = sparse)
180
+
end
181
+
functionenr_thermal_dm(
182
+
s_enr::EnrSpace{N},
183
+
n::Union{T,AbstractVector{T}};
184
+
sparse::Union{Bool,Val}=Val(false),
185
+
) where {N,T<:Real}
186
+
if n isa Real
187
+
nvec =fill(n, N)
188
+
else
189
+
(length(n) == N) ||throw(ArgumentError("The length of the vector `n` should be the same as `dims`."))
Generate a `Tuple` of annihilation operators for each sub-system in an excitation number restricted state space ([`EnrSpace`](@ref)). Thus, the return `Tuple` will have the same length as `dims`.
211
+
212
+
The arguments `dims` and `excitations` are used to generate [`EnrSpace`](@ref).
213
+
214
+
!!! warning "Beware of type-stability!"
215
+
It is highly recommended to use `enr_destroy(dims, excitations)` with `dims` as `Tuple` or `SVector` from [StaticArrays.jl](https://github.com/JuliaArrays/StaticArrays.jl) to keep type stability. See [this link](https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-value-type) and the [related Section](@ref doc:Type-Stability) about type stability for more details.
216
+
"""
140
217
functionenr_destroy(dims::Union{AbstractVector{T},NTuple{N,T}}, excitations::Int) where {T<:Integer,N}
141
218
s_enr =EnrSpace(dims, excitations)
142
219
returnenr_destroy(s_enr)
@@ -164,28 +241,19 @@ function enr_destroy(s_enr::EnrSpace{N}) where {N}
164
241
return a_ops
165
242
end
166
243
167
-
functionenr_thermal_dm(
168
-
dims::Union{AbstractVector{T1},NTuple{N,T1}},
169
-
excitations::Int,
170
-
n::Union{T2,AbstractVector{T2}},
171
-
) where {T1<:Integer,T2<:Real,N}
172
-
s_enr =EnrSpace(dims, excitations)
173
-
returnenr_thermal_dm(s_enr, n)
174
-
end
175
-
functionenr_thermal_dm(s_enr::EnrSpace{N}, n::Union{T,AbstractVector{T}}) where {N,T<:Real}
176
-
if n isa Real
177
-
nvec =fill(n, N)
178
-
else
179
-
(length(n) == N) ||throw(ArgumentError("The length of the vector `n` should be the same as `dims`."))
It is highly recommended to use `enr_identity(dims, excitations)` with `dims` as `Tuple` or `SVector` from [StaticArrays.jl](https://github.com/JuliaArrays/StaticArrays.jl) to keep type stability. See [this link](https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-value-type) and the [related Section](@ref doc:Type-Stability) about type stability for more details.
254
+
"""
255
+
functionenr_identity(dims::Union{AbstractVector{T},NTuple{N,T}}, excitations::Int) where {T<:Integer,N}
0 commit comments