Skip to content

Commit

Permalink
InfiniteMPO open_boundary_conditions (#251)
Browse files Browse the repository at this point in the history
* Add OBC for InfiniteMPO

* Bump v0.12.6
  • Loading branch information
lkdvos authored Feb 10, 2025
1 parent f62543a commit 79c6664
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
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 @@ function periodic_boundary_conditions(H::InfiniteMPOHamiltonian, L=length(H))
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},
L=length(mpo)) where {O<:SparseBlockTensorMap}
mod(L, length(mpo)) == 0 ||
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]

return FiniteMPO(output)
end

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

2 comments on commit 79c6664

@lkdvos
Copy link
Member Author

@lkdvos lkdvos commented on 79c6664 Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/124753

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.12.6 -m "<description of version>" 79c6664ed6b3afea8f87cea41301214977db540b
git push origin v0.12.6

Also, note the warning: Version 0.12.6 skips over 0.12.5
This can be safely ignored. However, if you want to fix this you can do so. Call register() again after making the fix. This will update the Pull request.

Please sign in to comment.