-
Notifications
You must be signed in to change notification settings - Fork 48
windowhamiltonian poc #417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,40 @@ | ||||||||||
| """ | ||||||||||
| A WindowMPS is a finite MPS embedded between an infinite mps to the left, and an inifite mps to the right. | ||||||||||
| The associated hamiltonian has also an infinite part to the left, a finite hamiltonian in the middle, and an infinite part to the right. | ||||||||||
|
|
||||||||||
| Acts simalar as just a finite hamiltonian, but we 'remember' the boundary hamiltonians. | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| # todo - what is the required interface for abstractmpo? | ||||||||||
| # support densempo windows? | ||||||||||
| struct WindowMPOHamiltonian{O} <: AbstractMPO{O} | ||||||||||
| left_ham::InfiniteMPOHamiltonian{O} | ||||||||||
| finite_ham::FiniteMPOHamiltonian{O} | ||||||||||
| right_ham::InfiniteMPOHamiltonian{O} | ||||||||||
| end | ||||||||||
|
|
||||||||||
| #utility constructor | ||||||||||
| function WindowMPOHamiltonian(ham::InfiniteMPOHamiltonian, interval::UnitRange) | ||||||||||
|
|
||||||||||
| # to make sure the interval corresponds with finite_ham, it is important that the unitcell of the left/right hamiltonians is circshifted correctly | ||||||||||
| left_edge = (interval.start - 1) % length(ham) | ||||||||||
| left_ham = InfiniteMPOHamiltonian([ham[i] for i in (left_edge - length(ham) + 1):left_edge]) | ||||||||||
|
Comment on lines
+20
to
+21
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Should we just define |
||||||||||
| right_edge = (interval.stop + 1) % length(ham) | ||||||||||
| right_ham = InfiniteMPOHamiltonian([ham[i] for i in right_edge:(right_edge + length(ham) - 1)]) | ||||||||||
|
|
||||||||||
| finite_ham = FiniteMPOHamiltonian([ham[i] for i in interval]) | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Does this also work? |
||||||||||
| return WindowMPOHamiltonian(left_ham, finite_ham, right_ham) | ||||||||||
| end | ||||||||||
|
|
||||||||||
|
|
||||||||||
| Base.copy(h::WindowMPOHamiltonian) = WindowMPOHamiltonian(copy(h.left_ham), copy(h.finite_ham), copy(h.right_ham)) | ||||||||||
|
|
||||||||||
| # some basic linalg | ||||||||||
| for fun in (:(Base.:+), :(Base.:-), :(Base.:*)) | ||||||||||
| @eval $fun(a::WindowMPOHamiltonian, b::WindowMPOHamiltonian) = WindowMPOHamiltonian($fun(a.left_ham, b.left_ham), $fun(a.finite_ham, b.finite_ham), $fun(a.right_ham, b.right_ham)) | ||||||||||
| end | ||||||||||
|
|
||||||||||
| TensorKit.dot( | ||||||||||
| bra::WindowMPS, H::WindowMPOHamiltonian, ket::WindowMPS = bra, | ||||||||||
| envs = environments(bra, H, ket) | ||||||||||
| ) = dot(bra.window, H.finite_ham, ket.window, envs) | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesnt matter too much but then it is consistent between the two flavors