Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MPSKit"
uuid = "bb1c41ca-d63c-52ed-829e-0820dda26502"
authors = "Lukas Devos, Maarten Van Damme and contributors"
version = "0.12.5"
version = "0.12.6"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand Down
21 changes: 21 additions & 0 deletions src/algorithms/toolbox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,27 @@
return remove_orphans!(FiniteMPOHamiltonian(output))
end

"""
open_boundary_conditions(mpo::InfiniteMPO, L::Int) -> FiniteMPO

Convert an infinite MPO into a finite MPO of length `L`, by applying open boundary conditions.
"""
function open_boundary_conditions(mpo::InfiniteMPO{O},

Check warning on line 423 in src/algorithms/toolbox.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/toolbox.jl#L423

Added line #L423 was not covered by tests
L=length(mpo)) where {O<:SparseBlockTensorMap}
mod(L, length(mpo)) == 0 ||

Check warning on line 425 in src/algorithms/toolbox.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/toolbox.jl#L425

Added line #L425 was not covered by tests
throw(ArgumentError("length $L is not a multiple of the infinite unitcell"))

# Make a FiniteMPO, filling it up with the tensors of H
# Only keep top row of the first and last column of the last MPO tensor

# allocate output
output = Vector(repeat(copy(parent(mpo)), L ÷ length(mpo)))
output[1] = output[1][1, :, :, :]
output[end] = output[end][:, :, :, 1]

Check warning on line 434 in src/algorithms/toolbox.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/toolbox.jl#L432-L434

Added lines #L432 - L434 were not covered by tests

return FiniteMPO(output)

Check warning on line 436 in src/algorithms/toolbox.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/toolbox.jl#L436

Added line #L436 was not covered by tests
end

"""
open_boundary_conditions(mpo::InfiniteMPOHamiltonian, L::Int) -> FiniteMPOHamiltonian

Expand Down