Skip to content

Commit 96b3ff8

Browse files
committed
Add OBC for InfiniteMPO
1 parent f62543a commit 96b3ff8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/algorithms/toolbox.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,27 @@ function periodic_boundary_conditions(H::InfiniteMPOHamiltonian, L=length(H))
415415
return remove_orphans!(FiniteMPOHamiltonian(output))
416416
end
417417

418+
"""
419+
open_boundary_conditions(mpo::InfiniteMPO, L::Int) -> FiniteMPO
420+
421+
Convert an infinite MPO into a finite MPO of length `L`, by applying open boundary conditions.
422+
"""
423+
function open_boundary_conditions(mpo::InfiniteMPO{O},
424+
L=length(mpo)) where {O<:SparseBlockTensorMap}
425+
mod(L, length(mpo)) == 0 ||
426+
throw(ArgumentError("length $L is not a multiple of the infinite unitcell"))
427+
428+
# Make a FiniteMPO, filling it up with the tensors of H
429+
# Only keep top row of the first and last column of the last MPO tensor
430+
431+
# allocate output
432+
output = Vector(repeat(copy(parent(mpo)), L ÷ length(mpo)))
433+
output[1] = output[1][1, :, :, :]
434+
output[end] = output[end][:, :, :, 1]
435+
436+
return FiniteMPO(output)
437+
end
438+
418439
"""
419440
open_boundary_conditions(mpo::InfiniteMPOHamiltonian, L::Int) -> FiniteMPOHamiltonian
420441

0 commit comments

Comments
 (0)