I am trying to act some state with 2-layered unitaries. For instance, consider the following code:
function ITensors.op(::OpName"evoH", ::SiteType"S=1/2", s1::Index, s2::Index)
mat = [1. 0. 0. 0.
0. 1. 0. 0.
0. 0. 0. 1.0*im
0. 0. 1.0*im 0.]
return itensor(mat, s2', s1', s2, s1)
end
function evolution_single_step(sites, psi)
N = length(psi)
os = [("evoH", 1, 2)]
for site_os=3:2:N-1
push!(os, ("evoH", site_os, site_os+1))
end
for site_es=2:2:N-1
push!(os, ("evoH", site_es, site_es+1))
end
psi = apply(ops(os, sites), psi; cutoff = 1e-15)
return psi
end
sites0 = siteinds("S=1/2", 10)
state = ["Dn" for n in 1:10]
psi_init = productMPS(ComplexF64, sites0, state)
psi_init_dp = deepcopy(psi_init)
evolution_single_step(sites0, psi_init_dp)
println(inner(psi_init_dp, psi_init_dp))
As expected the inner product is 1.
But when I try to recreate the above using the following code:
function two_qubit_gate(psi, i, j)
sind_i = siteind(psi, I)
sind_j = siteind(psi, j)
# construct the unitary
tq_gate = ITensor(sind_i', sind_i, sind_j', sind_j)
tq_gate = complex(tq_gate)
tq_gate.store.data[1] = 1.
tq_gate.store.data[4] = 1.
tq_gate.store.data[14] = 1.0*im
tq_gate.store.data[15] = 1.0*im
return tq_gate
end
function evolution_single_step(psi)
N = length(psi)
for site_os=1:2:N-1
orthogonalize!(psi, site_os)
op_psi1 = psi[site_os]*psi[site_os+1]*two_qubit_gate(psi, site_os, site_os+1)
noprime!(op_psi1)
U,S,V = svd(op_psi1, siteind(psi, site_os))
psi[site_os] = U
psi[site_os+1] = S*V
println(inner(psi, psi))
end
for site_es=2:2:N-1
orthogonalize!(psi, site_es)
op_psi2 = psi[site_es]*psi[site_es+1]*two_qubit_gate(psi, site_es, site_es+1)
noprime!(op_psi2)
U,S,V = svd(op_psi2, siteind(psi, site_es))
psi[site_es] = U
psi[site_es+1] = S*V
println(inner(psi, psi))
end
return psi
end
sites0 = siteinds("S=1/2", 10)
state = ["Dn" for n in 1:10]
psi_init = productMPS(ComplexF64, sites0, state)
evolution_single_step(psi_init)
println(inner(psi_init, psi_init))
For the first layer (for the first for
loop) the norm is conserved, it goes to 1 while for the action on the evolved state, the norm remains unconserved (grows on as an exponential, resulting in 2, 4, 8, 16). I would have assumed that the machinery of apply is prototyped as in the second function. It would be helpful to know if my comparison is right and if so why the action on the evolved state is resulting in an unconserved norm. Thanks!