Skip to content

Commit 1743240

Browse files
lkdvosclaude
andcommitted
Reuse the effective Hamiltonian for the DMRG Galerkin error
Without bond expansion the single-site update now builds AC_hamiltonian once and takes the local Galerkin error from it, instead of contracting a separate unprepared projection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 077ee8b commit 1743240

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

‎src/algorithms/groundstate/dmrg.jl‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,24 @@ function local_update!(
124124
ϵ_global, ϵ_trunc, decay_rate,
125125
iter, timeroutput, allocator
126126
)
127-
ϵ_local = calc_galerkin(site, ψ, O, ψ, envs; alg.backend, allocator)
127+
ac_old = ψ.AC[site]
128+
if isnothing(alg.alg_expand)
129+
H_effective = @timeit timeroutput "AC_hamiltonian" AC_hamiltonian(site, ψ, O, ψ, envs; alg.backend, allocator)
130+
ϵ_local = galerkin_error(H_effective * ac_old, ψ.AL[site])
131+
else
132+
ϵ_local = calc_galerkin(site, ψ, O, ψ, envs; alg.backend, allocator)
128133

129-
# 1. expand
130-
if !isnothing(alg.alg_expand)
134+
# 1. expand
131135
@timeit timeroutput "expand" changebond!(
132136
site, direction, ψ, O, alg.alg_expand, envs; allocator
133137
)
138+
ac_old = ψ.AC[site]
139+
H_effective = @timeit timeroutput "AC_hamiltonian" AC_hamiltonian(site, ψ, O, ψ, envs; alg.backend, allocator)
134140
end
135141

136142
# 2. local update
137143
alg_eigsolve = adapt_solver(alg.alg_eigsolve; decay_rate, g_local = ϵ_local, g_global = ϵ_global, eps_trunc = ϵ_trunc)
138-
ac_old = ψ.AC[site]
139-
λ, AC′, info = @timeit timeroutput "AC_eigsolve" begin
140-
H_effective = AC_hamiltonian(site, ψ, O, ψ, envs; alg.backend, allocator)
141-
fixedpoint(H_effective, ac_old, :SR, alg_eigsolve)
142-
end
144+
λ, AC′, info = @timeit timeroutput "AC_eigsolve" fixedpoint(H_effective, ac_old, :SR, alg_eigsolve)
143145

144146
alg_gauge = _update_alg_gauge(alg.alg_gauge, iter, ϵ_global)
145147

‎src/algorithms/toolbox.jl‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ function calc_galerkin(
6565
backend::AbstractBackend = DefaultBackend(), allocator = DefaultAllocator()
6666
)
6767
AC´ = AC_projection(pos, below, operator, above, envs; backend, allocator)
68-
normalize!(AC´)
69-
return norm(project_complement!(AC´, below.AL[pos]))
68+
return galerkin_error(AC´, below.AL[pos])
7069
end
70+
galerkin_error(AC´, AL) = norm(project_complement!(normalize!(AC´), AL))
7171
function calc_galerkin(pos::CartesianIndex{2}, below, operator, above, envs; kwargs...)
7272
row, col = Tuple(pos)
7373
return calc_galerkin(col, below[row + 1], operator[row], above[row], envs[row]; kwargs...)

0 commit comments

Comments
 (0)