Skip to content

Commit 79c6664

Browse files
authored
InfiniteMPO open_boundary_conditions (#251)
* Add OBC for InfiniteMPO * Bump v0.12.6
1 parent f62543a commit 79c6664

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MPSKit"
22
uuid = "bb1c41ca-d63c-52ed-829e-0820dda26502"
33
authors = "Lukas Devos, Maarten Van Damme and contributors"
4-
version = "0.12.5"
4+
version = "0.12.6"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"

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)