Hello iTensor team,
First i have to thank all iTensor team for keep this incredible package alive and growing.
Secondly, I'm trying to use an external file to study a ferrimagnetic system with Spin S=2. I follow the correct structure of external file, which give the following simple code
using ITensors
function ITensors.space(::SiteType"S=2"; conserve_qns=false)
if conserve_qns
return [QN("Sz",4)=>1,QN("Sz",2)=>1,
QN("Sz",0)=>1,QN("Sz",-2)=>1,QN("Sz",-4)=>1]
end
return 5
end
function ITensors.op!(Op::ITensor, ::OpName"Sz",
::SiteType"S=2", s::Index)
Op[s'=>1,s=>1] = +2
Op[s'=>2,s=>2] = +1
Op[s'=>3,s=>3] = +0
Op[s'=>4,s=>4] = -1
Op[s'=>5,s=>5] = -2
end
function ITensors.op!(Op::ITensor, ::OpName"S+",
::SiteType"S=2", s::Index)
Op[s'=>1,s=>2] = 2
Op[s'=>2,s=>3] = sqrt(6)
Op[s'=>3,s=>4] = sqrt(6)
Op[s'=>4,s=>5] = 2
end
function ITensors.op!(Op::ITensor, ::OpName"S-",
::SiteType"S=2", s::Index)
Op[s'=>2,s=>1] = 2
Op[s'=>3,s=>2] = sqrt(6)
Op[s'=>4,s=>3] = sqrt(6)
Op[s'=>5,s=>4] = 2
end
ITensors.state(::StateName"Up+", ::SiteType"S=2") = [1.0, 0.0, 0.0, 0.0, 0.0]
ITensors.state(::StateName"Up", ::SiteType"S=2") = [0.0, 1.0, 0.0, 0.0, 0.0]
ITensors.state(::StateName"Z0", ::SiteType"S=2") = [0.0, 0.0, 1.0, 0.0, 0.0]
ITensors.state(::StateName"Dn", ::SiteType"S=2") = [0.0, 0.0, 0.0, 1.0, 0.0]
ITensors.state(::StateName"Dn-", ::SiteType"S=2") = [0.0, 0.0, 0.0, 0.0, 1.0]
The interesting part is, I'm receiving an error message "InexactError" from the line concerning the value of Sqrt(6). The funny part is when I tried using the same structure to construct the same external file for different spins (S=3/2, 5/2) everyting works fine. I'm not using the convert Julia function to convert any float number to an integer, so I don't know exactly what i had to change to make my code work.
Here follow the error message :
ERROR: LoadError: InexactError: Int64(2.449489742783178)
Stacktrace:
[1] Int64
@ ./float.jl:723 [inlined]
[2] convert
@ ./number.jl:7 [inlined]
[3] setindex!
@ ./array.jl:839 [inlined]
[4] setindex!
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/NDTensors/tensorstorage.jl:25 [inlined]
[5] setindex!
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/NDTensors/blocksparse/blocksparsetensor.jl:266 [inlined]
[6] setindex!!
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/NDTensors/tensor.jl:325 [inlined]
[7] setindex!!
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/qn/qnitensor.jl:11 [inlined]
[8] _setindex!!
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/itensor.jl:855 [inlined]
[9] _setindex!!(::ITensors.NDTensors.BlockSparseTensor{Int64, 2, Tuple{Index{Vector{Pair{QN, Int64}}}, Index{Vector{Pair{QN, Int64}}}}, ITensors.NDTensors.BlockSparse{Int64, Vector{Int64},
@ ITensors /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/itensor.jl:911
[10] setindex!
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/itensor.jl:919 [inlined]
[11] op!(Op::ITensor, #unused#::OpName{Symbol("S+")}, #unused#::SiteType{S=2}, s::Index{Vector{Pair{QN, Int64}}})
@ Main /scratch/lmverissimo/Top2/2/N=128/S=2.jl:29
[12] op(name::String, s::Index{Vector{Pair{QN, Int64}}}; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ ITensors /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/physics/sitetype.jl:256
[13] op
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/physics/sitetype.jl:221 [inlined]
[14] #op#902
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/physics/sitetype.jl:332 [inlined]
[15] op
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/physics/sitetype.jl:332 [inlined]
[16] (::ITensors.var"#calcQN#1004"{Vector{Index{Vector{Pair{QN, Int64}}}}, Dict{Pair{String, Int64}, ITensor}})(term::Vector{ITensors.SiteOp})
@ ITensors /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/physics/autompo.jl:668
[17] qnsvdMPO(ampo::OpSum, sites::Vector{Index{Vector{Pair{QN, Int64}}}}; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ ITensors /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/physics/autompo.jl:676
[18] qn_svdMPO
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/physics/autompo.jl:632 [inlined]
[19] #MPO#1007
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/physics/autompo.jl:973 [inlined]
[20] MPO(ampo::OpSum, sites::Vector{Index{Vector{Pair{QN, Int64}}}})
@ ITensors /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/physics/autompo.jl:966
Any help will be appreciated, Thank you !