Skip to content

Commit 4c7a19e

Browse files
Yet Another TensorKitTensors Convention Change (#16)
The new conventions are - `b` for bosons - `f` for spinless fermions - `e` for spinfull fermions (from 'electron') - `h` for holes (absence of electron) - `S` for spin operators Additionally, the hopping operator [flavor]_hopping is added. --------- Co-authored-by: Lukas Devos <[email protected]>
1 parent 15cc214 commit 4c7a19e

File tree

10 files changed

+738
-575
lines changed

10 files changed

+738
-575
lines changed

src/bosonoperators.jl

Lines changed: 100 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ using TensorKit
44
using LinearAlgebra: diagind
55

66
export boson_space
7-
export a_plus, a_min, number
8-
export a_plusplus, a_plusmin, a_minplus, a_minmin
9-
export a, a⁺, n
10-
export a⁺a⁺, aa⁺, a⁺a, aa
7+
export b_plus, b_min, b_num
8+
export b_plus_b_plus, b_plus_b_min, b_min_b_plus, b_min_b_min
9+
export b_hopping
10+
export b⁻, b⁺, n
11+
export b⁺b⁺, b⁻b⁺, b⁺b⁻, b⁻b⁻
12+
export b_hop
1113

1214
"""
1315
boson_space([symmetry::Type{<:Sector}]; cutoff::Integer)
@@ -21,63 +23,63 @@ boson_space(::Type{U1Irrep}; cutoff::Integer) = U1Space(n => 1 for n in 0:cutoff
2123
# Single-site operators
2224
# ---------------------
2325
@doc """
24-
a_min([eltype::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
25-
a([eltype::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
26+
b_min([elt::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
27+
b⁻([elt::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
2628
2729
The truncated bosonic annihilation operator, with a maximum of `cutoff` bosons per site.
28-
""" a_min
29-
a_min(; kwargs...) = a_min(ComplexF64, Trivial; kwargs...)
30-
a_min(elt::Type{<:Number}; kwargs...) = a_min(elt, Trivial; kwargs...)
31-
a_min(symm::Type{<:Sector}; kwargs...) = a_min(ComplexF64, symm; kwargs...)
32-
function a_min(elt::Type{<:Number}, symmetry::Type{<:Sector}; cutoff::Integer)
30+
""" b_min
31+
b_min(; kwargs...) = b_min(ComplexF64, Trivial; kwargs...)
32+
b_min(elt::Type{<:Number}; kwargs...) = b_min(elt, Trivial; kwargs...)
33+
b_min(symm::Type{<:Sector}; kwargs...) = b_min(ComplexF64, symm; kwargs...)
34+
function b_min(elt::Type{<:Number}, symmetry::Type{<:Sector}; cutoff::Integer)
3335
if symmetry === Trivial
3436
pspace = boson_space(Trivial; cutoff)
35-
a = zeros(elt, pspace pspace)
37+
b⁻ = zeros(elt, pspace pspace)
3638
for i in 1:cutoff
37-
a[i, i + 1] = sqrt(i)
39+
b⁻[i, i + 1] = sqrt(i)
3840
end
39-
return a
41+
return b⁻
4042
else
4143
throw(ArgumentError("invalid symmetry `$symmetry`"))
4244
end
4345
end
4446

45-
const a = a_min
47+
const b⁻ = b_min
4648

4749
@doc """
48-
a_plus([eltype::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
49-
a⁺([eltype::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
50+
b_plus([elt::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
51+
b⁺([elt::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
5052
5153
The truncated bosonic creation operator, with a maximum of `cutoff` bosons per site.
52-
""" a_plus
53-
a_plus(; kwargs...) = a_plus(ComplexF64, Trivial; kwargs...)
54-
a_plus(elt::Type{<:Number}; kwargs...) = a_plus(elt, Trivial; kwargs...)
55-
a_plus(symm::Type{<:Sector}; kwargs...) = a_plus(ComplexF64, symm; kwargs...)
56-
function a_plus(elt::Type{<:Number}, symmetry::Type{<:Sector}; cutoff::Integer)
54+
""" b_plus
55+
b_plus(; kwargs...) = b_plus(ComplexF64, Trivial; kwargs...)
56+
b_plus(elt::Type{<:Number}; kwargs...) = b_plus(elt, Trivial; kwargs...)
57+
b_plus(symm::Type{<:Sector}; kwargs...) = b_plus(ComplexF64, symm; kwargs...)
58+
function b_plus(elt::Type{<:Number}, symmetry::Type{<:Sector}; cutoff::Integer)
5759
if symmetry === Trivial
5860
pspace = boson_space(Trivial; cutoff)
59-
a= zeros(elt, pspace pspace)
61+
b= zeros(elt, pspace pspace)
6062
for i in 1:cutoff
61-
a⁺[i + 1, i] = sqrt(i)
63+
b⁺[i + 1, i] = sqrt(i)
6264
end
63-
return a
65+
return b
6466
else
6567
throw(ArgumentError("invalid symmetry `$symmetry`"))
6668
end
6769
end
6870

69-
const a= a_plus
71+
const b= b_plus
7072

7173
@doc """
72-
number([eltype::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
73-
n([eltype::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
74+
b_num([elt::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
75+
n([elt::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
7476
7577
The truncated bosonic number operator, with a maximum of `cutoff` bosons per site.
76-
""" number
77-
number(; kwargs...) = number(ComplexF64, Trivial; kwargs...)
78-
number(elt::Type{<:Number}; kwargs...) = number(elt, Trivial; kwargs...)
79-
number(symm::Type{<:Sector}; kwargs...) = number(ComplexF64, symm; kwargs...)
80-
function number(elt::Type{<:Number}, symmetry::Type{<:Sector}; cutoff::Integer)
78+
""" b_num
79+
b_num(; kwargs...) = b_num(ComplexF64, Trivial; kwargs...)
80+
b_num(elt::Type{<:Number}; kwargs...) = b_num(elt, Trivial; kwargs...)
81+
b_num(symm::Type{<:Sector}; kwargs...) = b_num(ComplexF64, symm; kwargs...)
82+
function b_num(elt::Type{<:Number}, symmetry::Type{<:Sector}; cutoff::Integer)
8183
pspace = boson_space(symmetry; cutoff)
8284
n = zeros(elt, pspace pspace)
8385
if symmetry === Trivial
@@ -94,106 +96,118 @@ function number(elt::Type{<:Number}, symmetry::Type{<:Sector}; cutoff::Integer)
9496
return n
9597
end
9698

97-
const n = number
99+
const n = b_num
98100

99101
# Two site operators
100102
# ------------------
101103
@doc """
102-
a_plusplus([eltype::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
103-
a⁺a⁺([eltype::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
104+
b_plus_b_plus([elt::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
105+
b⁺b⁺([elt::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
104106
105107
The truncated bosonic pair-creation operator, with a maximum of `cutoff` bosons per site.
106-
""" a_plusplus
107-
a_plusplus(; kwargs...) = a_plusplus(ComplexF64, Trivial; kwargs...)
108-
a_plusplus(elt::Type{<:Number}; kwargs...) = a_plusplus(elt, Trivial; kwargs...)
109-
a_plusplus(symm::Type{<:Sector}; kwargs...) = a_plusplus(ComplexF64, symm; kwargs...)
110-
function a_plusplus(elt::Type{<:Number}, symmetry::Type{<:Sector}; cutoff::Integer)
108+
""" b_plus_b_plus
109+
b_plus_b_plus(; kwargs...) = b_plus_b_plus(ComplexF64, Trivial; kwargs...)
110+
b_plus_b_plus(elt::Type{<:Number}; kwargs...) = b_plus_b_plus(elt, Trivial; kwargs...)
111+
b_plus_b_plus(symm::Type{<:Sector}; kwargs...) = b_plus_b_plus(ComplexF64, symm; kwargs...)
112+
function b_plus_b_plus(elt::Type{<:Number}, symmetry::Type{<:Sector}; cutoff::Integer)
111113
if symmetry === Trivial
112-
a= a_plus(elt, Trivial; cutoff)
113-
return a a
114+
b= b_plus(elt, Trivial; cutoff)
115+
return b b
114116
else
115117
throw(ArgumentError("invalid symmetry `$symmetry`"))
116118
end
117119
end
118120

119-
const a⁺a= a_plusplus
121+
const b⁺b= b_plus_b_plus
120122

121123
@doc """
122-
a_plusmin([eltype::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
123-
a⁺a([eltype::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
124+
b_plus_b_min([elt::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
125+
b⁺b⁻([elt::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
124126
125127
The truncated bosonic left-hopping operator, with a maximum of `cutoff` bosons per site.
126-
""" a_plusmin
127-
a_plusmin(; kwargs...) = a_plusmin(ComplexF64, Trivial; kwargs...)
128-
a_plusmin(elt::Type{<:Number}; kwargs...) = a_plusmin(elt, Trivial; kwargs...)
129-
a_plusmin(symm::Type{<:Sector}; kwargs...) = a_plusmin(ComplexF64, symm; kwargs...)
130-
function a_plusmin(elt::Type{<:Number}, ::Type{Trivial}; cutoff::Integer)
131-
a= a_plus(elt, Trivial; cutoff)
132-
a = a_min(elt, Trivial; cutoff)
133-
return a a
128+
""" b_plus_b_min
129+
b_plus_b_min(; kwargs...) = b_plus_b_min(ComplexF64, Trivial; kwargs...)
130+
b_plus_b_min(elt::Type{<:Number}; kwargs...) = b_plus_b_min(elt, Trivial; kwargs...)
131+
b_plus_b_min(symm::Type{<:Sector}; kwargs...) = b_plus_b_min(ComplexF64, symm; kwargs...)
132+
function b_plus_b_min(elt::Type{<:Number}, ::Type{Trivial}; cutoff::Integer)
133+
b= b_plus(elt, Trivial; cutoff)
134+
b⁻ = b_min(elt, Trivial; cutoff)
135+
return b b⁻
134136
end
135-
function a_plusmin(elt::Type{<:Number}, ::Type{U1Irrep}; cutoff::Integer)
137+
function b_plus_b_min(elt::Type{<:Number}, ::Type{U1Irrep}; cutoff::Integer)
136138
pspace = boson_space(U1Irrep; cutoff)
137-
a⁺a = zeros(elt, pspace pspace pspace pspace)
138-
for (f1, f2) in fusiontrees(a⁺a)
139+
b⁺b⁻ = zeros(elt, pspace pspace pspace pspace)
140+
for (f1, f2) in fusiontrees(b⁺b⁻)
139141
c_out, c_in = f1.uncoupled, f2.uncoupled
140142
if c_in[1].charge + 1 == c_out[1].charge &&
141143
c_in[2].charge - 1 == c_out[2].charge
142-
a⁺a[f1, f2] .= sqrt(c_out[1].charge) * sqrt(c_in[2].charge)
144+
b⁺b⁻[f1, f2] .= sqrt(c_out[1].charge) * sqrt(c_in[2].charge)
143145
end
144146
end
145-
return a⁺a
147+
return b⁺b⁻
146148
end
147149

148-
const a⁺a = a_plusmin
150+
const b⁺b⁻ = b_plus_b_min
149151

150152
@doc """
151-
a_minplus([eltype::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
152-
aa⁺([eltype::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
153+
b_min_b_plus([elt::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
154+
b⁻b⁺([elt::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
153155
154156
The truncated bosonic right-hopping operator, with a maximum of `cutoff` bosons per site.
155-
""" a_minplus
156-
a_minplus(; kwargs...) = a_minplus(ComplexF64, Trivial; kwargs...)
157-
a_minplus(elt::Type{<:Number}; kwargs...) = a_minplus(elt, Trivial; kwargs...)
158-
a_minplus(symm::Type{<:Sector}; kwargs...) = a_minplus(ComplexF64, symm; kwargs...)
159-
function a_minplus(elt::Type{<:Number}, ::Type{Trivial}; cutoff::Integer)
160-
a= a_plus(elt, Trivial; cutoff)
161-
a = a_min(elt, Trivial; cutoff)
162-
return a a
157+
""" b_min_b_plus
158+
b_min_b_plus(; kwargs...) = b_min_b_plus(ComplexF64, Trivial; kwargs...)
159+
b_min_b_plus(elt::Type{<:Number}; kwargs...) = b_min_b_plus(elt, Trivial; kwargs...)
160+
b_min_b_plus(symm::Type{<:Sector}; kwargs...) = b_min_b_plus(ComplexF64, symm; kwargs...)
161+
function b_min_b_plus(elt::Type{<:Number}, ::Type{Trivial}; cutoff::Integer)
162+
b= b_plus(elt, Trivial; cutoff)
163+
b⁻ = b_min(elt, Trivial; cutoff)
164+
return b⁻ b
163165
end
164-
function a_minplus(elt::Type{<:Number}, ::Type{U1Irrep}; cutoff::Integer)
166+
function b_min_b_plus(elt::Type{<:Number}, ::Type{U1Irrep}; cutoff::Integer)
165167
pspace = boson_space(U1Irrep; cutoff)
166-
aa= zeros(elt, pspace pspace pspace pspace)
167-
for (f1, f2) in fusiontrees(aa⁺)
168+
b⁻b= zeros(elt, pspace pspace pspace pspace)
169+
for (f1, f2) in fusiontrees(b⁻b⁺)
168170
c_out, c_in = f1.uncoupled, f2.uncoupled
169171
if c_in[1].charge - 1 == c_out[1].charge &&
170172
c_in[2].charge + 1 == c_out[2].charge
171-
aa⁺[f1, f2] .= sqrt(c_in[1].charge) * sqrt(c_out[2].charge)
173+
b⁻b⁺[f1, f2] .= sqrt(c_in[1].charge) * sqrt(c_out[2].charge)
172174
end
173175
end
174-
return aa
176+
return b⁻b
175177
end
176178

177-
const aa= a_minplus
179+
const b⁻b= b_min_b_plus
178180

179181
@doc """
180-
a_minmin([eltype::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
181-
aa([eltype::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
182+
b_min_b_min([elt::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
183+
b⁻b⁻([elt::Type{<:Number}], [symmetry::Type{<:Sector}]; cutoff::Integer)
182184
183185
The truncated bosonic pair-annihilation operator, with a maximum of `cutoff` bosons per site.
184-
""" a_minmin
185-
a_minmin(; kwargs...) = a_minmin(ComplexF64, Trivial; kwargs...)
186-
a_minmin(elt::Type{<:Number}; kwargs...) = a_minmin(elt, Trivial; kwargs...)
187-
a_minmin(symm::Type{<:Sector}; kwargs...) = a_minmin(ComplexF64, symm; kwargs...)
188-
function a_minmin(elt::Type{<:Number}, symmetry::Type{<:Sector}; cutoff::Integer)
186+
""" b_min_b_min
187+
b_min_b_min(; kwargs...) = b_min_b_min(ComplexF64, Trivial; kwargs...)
188+
b_min_b_min(elt::Type{<:Number}; kwargs...) = b_min_b_min(elt, Trivial; kwargs...)
189+
b_min_b_min(symm::Type{<:Sector}; kwargs...) = b_min_b_min(ComplexF64, symm; kwargs...)
190+
function b_min_b_min(elt::Type{<:Number}, symmetry::Type{<:Sector}; cutoff::Integer)
189191
if symmetry === Trivial
190-
a = a_min(elt, Trivial; cutoff)
191-
return a a
192+
b⁻ = b_min(elt, Trivial; cutoff)
193+
return b⁻ b⁻
192194
else
193195
throw(ArgumentError("invalid symmetry `$symmetry`"))
194196
end
195197
end
196198

197-
const aa = a_minmin
199+
const b⁻b⁻ = b_min_b_min
200+
201+
@doc """
202+
b_hopping([elt::Type{<:Number}])
203+
b_hop([elt::Type{<:Number}])
204+
205+
Return the two-body operator that describes a particle that hops between the first and the second site.
206+
""" b_hopping
207+
b_hopping(; kwargs...) = b_hopping(ComplexF64, Trivial; kwargs...)
208+
function b_hopping(elt::Type{<:Number}, symmetry::Type{<:Sector}; cutoff::Integer)
209+
return b_plus_b_min(elt, symmetry; cutoff) + b_min_b_plus(elt, symmetry; cutoff)
210+
end
211+
const b_hop = b_hopping
198212

199213
end

0 commit comments

Comments
 (0)