@@ -126,15 +126,35 @@ function changebond!(
126126 # a sweep that already holds one should pass it: this is called once per site
127127 allocator = default_allocator (ψ, SerialScheduler ()),
128128 )
129- bond = site
129+ # two-site update from the projected effective Hamiltonian
130+ AC2 = AC2_projection (site, ψ, H, ψ, envs; alg. backend, allocator)
131+ return expand_from_projection! (site, Val (:right ), ψ, AC2, alg; normalize)
132+ end
133+ function changebond! (
134+ site:: Int , :: Val{:left} , ψ:: AbstractFiniteMPS , H, alg:: OptimalExpand , envs;
135+ normalize:: Bool = true ,
136+ # a sweep that already holds one should pass it: this is called once per site
137+ allocator = default_allocator (ψ, SerialScheduler ()),
138+ )
139+ # two-site update from the projected effective Hamiltonian
140+ AC2 = AC2_projection (site - 1 , ψ, H, ψ, envs; alg. backend, allocator)
141+ return expand_from_projection! (site, Val (:left ), ψ, AC2, alg; normalize)
142+ end
143+
144+ """
145+ expand_from_projection!(site, direction, ψ, AC2, alg::OptimalExpand; normalize = true)
146+
147+ Expand the bond of `site` in `direction` of `ψ` from `AC2`, the projected two-site update of that
148+ bond, as [`changebond!`](@ref) does after forming it.
149+ """
150+ function expand_from_projection! (
151+ site:: Int , :: Val{:right} , ψ:: AbstractFiniteMPS , AC2, alg:: OptimalExpand ; normalize:: Bool = true
152+ )
130153 left = ψ. AC[site]
131154 right = ψ. AR[site + 1 ]
132155 NL = left_null (left)
133156 NR = right_null! (_transpose_tail (right; copy = true ))
134157
135- # two-site update from the projected effective Hamiltonian
136- AC2 = AC2_projection (bond, ψ, H, ψ, envs; alg. backend, allocator)
137-
138158 # select the dominant directions in the complement of the current state
139159 g2 = adjoint (NL) * AC2 * adjoint (NR)
140160 nrm = norm (g2)
@@ -155,21 +175,14 @@ function changebond!(
155175 ψ. AC[site + 1 ] = (nc, nar)
156176 return ψ
157177end
158- function changebond! (
159- site:: Int , :: Val{:left} , ψ:: AbstractFiniteMPS , H, alg:: OptimalExpand , envs;
160- normalize:: Bool = true ,
161- # a sweep that already holds one should pass it: this is called once per site
162- allocator = default_allocator (ψ, SerialScheduler ()),
178+ function expand_from_projection! (
179+ site:: Int , :: Val{:left} , ψ:: AbstractFiniteMPS , AC2, alg:: OptimalExpand ; normalize:: Bool = true
163180 )
164- bond = site - 1
165181 left = ψ. AL[site - 1 ]
166182 right = ψ. AC[site]
167183 NL = left_null (left)
168184 NR = right_null! (_transpose_tail (right; copy = true ))
169185
170- # two-site update from the projected effective Hamiltonian
171- AC2 = AC2_projection (bond, ψ, H, ψ, envs; alg. backend, allocator)
172-
173186 # select the dominant directions in the complement of the current state
174187 g2 = adjoint (NL) * AC2 * adjoint (NR)
175188 nrm = norm (g2)
0 commit comments