Hi Matt,
Thanks for your reply. Indeed I tried that as also written in the ITensor tutorial. However, I get some errors which I do not understand. For convenience , let me paste down my code first and then the error
#---------------Define Basic Params------------------------#
N, Jz =8, 1.0
hstark = 1.0
beta_max = 0.2
t_max = 2.
Wz = 0.1
hz = zeros(N)
for i=1:N
hz[i] = i*hstark
end
sites = siteinds("S=1/2", N; conserve_qns=true)
#------------Initial Density Matrix---------------------------------------#
rho = MPO(sites, "Id") ./ √2 #---------Initial product state with infinite temp.--------------------#
#------time steps----------------#
τ = beta_max/200
#----------Gates for TEBD evo-----------------------------#
G = ITensor[]
for j=1:N-1
s1 = sites[j]
s2 = sites[j+1]
#print(s2)
hj = Jz* op("Sz",s1) * op("Sz",s2) + 1.0* op("Sy",s1) * op("Sy",s2)+ 1.0* op("Sx",s1) * op("Sx",s2) + hz[j] * op("Sz",s1)*op("Id", s2) + Wz*(-1)^(j)*op("Sz",s1) * op("Sz",s2)
Gj = exp(-τ*0.5*hj)
push!(G,Gj)
end
s1 = sites[N-1]
s2 = sites[N]
hL = hz[N] * op("Id",s1)*op("Sz", s2)
GL = exp(-τ*0.5* hL)
push!(G,GL)
append!(G, reverse(G))
#---------------Propagation---------------------------#
for β in 0:τ:beta_max-τ
rho = apply(G, rho; cutoff=1E-10)
rho = rho/tr(rho)
end
The error I am getting is the following : (I am just pasting it).
In `setindex!`, the element (1, 2) of ITensor:
Dim 1: (dim=2|id=382|"S=1/2,Site,n=1")' <Out>
1: QN("Sz",1) => 1
2: QN("Sz",-1) => 1
Dim 2: (dim=2|id=382|"S=1/2,Site,n=1") <In>
1: QN("Sz",1) => 1
2: QN("Sz",-1) => 1
NDTensors.BlockSparse{ComplexF64, Vector{ComplexF64}, 2}
2×2
Block(2, 1)
[2:2, 1:1]
0.0 + 0.5im
you are trying to set is in a block with flux QN("Sz",2), which is different from the flux QN("Sz",-2) of the other blocks of the ITensor. You may be trying to create an ITensor that does not have a well defined quantum number flux.
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] _setindex!!(::ITensors.HasQNs, ::NDTensors.BlockSparseTensor{ComplexF64, 2, Tuple{Index{Vector{Pair{QN, Int64}}}, Index{Vector{Pair{QN, Int64}}}}, NDTensors.BlockSparse{ComplexF64, Vector{ComplexF64}, 2}}, ::ComplexF64, ::Int64, ::Int64)
@ ITensors ~/.julia/packages/ITensors/LXBUp/src/qn/qnitensor.jl:7
[3] _setindex!!
@ ~/.julia/packages/ITensors/LXBUp/src/itensor.jl:1176 [inlined]
[4] setindex!
@ ~/.julia/packages/ITensors/LXBUp/src/itensor.jl:1218 [inlined]
[5] setindex!(T::ITensor, x::ComplexF64, I::CartesianIndex{2})
@ ITensors ~/.julia/packages/ITensors/LXBUp/src/itensor.jl:1222
[6] ITensor(::NDTensors.AllowAlias, ::Type{ComplexF64}, A::Matrix{ComplexF64}, inds::Tuple{Index{Vector{Pair{QN, Int64}}}, Index{Vector{Pair{QN, Int64}}}}; tol::Int64)
@ ITensors ~/.julia/packages/ITensors/LXBUp/src/qn/qnitensor.jl:301
[7] ITensor(::NDTensors.AllowAlias, ::Type{ComplexF64}, A::Matrix{ComplexF64}, inds::Tuple{Index{Vector{Pair{QN, Int64}}}, Index{Vector{Pair{QN, Int64}}}})
@ ITensors ~/.julia/packages/ITensors/LXBUp/src/qn/qnitensor.jl:290
[8] ITensor(::NDTensors.AllowAlias, ::Matrix{ComplexF64}, ::Index{Vector{Pair{QN, Int64}}}, ::Vararg{Index{Vector{Pair{QN, Int64}}}, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ ITensors ~/.julia/packages/ITensors/LXBUp/src/itensor.jl:402
[9] ITensor(::NDTensors.AllowAlias, ::Matrix{ComplexF64}, ::Index{Vector{Pair{QN, Int64}}}, ::Vararg{Index{Vector{Pair{QN, Int64}}}, N} where N)
@ ITensors ~/.julia/packages/ITensors/LXBUp/src/itensor.jl:402
[10] itensor(::Matrix{ComplexF64}, ::Vararg{Any, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ ITensors ~/.julia/packages/ITensors/LXBUp/src/itensor.jl:134
[11] itensor(::Matrix{ComplexF64}, ::Index{Vector{Pair{QN, Int64}}}, ::Vararg{Index{Vector{Pair{QN, Int64}}}, N} where N)
@ ITensors ~/.julia/packages/ITensors/LXBUp/src/itensor.jl:134
[12] op(name::String, s::Index{Vector{Pair{QN, Int64}}}; adjoint::Bool, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ ITensors ~/.julia/packages/ITensors/LXBUp/src/physics/sitetype.jl:324
[13] op(name::String, s::Index{Vector{Pair{QN, Int64}}})
@ ITensors ~/.julia/packages/ITensors/LXBUp/src/physics/sitetype.jl:231
[14] top-level scope
@ ./In[42]:29
[15] eval
@ ./boot.jl:360 [inlined]
[16] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1116
I am not sure what’s going wrong.
Best,
S