Hello everyone,
I’m a beginner with ITensor and I have a question about the usage of apply function in two-site operator case.
My code is following.
using ITensorMPS
using ITensors
s = siteinds("Qubit",2)
qubit_state_origin_1 = MPS(s,"0")
rho_id = outer(qubit_state_origin_1',qubit_state_origin_1) #create density matrix
rho_id[1][4] = 1 # create identity at each site
rho_id[2][4] = 1
rho_mult = apply(rho_id,rho_id; alg="zipup") #contract by apply function
rho_ele_mult = rho_id' .* rho_id #contract by boardcasting
sz_test = op("Sz",s[1])*op("Id",s[2])
state_evolution = apply(sz_test,rho_id)
First, I create a two-site MPO called rho_id with each site is 2 by 2 identity matrix. And what I want to do is applying the rho_id to another rho_id to find whether each site is still identity matrix after contraction. The result expected to be [1 0; 0 1] for each site. However, the result is
@show rho_mult[1]
rho_mult[1] = ITensor ord=3
Dim 1: (dim=2|id=766|"Qubit,Site,n=1")'
Dim 2: (dim=2|id=766|"Qubit,Site,n=1")
Dim 3: (dim=1|id=958|"Link,l=1")
NDTensors.Dense{Float64, Vector{Float64}}
2×2×1
[:, :, 1] =
-1.4142135623730947 0.0
0.0 -1.414213562373095
ITensor ord=3 (dim=2|id=766|"Qubit,Site,n=1")' (dim=2|id=766|"Qubit,Site,n=1") (dim=1|id=958|"Link,l=1")
NDTensors.Dense{Float64, Vector{Float64}}
I have no idea why there is a additional minus sign before the strange number.
And if I use boardcast “.*”, the result is reasonable with the cost of adding a dimension.
@show rho_ele_mult[2]
rho_ele_mult[2] = ITensor ord=4
Dim 1: (dim=2|id=722|"Qubit,Site,n=2")''
Dim 2: (dim=1|id=865|"Link,l=1")'
Dim 3: (dim=2|id=722|"Qubit,Site,n=2")
Dim 4: (dim=1|id=865|"Link,l=1")
NDTensors.Dense{Float64, Vector{Float64}}
2×1×2×1
[:, :, 1, 1] =
1.0
0.0
[:, :, 2, 1] =
0.0
1.0
ITensor ord=4 (dim=2|id=722|"Qubit,Site,n=2")'' (dim=1|id=865|"Link,l=1")' (dim=2|id=722|"Qubit,Site,n=2") (dim=1|id=865|"Link,l=1")
NDTensors.Dense{Float64, Vector{Float64}}
The reason I play with this kind of thing is that I’d like to create a global operator like sz_test defined in the code. And applying it to MPO state to evolute the qubit state. The result is also strange.
@show state_evolution[1]
state_evolution[1] = ITensor ord=3
Dim 1: (dim=2|id=766|"Qubit,Site,n=1")'
Dim 2: (dim=2|id=766|"Qubit,Site,n=1")
Dim 3: (dim=4|id=8|"Link,n=1")
NDTensors.Dense{Float64, Vector{Float64}}
2×2×4
[:, :, 1] =
-0.7071067811865472 0.0
0.0 0.7071067811865475
[:, :, 2] =
0.0 0.0
1.0 0.0
[:, :, 3] =
0.0 1.0
0.0 0.0
[:, :, 4] =
0.7071067811865475 0.0
0.0 0.7071067811865475
ITensor ord=3 (dim=2|id=766|"Qubit,Site,n=1")' (dim=2|id=766|"Qubit,Site,n=1") (dim=4|id=8|"Link,n=1")
NDTensors.Dense{Float64, Vector{Float64}}
I’d sincerely appreciate it if someone could help me to solve this problem or share the method of applying global operator to MPO state.