Hello! I’ve been trying to make use of the entropy_von_neumann function provided in the MPS and MPO examples. However, I encountered an error when calculating the von Neumann entropy across a cut which separates the first site from the others; all other cuts seem to work fine.
The state I am interested is a state of 2 (or more) qudits. The code (added below) gives an error. I suppose it is because the tensor entering the svd function does not have a linkind to its left, but I’m not sure how to fix this.
function entropy_von_neumann(psi, b)
s = siteinds(psi)
orthogonalize!(psi, b)
_,S = svd(psi[b], (linkind(psi, b-1), s[b]))
SvN = 0.0
for n in 1:dim(S, 1)
p = S[n,n]^2
SvN -= p * log2(p)
end
return SvN
end
sites = siteinds("Qudit", 2; dim = 3, conserve_number=true)
state = ["1","1"]
psi0 = MPS(sites, state)
S_vN0 = entropy_von_neumann(psi0, 1)
The error is
ERROR: MethodError: no method matching _indices(::Tuple{}, ::Nothing)
Do you have any idea how to modify the code to solve this error?
By the way, in the entropy_von_neumann function from the above link there is
SvN -= p * log(p)
that should be modified to
SvN -= p * log2(p)
because we need the logarithm base 2. (Perhaps you have done this in another way when implementing it, but at least for my setup this seems be the easiest way to find the correct vN entropy.)