@@ -22,10 +22,13 @@ $(TYPEDFIELDS)
2222 " algorithm used for gauging the MPS"
2323 alg_gauge = Defaults. alg_gauge ()
2424
25+
2526 " algorithm used for the eigenvalue solvers"
2627 alg_eigsolve:: A = Defaults. alg_eigsolve ()
2728
28- expscheme:: Algorithm = NoExpand ()
29+ expscheme:: TruncationStrategy = noexpand ()
30+
31+ trscheme:: TruncationStrategy = notrunc ()
2932end
3033
3134"""
@@ -58,10 +61,10 @@ $(TYPEDFIELDS)
5861 " algorithm used for the singular value decomposition"
5962 alg_svd:: S = Defaults. alg_svd ()
6063
61- expscheme:: Algorithm = NoExpand ()
64+ expscheme:: TruncationStrategy = noexpand ()
6265
6366 " algorithm used for [truncation](@extref MatrixAlgebraKit.TruncationStrategy) of the two-site update"
64- trscheme:: TruncationStrategy
67+ trscheme:: TruncationStrategy = notrunc ()
6568end
6669
6770
@@ -79,9 +82,9 @@ function IDMRGState{T}(mps::S, operator::O, envs::E, iter::Int, ϵ::Float64, ene
7982end
8083
8184function find_groundstate! (
82- :: InfiniteChainStyle , mps, operator, alg:: alg_type ,
85+ :: InfiniteChainStyle , mps:: S , operator, alg:: alg_type ,
8386 envs = environments (mps, operator)
84- ) where {alg_type <: Union{<:IDMRG, <:IDMRG2} }
87+ ) where {alg_type <: Union{<:IDMRG, <:IDMRG2} , S }
8588 (length (mps) ≤ 1 && alg isa IDMRG2) && throw (ArgumentError (" unit cell should be >= 2" ))
8689 log = alg isa IDMRG ? IterLog (" IDMRG" ) : IterLog (" IDMRG2" )
8790 iter = 0
@@ -111,8 +114,9 @@ function find_groundstate!(
111114 @infov 3 logiter! (log, it. iter, ϵ, ΔE)
112115 end
113116
114- alg_gauge = updatetol (alg. alg_gauge, it. state. iter, it. state. ϵ)
115- ψ′ = InfiniteMPS (it. state. mps. AR; alg_gauge. tol, alg_gauge. maxiter)
117+ alg_gauge = updatetol (alg. alg_gauge, it. iter, it. ϵ)
118+ ψ′ = S. name. wrapper (it. state. mps. AR; alg_gauge. tol, alg_gauge. maxiter)
119+
116120 envs = recalculate! (it. state. envs, ψ′, it. state. operator, ψ′)
117121 return ψ′, envs, it. state. ϵ
118122 end
@@ -124,8 +128,7 @@ function Base.iterate(
124128 mps, envs, C_old, E_new = localupdate_step! (it, state)
125129
126130 # error criterion
127- C = mps. C[0 ]
128- ϵ = bond_error (C_old, C)
131+ ϵ = bond_error (C_old, mps. C[0 ])
129132
130133 # New energy
131134 ΔE = (E_new - state. energy) / 2
@@ -141,24 +144,28 @@ function localupdate_step!(
141144 it:: IterativeSolver{<:IDMRG} , state
142145 )
143146 alg_eigsolve = updatetol (it. alg_eigsolve, state. iter, state. ϵ)
144- return _localupdate_sweep_idmrg! (state. mps, state. operator, state. envs, alg_eigsolve, it. alg_expscheme)
147+ expscheme = updatetruncation (it. expscheme; iter = state. iter, current_rank = maximum (map (left_virtualspace, state. mps)))
148+ trscheme = updatetruncation (it. trscheme; iter = state. iter)
149+ return _localupdate_sweep_idmrg! (state. mps, state. operator, state. envs, alg_eigsolve, trscheme, expscheme)
145150end
146151
147152function localupdate_step! (
148153 it:: IterativeSolver{<:IDMRG2} , state
149154 )
150155 alg_eigsolve = updatetol (it. alg_eigsolve, state. iter, state. ϵ)
151- return _localupdate_sweep_idmrg2! (state. mps, state. operator, state. envs, alg_eigsolve, it. trscheme, it. alg_svd, it. expscheme)
156+ expscheme = updatetruncation (it. expscheme; iter = state. iter, current_rank = maximum (map (left_virtualspace, state. mps)))
157+ trscheme = updatetruncation (it. trscheme; iter = state. iter)
158+ return _localupdate_sweep_idmrg2! (state. mps, state. operator, state. envs, alg_eigsolve, trscheme, it. alg_svd, expscheme)
152159end
153160
154- function _localupdate_sweep_idmrg! (ψ, H, envs, alg_eigsolve, expscheme)
161+ function _localupdate_sweep_idmrg! (ψ, H, envs, alg_eigsolve, alg_trscheme, expscheme)
155162 local E
156163 C_old = ψ. C[0 ]
157164 # left to right sweep
158165 for pos in 1 : length (ψ)
159166 h = AC_hamiltonian (pos, ψ, H, ψ, envs)
160167 _, ψ. AC[pos] = fixedpoint (h, ψ. AC[pos], :SR , alg_eigsolve)
161- ψ. AL[pos], ψ. C[pos] = left_orth! (ψ. AC[pos]; positive = true )
168+ ψ. AL[pos], ψ. C[pos] = left_orth! (ψ. AC[pos]; trunc = alg_trscheme )
162169 ψ. AL[pos], ψ. C[pos], ψ. AC[pos + 1 ] = changebonds_left (ψ. AL[pos], ψ. C[pos], ψ. AC[pos + 1 ], expscheme)
163170 if pos == length (ψ) # AC needed in next sweep
164171 ψ. AC[pos] = _mul_tail (ψ. AL[pos], ψ. C[pos])
@@ -171,7 +178,7 @@ function _localupdate_sweep_idmrg!(ψ, H, envs, alg_eigsolve, expscheme)
171178 h = AC_hamiltonian (pos, ψ, H, ψ, envs)
172179 E, ψ. AC[pos] = fixedpoint (h, ψ. AC[pos], :SR , alg_eigsolve)
173180
174- C, temp = right_orth! (_transpose_tail (ψ. AC[pos]); positive = true )
181+ C, temp = right_orth! (_transpose_tail (ψ. AC[pos]); trunc = alg_trscheme )
175182 ψ. C[pos - 1 ], ψ. AC[pos - 1 ], temp = changebonds_right (C, ψ. AC[pos - 1 ], temp, expscheme)
176183 ψ. AR[pos] = _transpose_front (temp)
177184 if pos == 1 # AC needed in next sweep
@@ -207,8 +214,8 @@ function _localupdate_sweep_idmrg2!(ψ, H, envs, alg_eigsolve, alg_trscheme, alg
207214 # update the edge
208215 ψ. AL[end ] = ψ. AC[end ] / ψ. C[end ]
209216 ψ. AC[1 ] = _mul_tail (ψ. AL[1 ], ψ. C[1 ])
210- ac2 = AC2 (ψ, 0 ; kind = :ALAC )
211- h_ac2 = AC2_hamiltonian (0 , ψ, H, ψ, envs)
217+ ac2 = AC2 (ψ, length (ψ) ; kind = :ALAC )
218+ h_ac2 = AC2_hamiltonian (length (ψ) , ψ, H, ψ, envs)
212219 _, ac2′ = fixedpoint (h_ac2, ac2, :SR , alg_eigsolve)
213220
214221 al, c, ar = svd_trunc! (ac2′; trunc = alg_trscheme, alg = alg_svd)
@@ -217,11 +224,11 @@ function _localupdate_sweep_idmrg2!(ψ, H, envs, alg_eigsolve, alg_trscheme, alg
217224
218225 ψ. AL[end ] = al
219226 ψ. C[end ] = complex (c)
220- ψ. AR[1 ] = _transpose_front (ar)
227+ ψ. AR[end + 1 ] = _transpose_front (ar)
221228
222229 ψ. AC[end ] = _mul_tail (al, c)
223- ψ. AC[1 ] = _transpose_front (c * ar)
224- ψ. AL[1 ] = ψ. AC[1 ] / ψ. C[1 ]
230+ ψ. AC[end + 1 ] = _transpose_front (c * ar)
231+ ψ. AL[end + 1 ] = ψ. AC[end + 1 ] / ψ. C[end + 1 ]
225232
226233 C_old = complex (c)
227234
@@ -250,20 +257,20 @@ function _localupdate_sweep_idmrg2!(ψ, H, envs, alg_eigsolve, alg_trscheme, alg
250257 end
251258
252259 # update the edge
253- ψ. AC[end ] = _mul_front (ψ. C[end - 1 ], ψ. AR[end ])
254- ψ. AR[1 ] = _transpose_front (ψ. C[end ] \ _transpose_tail (ψ. AC[1 ]))
260+ ψ. AC[0 ] = _mul_front (ψ. C[- 1 ], ψ. AR[0 ])
261+ ψ. AR[1 ] = _transpose_front (ψ. C[0 ] \ _transpose_tail (ψ. AC[1 ]))
255262 ac2 = AC2 (ψ, 0 ; kind = :ACAR )
256263 h_ac2 = AC2_hamiltonian (0 , ψ, H, ψ, envs)
257264 E, ac2′ = fixedpoint (h_ac2, ac2, :SR , alg_eigsolve)
258265 al, c, ar = svd_trunc! (ac2′; trunc = alg_trscheme, alg = alg_svd)
259266 al, c, ar = changebonds (al, c, ar, expscheme)
260267 normalize! (c)
261268
262- ψ. AL[end ] = al
263- ψ. C[end ] = complex (c)
269+ ψ. AL[0 ] = al
270+ ψ. C[0 ] = complex (c)
264271 ψ. AR[1 ] = _transpose_front (ar)
265272
266- ψ. AR[end ] = _transpose_front (ψ. C[end - 1 ] \ _transpose_tail (al * c))
273+ ψ. AR[0 ] = _transpose_front (ψ. C[- 1 ] \ _transpose_tail (al * c))
267274 ψ. AC[1 ] = _transpose_front (c * ar)
268275
269276 transfer_leftenv! (envs, ψ, H, ψ, 1 )
0 commit comments