Skip to content

Commit 7585275

Browse files
committed
feat: simplify MPO project from P'HP to HP
Based on David's comments, we can use the operator diagonality to simplify P'HP = PHP = HPP = HP. This improves the constraint's contribution to the bond dimension from a quadratic to a linear factor.
1 parent 98945c5 commit 7585275

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

src/projection_mpo.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,14 @@ function project_hamiltonian(H::ITensorMPS.MPO, projections; cutoff=1e-8, kwargs
284284
target_sites = projection_target_sites(H)
285285
validate_projection_sequence(target_sites, projection_tuple)
286286

287-
H_eff = H
288-
for P in projection_tuple
289-
H_eff = ITensors.apply(ITensors.dag(P), H_eff; cutoff, kwargs...)
290-
H_eff = ITensors.apply(H_eff, P; cutoff, kwargs...)
291-
end
292-
293-
return H_eff
287+
# WARNING: The code below assumes that all MPOs are **diagonal**
288+
# and all projections are actual projections, i.e. P^2 = P.
289+
# It simplifies P'HP = PHP = HPP = HP.
290+
# We should test that this simplification actually improves the code
291+
# or if the MPO multiplication machinery already catchs it.
292+
# We keep the documentation as P'HP _on purpose_ because that is the correct semantics.
293+
op = (x, y) -> ITensors.apply(x, y; cutoff, kwargs...)
294+
return reduce(op, projection_tuple; init = H)
294295
end
295296

296297
"""

0 commit comments

Comments
 (0)