Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ITensors] [BUG] exp(A::ITensor) not working with auto_fermion #1188

Open
JoeyT1994 opened this issue Sep 6, 2023 · 0 comments
Open

[ITensors] [BUG] exp(A::ITensor) not working with auto_fermion #1188

JoeyT1994 opened this issue Sep 6, 2023 · 0 comments
Labels
bug Something isn't working ITensors Issues or pull requests related to the `ITensors` package.

Comments

@JoeyT1994
Copy link
Contributor

When you enable auto_fermion, i.e. ITensors.enable_auto_fermion() then exp(A::ITensor) doesn't return the correct result.

Here is a minimal working example just building the identity matrix with exp (but the incorrect result propagates to exponentiating more complicated ITensors) and comparing to the correct result.

Minimal runnable code

using ITensors

ITensors.enable_auto_fermion()

n = 4
s = siteinds("Fermion", n; conserve_qns=true)

id_tensor = op("I", s[2])*op("I", s[3])
@show id_tensor


id_tensor_from_exp = exp(0.0 * id_tensor)
@show permute(id_tensor_from_exp, inds(id_tensor))

@show id_tensor == id_tensor_from_exp

Both of these methods should return the same, identity matrix but the one returned from exp is not (which you can check by applying it to a wavefunction) and has signs which are wrong.

Output of minimal runnable code

id_tensor = ITensor ord=4
Dim 1: (dim=2|id=147|"Fermion,Site,n=2")' <Out>
 1: QN("Nf",0,-1) => 1
 2: QN("Nf",1,-1) => 1
Dim 2: (dim=2|id=147|"Fermion,Site,n=2") <In>
 1: QN("Nf",0,-1) => 1
 2: QN("Nf",1,-1) => 1
Dim 3: (dim=2|id=164|"Fermion,Site,n=3")' <Out>
 1: QN("Nf",0,-1) => 1
 2: QN("Nf",1,-1) => 1
Dim 4: (dim=2|id=164|"Fermion,Site,n=3") <In>
 1: QN("Nf",0,-1) => 1
 2: QN("Nf",1,-1) => 1
NDTensors.BlockSparse{Float64, Vector{Float64}, 4}
 2×2×2×2
Block(1, 1, 1, 1)
 [1:1, 1:1, 1:1, 1:1]
[:, :, 1, 1] =
 1.0

Block(1, 1, 2, 2)
 [1:1, 1:1, 2:2, 2:2]
[:, :, 1, 1] =
 1.0

Block(2, 2, 1, 1)
 [2:2, 2:2, 1:1, 1:1]
[:, :, 1, 1] =
 1.0

Block(2, 2, 2, 2)
 [2:2, 2:2, 2:2, 2:2]
[:, :, 1, 1] =
 1.0
permute(id_tensor_from_exp, inds(id_tensor)) = ITensor ord=4
Dim 1: (dim=2|id=147|"Fermion,Site,n=2")' <Out>
 1: QN("Nf",0,-1) => 1
 2: QN("Nf",1,-1) => 1
Dim 2: (dim=2|id=147|"Fermion,Site,n=2") <In>
 1: QN("Nf",0,-1) => 1
 2: QN("Nf",1,-1) => 1
Dim 3: (dim=2|id=164|"Fermion,Site,n=3")' <Out>
 1: QN("Nf",0,-1) => 1
 2: QN("Nf",1,-1) => 1
Dim 4: (dim=2|id=164|"Fermion,Site,n=3") <In>
 1: QN("Nf",0,-1) => 1
 2: QN("Nf",1,-1) => 1
NDTensors.BlockSparse{Float64, Vector{Float64}, 4}
 2×2×2×2
Block(1, 1, 1, 1)
 [1:1, 1:1, 1:1, 1:1]
[:, :, 1, 1] =
 1.0

Block(2, 2, 1, 1)
 [2:2, 2:2, 1:1, 1:1]
[:, :, 1, 1] =
 -1.0

Block(1, 2, 2, 1)
 [1:1, 2:2, 2:2, 1:1]
[:, :, 1, 1] =
 0.0

Block(2, 1, 1, 2)
 [2:2, 1:1, 1:1, 2:2]
[:, :, 1, 1] =
 -0.0

Block(1, 1, 2, 2)
 [1:1, 1:1, 2:2, 2:2]
[:, :, 1, 1] =
 -1.0

Block(2, 2, 2, 2)
 [2:2, 2:2, 2:2, 2:2]
[:, :, 1, 1] =
 -1.0
id_tensor == id_tensor_from_exp = false

@JoeyT1994 JoeyT1994 added bug Something isn't working ITensors Issues or pull requests related to the `ITensors` package. labels Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ITensors Issues or pull requests related to the `ITensors` package.
Projects
None yet
Development

No branches or pull requests

1 participant