Draft
Conversation
Contributor
|
Your PR requires formatting changes to meet the project's style guidelines. Click here to view the suggested changes.diff --git a/src/operators/windowhamiltonian.jl b/src/operators/windowhamiltonian.jl
index 7eed2c4..d39bfc8 100644
--- a/src/operators/windowhamiltonian.jl
+++ b/src/operators/windowhamiltonian.jl
@@ -8,22 +8,22 @@ Acts simalar as just a finite hamiltonian, but we 'remember' the boundary hamilt
# 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}
+ 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])
- right_edge = (interval.stop+1)%length(ham)
- right_ham = InfiniteMPOHamiltonian([ham[i] for i in right_edge:(right_edge+length(ham)-1)])
+ left_edge = (interval.start - 1) % length(ham)
+ left_ham = InfiniteMPOHamiltonian([ham[i] for i in (left_edge - length(ham) + 1):left_edge])
+ 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])
- WindowMPOHamiltonian(left_ham, finite_ham, right_ham)
+ finite_ham = FiniteMPOHamiltonian([ham[i] for i in interval])
+ return WindowMPOHamiltonian(left_ham, finite_ham, right_ham)
end
#
Base.parent(h::WindowMPOHamiltonian) = h.finite_ham
@@ -32,5 +32,5 @@ Base.copy(h::WindowMPOHamiltonian) = WindowMPOHamiltonian(copy(h.left_ham), copy
# 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))
+ @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
diff --git a/test/states/windowmps.jl b/test/states/windowmps.jl
index 2106dab..ab37bba 100644
--- a/test/states/windowmps.jl
+++ b/test/states/windowmps.jl
@@ -63,7 +63,7 @@ using TensorKit: ℙ
e1 = expectation_value(window, (2, 3) => O)
- w_ham = WindowMPOHamiltonian(ham,1:length(window))
+ w_ham = WindowMPOHamiltonian(ham, 1:length(window))
window, envs, _ = find_groundstate(window, w_ham, DMRG(; verbosity = 0))
e2 = expectation_value(window, (2, 3) => O) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
draft pr for a windowhamiltonian type, resolving some pain points from #411
It wasn't possible in the past to correctly create a windowmps environments. The window uses a finitehamiltonian, but then the boundaries require an infinite hamiltonian. This new windowhamiltonian would keep track of the "bath" hamiltonian, and the finite hamiltonian for the window.
Misses full support for the abstractmpo interface, and I think a propagator+window test would be nice to have.