Skip to content

Add WindowMPOHamiltonian enabling propagators and dynamical DMRG on WindowMPS#417

Merged
lkdvos merged 13 commits into
mainfrom
mvd/windowham
Jul 1, 2026
Merged

Add WindowMPOHamiltonian enabling propagators and dynamical DMRG on WindowMPS#417
lkdvos merged 13 commits into
mainfrom
mvd/windowham

Conversation

@maartenvd

@maartenvd maartenvd commented Apr 21, 2026

Copy link
Copy Markdown
Collaborator

Adds a WindowMPOHamiltonian: the operator counterpart of a WindowMPS, a finite window embedded between infinite left/right "bath" Hamiltonians.
This resolves the pain points from #411, where propagator/dynamical DMRG could not run on a WindowMPS.

What was wrong

A WindowMPS has a finite window but infinite environments.
Slicing an InfiniteMPOHamiltonian into a FiniteMPOHamiltonian does not impose trivial finite boundary conditions, so environments/squaredenvs hit a SpaceMismatch.
There was also no finite energy reference for z (the true ground-state energy is extensive).

What this adds

  • WindowMPOHamiltonian(H::InfiniteMPOHamiltonian, interval) — carves a finite window out of an infinite Hamiltonian, keeping the boundary Hamiltonians and circshifting their unit cells to align with the window.
  • environments(::WindowMPS, ::WindowMPOHamiltonian) — builds finite env caches with boundaries from the infinite fixed-points; explicit leftstart/rightstart avoid the fixed-point solve for conj(H)*H.
  • propagator/squaredenvs accept a WindowMPS + WindowMPOHamiltonian directly; docstrings corrected to the 1/(z-H) convention and Jeckelmann functional (14).
  • expectation_value, dot, and linear algebra (+, -, *, scale, conj) for WindowMPOHamiltonian; WindowMPS(ψ, interval) constructor with aligned environments.
  • Window derivatives (AC_hamiltonian/AC2_hamiltonian) forward to the finite window so DMRG/TDVP/propagator use the Jordan-optimized operators.
  • Tests: dynamical DMRG on a WindowMPS (both flavours, vs analytic result), window-Hamiltonian linear algebra + circshift-offset invariance, and find_groundstate/timestep on windows.

Remaining work / limitations

  • Full AbstractMPO interface coverage (only the pieces used here are wired).
  • Only InfiniteMPOHamiltonian windows (no dense-MPO windows yet).
  • No public environment-passing overload for propagator.
  • No dedicated docs page / rendered example yet.

Closes #411

@github-actions

github-actions Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Your PR no longer requires formatting changes. Thank you for your contribution!

@codecov

codecov Bot commented Apr 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.82609% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/operators/windowhamiltonian.jl 96.77% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/MPSKit.jl 100.00% <ø> (ø)
src/algorithms/expval.jl 88.50% <100.00%> (+0.27%) ⬆️
src/algorithms/propagator/corvector.jl 95.40% <ø> (ø)
src/environments/finite_envs.jl 96.49% <100.00%> (-3.51%) ⬇️
src/operators/mpohamiltonian.jl 90.32% <100.00%> (+0.01%) ⬆️
src/states/windowmps.jl 69.04% <100.00%> (+2.79%) ⬆️
src/operators/windowhamiltonian.jl 96.77% <96.77%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@maartenvd
maartenvd marked this pull request as ready for review April 29, 2026 08:08

@lkdvos lkdvos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me! I left some minor comments but otherwise I'm happy to merge this and go from there

Comment thread src/algorithms/propagator/corvector.jl Outdated
Comment thread src/operators/windowhamiltonian.jl Outdated
Comment thread src/operators/windowhamiltonian.jl
@maartenvd

Copy link
Copy Markdown
Collaborator Author

I added a windowmps constructor that takes in a unitrange, similar to windowmpohamiltonian.

@lkdvos

lkdvos commented May 1, 2026

Copy link
Copy Markdown
Member

Looks good to me! I rebased on the latest main to hopefully resolve the errors in the tests, but if it works I'll just merge this so it is included in the next release, which I hope to get out today.

@maartenvd

Copy link
Copy Markdown
Collaborator Author

I forgot that I still want to write some docstring referencing exactly what propagator returns, I wouldn't merge just yet

@lkdvos
lkdvos force-pushed the mvd/windowham branch 2 times, most recently from 2f5c16d to 161c540 Compare July 1, 2026 14:43
maartenvd and others added 13 commits July 1, 2026 10:48
The WindowMPOHamiltonian environments method must call
initialize_environments on the finite Hamiltonian (there is no
environments(::WindowMPS, ::FiniteMPOHamiltonian, ...) method), and
expose leftstart/rightstart as keywords so squaredenvs (Jeckelmann
flavour) can pass squared boundary environments through.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Fix `+`/`-` on WindowMPOHamiltonian: the finite window carries full Jordan
  virtual spaces on its boundaries, so summands must be block-diagonalized at
  every site (including edges), like InfiniteMPOHamiltonian addition. Add a
  dedicated `_add_finite_window` helper and a `VectorInterface.scale` method so
  unary `-`, scalar `*`/`/` work through the AbstractMPO fallbacks.
- Avoid spurious non-convergent fixed-point solves in `squaredenvs`: inline the
  `leftstart`/`rightstart` defaults in the WindowMPOHamiltonian environments
  method so the infinite environment of e.g. `conj(H) * H` is only computed when
  no explicit boundaries are passed.
- Attach and clean up the WindowMPOHamiltonian docstring (was silently detached),
  document the interval constructors of WindowMPOHamiltonian and WindowMPS, and
  fix the propagator/DynamicalDMRG docstrings (return value + LaTeX).
- Add test/operators/windowhamiltonian.jl covering non-trivial intervals
  (circshift alignment via offset invariance) and the linear algebra.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add two Hamiltonians with different Jordan bond dimensions (Ising ZZ string
vs XY hopping) so the boundary/bulk virtual spaces of the summands differ and
must be block-diagonalized consistently, checking expectation-value additivity
in both orders.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lkdvos lkdvos changed the title windowhamiltonian poc Add WindowMPOHamiltonian enabling propagators and dynamical DMRG on WindowMPS Jul 1, 2026
@lkdvos
lkdvos enabled auto-merge (squash) July 1, 2026 20:10
@lkdvos
lkdvos merged commit ff0fc97 into main Jul 1, 2026
30 checks passed
@lkdvos
lkdvos deleted the mvd/windowham branch July 1, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

propagator with Jeckelmann flavour fails for WindowMPS due to SpaceMismatch in squaredenvs

2 participants