@@ -18,19 +18,19 @@ Base.length(envs::InfiniteEnvironments) = length(envs.GLs)
1818leftenv (envs:: InfiniteEnvironments , site:: Int , state) = envs. GLs[site]
1919rightenv (envs:: InfiniteEnvironments , site:: Int , state) = envs. GRs[site]
2020
21- function environments (above :: InfiniteMPS ,
21+ function environments (below :: InfiniteMPS ,
2222 operator:: Union{InfiniteMPO,InfiniteMPOHamiltonian} ,
23- below :: InfiniteMPS = above ;
23+ above :: InfiniteMPS = below ;
2424 kwargs... )
25- GLs, GRs = initialize_environments (above , operator, below )
25+ GLs, GRs = initialize_environments (below , operator, above )
2626 envs = InfiniteEnvironments (GLs, GRs)
27- return recalculate! (envs, above , operator, below ; kwargs... )
27+ return recalculate! (envs, below , operator, above ; kwargs... )
2828end
2929
30- function issamespace (envs:: InfiniteEnvironments , above :: InfiniteMPS ,
30+ function issamespace (envs:: InfiniteEnvironments , below :: InfiniteMPS ,
3131 operator:: Union{InfiniteMPO,InfiniteMPOHamiltonian} ,
32- below :: InfiniteMPS )
33- L = check_length (above , operator, below )
32+ above :: InfiniteMPS )
33+ L = check_length (below , operator, above )
3434 for i in 1 : L
3535 space (envs. GLs[i]) ==
3636 (left_virtualspace (below, i) ⊗ left_virtualspace (operator, i)' ←
@@ -42,39 +42,39 @@ function issamespace(envs::InfiniteEnvironments, above::InfiniteMPS,
4242 return true
4343end
4444
45- function recalculate! (envs:: InfiniteEnvironments , above :: InfiniteMPS ,
45+ function recalculate! (envs:: InfiniteEnvironments , below :: InfiniteMPS ,
4646 operator:: Union{InfiniteMPO,InfiniteMPOHamiltonian} ,
47- below :: InfiniteMPS = above ; kwargs... )
48- if ! issamespace (envs, above , operator, below )
47+ above :: InfiniteMPS = below ; kwargs... )
48+ if ! issamespace (envs, below , operator, above )
4949 # TODO : in-place initialization?
50- GLs, GRs = initialize_environments (above , operator, below )
50+ GLs, GRs = initialize_environments (below , operator, above )
5151 copy! (envs. GLs, GLs)
5252 copy! (envs. GRs, GRs)
5353 end
5454
55- alg = environment_alg (above , operator, below ; kwargs... )
55+ alg = environment_alg (below , operator, above ; kwargs... )
5656
5757 @sync begin
58- @spawn compute_leftenvs! (envs, above , operator, below , alg)
59- @spawn compute_rightenvs! (envs, above , operator, below , alg)
58+ @spawn compute_leftenvs! (envs, below , operator, above , alg)
59+ @spawn compute_rightenvs! (envs, below , operator, above , alg)
6060 end
61- normalize! (envs, above , operator, below )
61+ normalize! (envs, below , operator, above )
6262
6363 return envs
6464end
6565
6666# InfiniteMPO environments
6767# ------------------------
68- function initialize_environments (above :: InfiniteMPS , operator:: InfiniteMPO ,
69- below :: InfiniteMPS = above )
70- L = check_length (above , operator, below )
68+ function initialize_environments (below :: InfiniteMPS , operator:: InfiniteMPO ,
69+ above :: InfiniteMPS = below )
70+ L = check_length (below , operator, above )
7171 GLs = PeriodicVector ([randomize! (allocate_GL (below, operator, above, i)) for i in 1 : L])
7272 GRs = PeriodicVector ([randomize! (allocate_GR (below, operator, above, i)) for i in 1 : L])
7373 return GLs, GRs
7474end
7575
76- function compute_leftenvs! (envs:: InfiniteEnvironments , above :: InfiniteMPS ,
77- operator:: InfiniteMPO , below :: InfiniteMPS , alg)
76+ function compute_leftenvs! (envs:: InfiniteEnvironments , below :: InfiniteMPS ,
77+ operator:: InfiniteMPO , above :: InfiniteMPS , alg)
7878 # compute eigenvector
7979 T = TransferMatrix (above. AL, operator, below. AL)
8080 λ, envs. GLs[1 ] = fixedpoint (flip (T), envs. GLs[1 ], :LM , alg)
@@ -86,8 +86,8 @@ function compute_leftenvs!(envs::InfiniteEnvironments, above::InfiniteMPS,
8686 return λ, envs
8787end
8888
89- function compute_rightenvs! (envs:: InfiniteEnvironments , above :: InfiniteMPS ,
90- operator:: InfiniteMPO , below :: InfiniteMPS , alg)
89+ function compute_rightenvs! (envs:: InfiniteEnvironments , below :: InfiniteMPS ,
90+ operator:: InfiniteMPO , above :: InfiniteMPS , alg)
9191 # compute eigenvector
9292 T = TransferMatrix (above. AR, operator, below. AR)
9393 λ, envs. GRs[end ] = fixedpoint (T, envs. GRs[end ], :LM , alg)
@@ -99,8 +99,8 @@ function compute_rightenvs!(envs::InfiniteEnvironments, above::InfiniteMPS,
9999 return λ, envs
100100end
101101
102- function TensorKit. normalize! (envs:: InfiniteEnvironments , above :: InfiniteMPS ,
103- operator:: InfiniteMPO , below :: InfiniteMPS )
102+ function TensorKit. normalize! (envs:: InfiniteEnvironments , below :: InfiniteMPS ,
103+ operator:: InfiniteMPO , above :: InfiniteMPS )
104104 for i in 1 : length (operator)
105105 λ = dot (below. C[i], MPO_∂∂C (envs. GLs[i + 1 ], envs. GRs[i]) * above. C[i])
106106 scale! (envs. GLs[i + 1 ], inv (λ))
110110
111111# InfiniteMPOHamiltonian environments
112112# -----------------------------------
113- function initialize_environments (above :: InfiniteMPS , operator:: InfiniteMPOHamiltonian ,
114- below :: InfiniteMPS = above )
113+ function initialize_environments (below :: InfiniteMPS , operator:: InfiniteMPOHamiltonian ,
114+ above :: InfiniteMPS = below )
115115 L = check_length (above, operator, below)
116116 GLs = PeriodicVector ([allocate_GL (below, operator, above, i) for i in 1 : L])
117117 GRs = PeriodicVector ([allocate_GR (below, operator, above, i) for i in 1 : L])
@@ -139,9 +139,9 @@ function initialize_environments(above::InfiniteMPS, operator::InfiniteMPOHamilt
139139 return GLs, GRs
140140end
141141
142- function compute_leftenvs! (envs:: InfiniteEnvironments , above :: InfiniteMPS ,
143- operator:: InfiniteMPOHamiltonian , below :: InfiniteMPS , alg)
144- L = check_length (above, operator, below )
142+ function compute_leftenvs! (envs:: InfiniteEnvironments , below :: InfiniteMPS ,
143+ operator:: InfiniteMPOHamiltonian , above :: InfiniteMPS , alg)
144+ L = check_length (below, above, operator )
145145 GLs = envs. GLs
146146 vsize = length (first (GLs))
147147
@@ -156,20 +156,20 @@ function compute_leftenvs!(envs::InfiniteEnvironments, above::InfiniteMPS,
156156 # fill_data!(leftutil, one)
157157 # @plansor GL[1][1][-1 -2; -3] = ρ_left[-1; -3] * leftutil[-2]
158158
159- (L > 1 ) && left_cyclethrough! (1 , GLs, above , operator, below )
159+ (L > 1 ) && left_cyclethrough! (1 , GLs, below , operator, above )
160160
161161 for i in 2 : vsize
162162 prev = copy (GLs[1 ][i])
163163 zerovector! (GLs[1 ][i])
164- left_cyclethrough! (i, GLs, above , operator, below )
164+ left_cyclethrough! (i, GLs, below , operator, above )
165165
166166 if isidentitylevel (operator, i) # identity matrices; do the hacky renormalization
167167 T = regularize (TransferMatrix (above. AL, below. AL), ρ_left, ρ_right)
168168 GLs[1 ][i], convhist = linsolve (flip (T), GLs[1 ][i], prev, alg, 1 , - 1 )
169169 convhist. converged == 0 &&
170170 @warn " GL$i failed to converge: normres = $(convhist. normres) "
171171
172- (L > 1 ) && left_cyclethrough! (i, GLs, above , operator, below )
172+ (L > 1 ) && left_cyclethrough! (i, GLs, below , operator, above )
173173
174174 # go through the unitcell, again subtracting fixpoints
175175 for site in 1 : L
@@ -186,15 +186,15 @@ function compute_leftenvs!(envs::InfiniteEnvironments, above::InfiniteMPS,
186186 convhist. converged == 0 &&
187187 @warn " GL$i failed to converge: normres = $(convhist. normres) "
188188 end
189- (L > 1 ) && left_cyclethrough! (i, GLs, above , operator, below )
189+ (L > 1 ) && left_cyclethrough! (i, GLs, below , operator, above )
190190 end
191191 end
192192
193193 return GLs
194194end
195195
196- function left_cyclethrough! (index:: Int , GL, above :: InfiniteMPS , H:: InfiniteMPOHamiltonian ,
197- below :: InfiniteMPS = above )
196+ function left_cyclethrough! (index:: Int , GL, below :: InfiniteMPS , H:: InfiniteMPOHamiltonian ,
197+ above :: InfiniteMPS = below )
198198 # TODO : efficient transfer matrix slicing for large unitcells
199199 leftinds = 1 : index
200200 for site in eachindex (GL)
@@ -205,8 +205,8 @@ function left_cyclethrough!(index::Int, GL, above::InfiniteMPS, H::InfiniteMPOHa
205205 return GL
206206end
207207
208- function compute_rightenvs! (envs:: InfiniteEnvironments , above :: InfiniteMPS ,
209- operator:: InfiniteMPOHamiltonian , below :: InfiniteMPS , alg)
208+ function compute_rightenvs! (envs:: InfiniteEnvironments , below :: InfiniteMPS ,
209+ operator:: InfiniteMPOHamiltonian , above :: InfiniteMPS , alg)
210210 L = check_length (above, operator, below)
211211 GRs = envs. GRs
212212 vsize = length (last (GRs))
@@ -222,12 +222,12 @@ function compute_rightenvs!(envs::InfiniteEnvironments, above::InfiniteMPS,
222222 # fill_data!(rightutil, one)
223223 # @plansor GR[end][end][-1 -2; -3] = r_RR(state)[-1; -3] * rightutil[-2]
224224
225- (L > 1 ) && right_cyclethrough! (vsize, GRs, above , operator, below ) # populate other sites
225+ (L > 1 ) && right_cyclethrough! (vsize, GRs, below , operator, above ) # populate other sites
226226
227227 for i in (vsize - 1 ): - 1 : 1
228228 prev = copy (GRs[end ][i])
229229 zerovector! (GRs[end ][i])
230- right_cyclethrough! (i, GRs, above , operator, below )
230+ right_cyclethrough! (i, GRs, below , operator, above )
231231
232232 if isidentitylevel (operator, i) # identity matrices; do the hacky renormalization
233233 # subtract fixpoints
@@ -236,7 +236,7 @@ function compute_rightenvs!(envs::InfiniteEnvironments, above::InfiniteMPS,
236236 convhist. converged == 0 &&
237237 @warn " GR$i failed to converge: normres = $(convhist. normres) "
238238
239- L > 1 && right_cyclethrough! (i, GRs, above , operator, below )
239+ L > 1 && right_cyclethrough! (i, GRs, below , operator, above )
240240
241241 # go through the unitcell, again subtracting fixpoints
242242 for site in 1 : L
@@ -253,16 +253,16 @@ function compute_rightenvs!(envs::InfiniteEnvironments, above::InfiniteMPS,
253253 @warn " GR$i failed to converge: normres = $(convhist. normres) "
254254 end
255255
256- (L > 1 ) && right_cyclethrough! (i, GRs, above , operator, below )
256+ (L > 1 ) && right_cyclethrough! (i, GRs, below , operator, above )
257257 end
258258 end
259259
260260 return GRs
261261end
262262
263- function right_cyclethrough! (index:: Int , GR, above :: InfiniteMPS ,
263+ function right_cyclethrough! (index:: Int , GR, below :: InfiniteMPS ,
264264 operator:: InfiniteMPOHamiltonian ,
265- below :: InfiniteMPS )
265+ above :: InfiniteMPS = below )
266266 # TODO : efficient transfer matrix slicing for large unitcells
267267 for site in reverse (eachindex (GR))
268268 rightinds = index: length (GR[site])
@@ -274,21 +274,21 @@ function right_cyclethrough!(index::Int, GR, above::InfiniteMPS,
274274end
275275
276276# no normalization necessary -- for consistant interface
277- function TensorKit. normalize! (envs:: InfiniteEnvironments , above :: InfiniteMPS ,
278- operator:: InfiniteMPOHamiltonian , below :: InfiniteMPS )
277+ function TensorKit. normalize! (envs:: InfiniteEnvironments , below :: InfiniteMPS ,
278+ operator:: InfiniteMPOHamiltonian , above :: InfiniteMPS )
279279 return envs
280280end
281281
282282# Transfer operations
283283# -------------------
284284
285- function transfer_leftenv! (envs:: InfiniteEnvironments , above , operator, below , site:: Int )
285+ function transfer_leftenv! (envs:: InfiniteEnvironments , below , operator, above , site:: Int )
286286 T = TransferMatrix (above. AL[site - 1 ], operator[site - 1 ], below. AL[site - 1 ])
287287 envs. GLs[site] = envs. GLs[site - 1 ] * T
288288 return envs
289289end
290290
291- function transfer_rightenv! (envs:: InfiniteEnvironments , above , operator, below , site:: Int )
291+ function transfer_rightenv! (envs:: InfiniteEnvironments , below , operator, above , site:: Int )
292292 T = TransferMatrix (above. AR[site + 1 ], operator[site + 1 ], below. AR[site + 1 ])
293293 envs. GRs[site] = T * envs. GRs[site + 1 ]
294294 return envs
0 commit comments