Skip to content

Commit 2a64ea3

Browse files
authored
Fix Hubbard operators (#33)
* Refactor and correct hubbard operators * changes to default values * hubbard tests * Remove obsolete Hubbard tests * Remove unused exports * Formatter
1 parent 49f174a commit 2a64ea3

File tree

7 files changed

+459
-179
lines changed

7 files changed

+459
-179
lines changed

src/MPSKitModels.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export c_plus, c_min, c_plusplus, c_minmin, c_plusmin, c_minplus, c_number
3434
export c⁺, c⁻, c⁺⁺, c⁻⁻, c⁺⁻, c⁻⁺
3535
export e_plus, e_min, e_plusplus, e_minmin, e_plusmin, e_minplus
3636
export e_number, e_number_up, e_number_down, e_number_updown
37-
export e⁺, e⁻, e⁺⁺, e⁻⁻, e⁺⁻, e⁻⁺
37+
export e⁺⁺, e⁻⁻, e⁺⁻, e⁻⁺
3838

3939
export transverse_field_ising
4040
export kitaev_model
@@ -63,6 +63,8 @@ include("operators/mpoham.jl")
6363

6464
include("operators/spinoperators.jl")
6565
include("operators/fermionoperators.jl")
66+
include("operators/hubbardoperators.jl")
67+
using .HubbardOperators
6668
include("operators/bosonoperators.jl")
6769

6870
include("models/hamiltonians.jl")

src/operators/fermionoperators.jl

Lines changed: 0 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -66,166 +66,3 @@ function c_number(elt::Type{<:Number}=ComplexF64)
6666
blocks(n)[fℤ₂(1)] .= one(elt)
6767
return n
6868
end
69-
70-
#===========================================================================================
71-
spin 1/2 fermions
72-
===========================================================================================#
73-
74-
"""
75-
e_plus([elt::Type{<:Number}=ComplexF64], particle_symmetry, spin_symmetry; side=:L)
76-
e⁺([elt::Type{<:Number}=ComplexF64], particle_symmetry, spin_symmetry; side=:L)
77-
78-
The creation operator for electron-like fermions.
79-
"""
80-
function e_plus end
81-
function e_plus(particle_symmetry::Type{<:Sector}, spin_symmetry::Type{<:Sector}; kwargs...)
82-
return e_plus(ComplexF64, particle_symmetry, spin_symmetry; kwargs...)
83-
end
84-
function e_plus(elt::Type{<:Number}=ComplexF64,
85-
::Type{Trivial}=Trivial,
86-
::Type{Trivial}=Trivial;
87-
side=:L)
88-
pspace = Vect[fℤ₂](0 => 2, 1 => 2)
89-
vspace = Vect[fℤ₂](1 => 2)
90-
if side == :L
91-
e⁺ = TensorMap(zeros, elt, pspace pspace vspace)
92-
blocks(e⁺)[fℤ₂(0)][2, 2:3] .= [one(elt), -one(elt)]
93-
blocks(e⁺)[fℤ₂(1)][:, 1:2] .= [one(elt) zero(elt); zero(elt) one(elt)]
94-
elseif side == :R
95-
E = e_plus(elt, Trivial, Trivial; side=:L)
96-
F = isomorphism(storagetype(E), vspace, flip(vspace))
97-
@planar e⁺[-1 -2; -3] := E[-2; 1 2] * τ[1 2; 3 -3] * F[3; -1]
98-
else
99-
throw(ArgumentError("invalid side `:$side`, expected `:L` or `:R`"))
100-
end
101-
return e⁺
102-
end
103-
function e_plus(elt::Type{<:Number}, ::Type{U1Irrep}, ::Type{SU2Irrep}; side=:L)
104-
pspace = Vect[fℤ₂ U1Irrep SU2Irrep]((0, 0, 0) => 1, (1, 1, 1 // 2) => 1,
105-
(0, 2, 0) => 1)
106-
vspace = Vect[fℤ₂ U1Irrep SU2Irrep]((1, 1, 1 // 2) => 1)
107-
if side == :L
108-
e⁺ = TensorMap(zeros, elt, pspace pspace vspace)
109-
blocks(e⁺)[fℤ₂(0) U1Irrep(2) SU2Irrep(0)] .= sqrt(2)
110-
blocks(e⁺)[fℤ₂(1) U1Irrep(1) SU2Irrep(1 // 2)] .= 1
111-
elseif side == :R
112-
E = e_plus(elt, U1Irrep, SU2Irrep; side=:L)
113-
F = isomorphism(storagetype(E), vspace, flip(vspace))
114-
@planar e⁺[-1 -2; -3] := E[-2; 1 2] * τ[1 2; 3 -3] * F[3; -1]
115-
end
116-
return e⁺
117-
end
118-
const e⁺ = e_plus
119-
120-
"""
121-
e_min([elt::Type{<:Number}=ComplexF64], particle_symmetry::Type{<:Sector}, spin_symmetry::Type{<:Sector}; side=:L)
122-
e⁻([elt::Type{<:Number}=ComplexF64], particle_symmetry::Type{<:Sector}, spin_symmetry::Type{<:Sector}; side=:L)
123-
124-
The annihilation operator for electron-like fermions.
125-
"""
126-
function e_min end
127-
function e_min(particle_symmetry::Type{<:Sector}, spin_symmetry::Type{<:Sector}; kwargs...)
128-
return e_min(ComplexF64, particle_symmetry, spin_symmetry; kwargs...)
129-
end
130-
function e_min(elt::Type{<:Number}=ComplexF64,
131-
particle_symmetry::Type{<:Sector}=Trivial,
132-
spin_symmetry::Type{<:Sector}=Trivial;
133-
side=:L)
134-
if side === :L
135-
E = e_plus(elt, particle_symmetry, spin_symmetry; side=:L)'
136-
F = isomorphism(storagetype(E), flip(space(E, 2)), space(E, 2))
137-
@planar e⁻[-1; -2 -3] := E[-1 1; -2] * F[-3; 1]
138-
elseif side === :R
139-
e⁻ = permute(e_plus(elt, particle_symmetry, spin_symmetry; side=:L)',
140-
((2, 1), (3,)))
141-
else
142-
throw(ArgumentError("invalid side `:$side`, expected `:L` or `:R`"))
143-
end
144-
return e⁻
145-
end
146-
const e⁻ = e_min
147-
148-
function e_plusmin(elt::Type{<:Number}=ComplexF64,
149-
particle_symmetry::Type{<:Sector}=Trivial,
150-
spin_symmetry::Type{<:Sector}=Trivial)
151-
return contract_twosite(e⁺(elt, particle_symmetry, spin_symmetry; side=:L),
152-
e⁻(elt, particle_symmetry, spin_symmetry; side=:R))
153-
end
154-
function e_plusmin(particle_symmetry::Type{<:Sector}, spin_symmetry::Type{<:Sector})
155-
return e_plusmin(ComplexF64, particle_symmetry, spin_symmetry)
156-
end
157-
const e⁺e⁻ = e_plusmin
158-
159-
function e_minplus(elt::Type{<:Number}=ComplexF64,
160-
particle_symmetry::Type{<:Sector}=Trivial,
161-
spin_symmetry::Type{<:Sector}=Trivial)
162-
return contract_twosite(e⁻(elt, particle_symmetry, spin_symmetry; side=:L),
163-
e⁺(elt, particle_symmetry, spin_symmetry; side=:R))
164-
end
165-
function e_minplus(particle_symmetry::Type{<:Sector}, spin_symmetry::Type{<:Sector})
166-
return e_minplus(ComplexF64, particle_symmetry, spin_symmetry)
167-
end
168-
const e⁻e⁺ = e_minplus
169-
170-
"""
171-
e_number([elt::Type{<:Number}=ComplexF64], particle_symmetry=fℤ₂, spin_symmetry=ℤ₁)
172-
173-
The number operator for electron-like fermions.
174-
"""
175-
function e_number end
176-
function e_number(particle_symmetry::Type{<:Sector}, spin_symmetry::Type{<:Sector})
177-
return e_number(ComplexF64, particle_symmetry, spin_symmetry)
178-
end
179-
function e_number(elt::Type{<:Number}=ComplexF64, ::Type{Trivial}=Trivial,
180-
::Type{Trivial}=Trivial)
181-
pspace = Vect[fℤ₂](0 => 2, 1 => 2)
182-
n = TensorMap(zeros, elt, pspace pspace)
183-
blocks(n)[fℤ₂(1)][1, 1] = 1
184-
blocks(n)[fℤ₂(1)][2, 2] = 1
185-
blocks(n)[fℤ₂(0)][2, 2] = 2
186-
return n
187-
end
188-
function e_number(elt::Type{<:Number}, ::Type{U1Irrep}, ::Type{SU2Irrep})
189-
pspace = Vect[fℤ₂ U1Irrep SU2Irrep]((0, 0, 0) => 1, (1, 1, 1 // 2) => 1,
190-
(0, 2, 0) => 1)
191-
n = TensorMap(zeros, elt, pspace pspace)
192-
for (c, b) in blocks(n)
193-
b .= c.sectors[2].charge
194-
end
195-
return n
196-
end
197-
198-
function e_number_up(elt::Type{<:Number}=ComplexF64, ::Type{Trivial}=Trivial,
199-
::Type{Trivial}=Trivial)
200-
pspace = Vect[fℤ₂](0 => 2, 1 => 2)
201-
n = TensorMap(zeros, elt, pspace pspace)
202-
blocks(n)[fℤ₂(1)][1, 1] = 1
203-
blocks(n)[fℤ₂(0)][2, 2] = 1
204-
return n
205-
end
206-
207-
function e_number_down(elt::Type{<:Number}=ComplexF64, ::Type{Trivial}=Trivial,
208-
::Type{Trivial}=Trivial)
209-
pspace = Vect[fℤ₂](0 => 2, 1 => 2)
210-
n = TensorMap(zeros, elt, pspace pspace)
211-
blocks(n)[fℤ₂(1)][2, 2] = 1
212-
blocks(n)[fℤ₂(0)][2, 2] = 1
213-
return n
214-
end
215-
216-
function e_number_updown(elt::Type{<:Number}=ComplexF64, ::Type{Trivial}=Trivial,
217-
::Type{Trivial}=Trivial)
218-
pspace = Vect[fℤ₂](0 => 2, 1 => 2)
219-
n = TensorMap(zeros, elt, pspace pspace)
220-
blocks(n)[fℤ₂(0)][2, 2] = 1
221-
return n
222-
end
223-
function e_number_updown(elt::Type{<:Number}, ::Type{U1Irrep}, ::Type{SU2Irrep})
224-
pspace = Vect[fℤ₂ U1Irrep SU2Irrep]((0, 0, 0) => 1, (1, 1, 1 // 2) => 1,
225-
(0, 2, 0) => 1)
226-
n = TensorMap(zeros, elt, pspace pspace)
227-
blocks(n)[fℤ₂(0) U1Irrep(2) SU2Irrep(0)] .= 1
228-
return n
229-
end
230-
231-
const nꜛnꜜ = e_number_updown

0 commit comments

Comments
 (0)