Skip to content

Commit dcc8e09

Browse files
committed
Fix issue in entanglement observer example (thanks Ryan Levy) [no ci]
1 parent 1ef8f05 commit dcc8e09

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

docs/src/examples/DMRG.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,9 @@ for it:
380380
mutable struct EntanglementObserver <: AbstractObserver
381381
end
382382

383-
function ITensors.measure!(o::EntanglementObserver; bond, psi, kwargs...)
384-
U,S,V = svd(psi[bond], uniqueinds(psi[bond],psi[bond+1]))
383+
function ITensors.measure!(o::EntanglementObserver; bond, psi, half_sweep, kwargs...)
384+
wf_center, other = half_sweep==1 ? (psi[bond+1],psi[bond]) : (psi[bond],psi[bond+1])
385+
U,S,V = svd(wf_center, uniqueinds(wf_center,other))
385386
SvN = 0.0
386387
for n=1:dim(S, 1)
387388
p = S[n,n]^2
@@ -402,8 +403,9 @@ using ITensors
402403
mutable struct EntanglementObserver <: AbstractObserver
403404
end
404405

405-
function ITensors.measure!(o::EntanglementObserver; bond, psi, kwargs...)
406-
U,S,V = svd(psi[bond], uniqueinds(psi[bond],psi[bond+1]))
406+
function ITensors.measure!(o::EntanglementObserver; bond, psi, half_sweep, kwargs...)
407+
wf_center, other = half_sweep==1 ? (psi[bond+1],psi[bond]) : (psi[bond],psi[bond+1])
408+
U,S,V = svd(wf_center, uniqueinds(wf_center,other))
407409
SvN = 0.0
408410
for n=1:dim(S, 1)
409411
p = S[n,n]^2

0 commit comments

Comments
 (0)