-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix fermionic creation and annihilation operators (c+, c, n) #7
- Loading branch information
Showing
4 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
function cc(elt::Type{<:Number}=ComplexF64) | ||
pspace = Vect[FermionParity](0=>1, 1=>1) | ||
cc = TensorMap(zeros, elt, pspace^2 ← pspace^2) | ||
blocks(cc)[fℤ₂(0)][1, 2] = -one(elt) | ||
return cc | ||
end | ||
|
||
function ccdag(elt::Type{<:Number}=ComplexF64) | ||
pspace = Vect[FermionParity](0 => 1, 1 => 1) | ||
ccdag = TensorMap(zeros, elt, pspace^2 ← pspace^2) | ||
blocks(ccdag)[fℤ₂(1)][2, 1] = -one(elt) | ||
return ccdag | ||
end | ||
|
||
function cdagc(elt::Type{<:Number}=ComplexF64) | ||
pspace = Vect[FermionParity](0 => 1, 1 => 1) | ||
cdagc = TensorMap(zeros, elt, pspace^2 ← pspace^2) | ||
blocks(cdagc)[fℤ₂(1)][1, 2] = one(elt) | ||
return cdagc | ||
end | ||
|
||
function cdagcdag(elt::Type{<:Number}=ComplexF64) | ||
pspace = Vect[FermionParity](0 => 1, 1 => 1) | ||
cdagcdag = TensorMap(zeros, elt, pspace^2 ← pspace^2) | ||
blocks(cdagcdag)[fℤ₂(0)][2, 1] = one(elt) | ||
return cdagcdag | ||
end | ||
|
||
function number(elt::Type{<:Number}=ComplexF64) | ||
pspace = Vect[FermionParity](0 => 1, 1 => 1) | ||
n = TensorMap(zeros, elt, pspace, pspace) | ||
blocks(n)[fℤ₂(1)] .= one(elt) | ||
return n | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using MPSKitModels | ||
using TensorKit | ||
using TensorOperations | ||
using Test | ||
using LinearAlgebra: tr | ||
|
||
# anticommutation relations | ||
# {cᵢ†, cⱼ†} = 0 = {cᵢ, cⱼ} | ||
|
||
@test cc() ≈ -permute(cc(), (2, 1), (4, 3)) | ||
@test cdagcdag() ≈ -permute(cdagcdag(), (2, 1), (4, 3)) | ||
@test ccdag() ≈ -permute(cdagc(), (2, 1), (4, 3)) | ||
|
||
@tensor begin | ||
term1[a; b] := ccdag()[a, i; i, b] | ||
term2[a; b] := cdagc()[a, i; i, b] | ||
end | ||
|
||
@test term1 + term2 ≈ id(domain(term)) | ||
|
||
@test term2 ≈ number() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters