@@ -8,7 +8,7 @@ T_RR[i] * GRs[i] = λ GRs[i - 1]
88```
99where `T_LL` and `T_RR` are the (regularized) transfer matrix operators on a give site for `AL-O-AL` and `AR-O-AR` respectively.
1010"""
11- struct InfiniteEnvironments{V<: GenericMPSTensor } <: AbstractMPSEnvironments
11+ struct InfiniteEnvironments{V <: GenericMPSTensor } <: AbstractMPSEnvironments
1212 GLs:: PeriodicVector{V}
1313 GRs:: PeriodicVector{V}
1414end
@@ -18,33 +18,41 @@ 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 (below :: InfiniteMPS ,
22- operator:: Union{InfiniteMPO,InfiniteMPOHamiltonian} ,
23- above:: InfiniteMPS = below;
24- kwargs ... )
21+ function environments (
22+ below :: InfiniteMPS , operator:: Union{InfiniteMPO, InfiniteMPOHamiltonian} ,
23+ above:: InfiniteMPS = below; kwargs ...
24+ )
2525 GLs, GRs = initialize_environments (below, operator, above)
2626 envs = InfiniteEnvironments (GLs, GRs)
2727 return recalculate! (envs, below, operator, above; kwargs... )
2828end
2929
30- function issamespace (envs:: InfiniteEnvironments , below:: InfiniteMPS ,
31- operator:: Union{InfiniteMPO,InfiniteMPOHamiltonian} ,
32- above:: InfiniteMPS )
30+ function issamespace (
31+ envs:: InfiniteEnvironments , below:: InfiniteMPS ,
32+ operator:: Union{InfiniteMPO, InfiniteMPOHamiltonian} , above:: InfiniteMPS
33+ )
3334 L = check_length (below, operator, above)
3435 for i in 1 : L
3536 space (envs. GLs[i]) ==
36- (left_virtualspace (below, i) ⊗ left_virtualspace (operator, i)' ←
37- left_virtualspace (above, i)) || return false
37+ (
38+ left_virtualspace (below, i) ⊗ left_virtualspace (operator, i)' ←
39+ left_virtualspace (above, i)
40+ ) || return false
3841 space (envs. GRs[i]) ==
39- (right_virtualspace (above, i) ⊗ right_virtualspace (operator, i) ←
40- right_virtualspace (below, i)) || return false
42+ (
43+ right_virtualspace (above, i) ⊗ right_virtualspace (operator, i) ←
44+ right_virtualspace (below, i)
45+ ) || return false
4146 end
4247 return true
4348end
4449
45- function recalculate! (envs:: InfiniteEnvironments , below:: InfiniteMPS ,
46- operator:: Union{InfiniteMPO,InfiniteMPOHamiltonian} ,
47- above:: InfiniteMPS = below; kwargs... )
50+ function recalculate! (
51+ envs:: InfiniteEnvironments , below:: InfiniteMPS ,
52+ operator:: Union{InfiniteMPO, InfiniteMPOHamiltonian} ,
53+ above:: InfiniteMPS = below;
54+ kwargs...
55+ )
4856 if ! issamespace (envs, below, operator, above)
4957 # TODO : in-place initialization?
5058 GLs, GRs = initialize_environments (below, operator, above)
6573
6674# InfiniteMPO environments
6775# ------------------------
68- function initialize_environments (below:: InfiniteMPS , operator:: InfiniteMPO ,
69- above:: InfiniteMPS = below)
76+ function initialize_environments (
77+ below:: InfiniteMPS , operator:: InfiniteMPO , above:: InfiniteMPS = below
78+ )
7079 L = check_length (below, operator, above)
7180 GLs = PeriodicVector ([randomize! (allocate_GL (below, operator, above, i)) for i in 1 : L])
7281 GRs = PeriodicVector ([randomize! (allocate_GR (below, operator, above, i)) for i in 1 : L])
7382 return GLs, GRs
7483end
7584
76- function compute_leftenvs! (envs:: InfiniteEnvironments , below:: InfiniteMPS ,
77- operator:: InfiniteMPO , above:: InfiniteMPS , alg)
85+ function compute_leftenvs! (
86+ envs:: InfiniteEnvironments , below:: InfiniteMPS ,
87+ operator:: InfiniteMPO , above:: InfiniteMPS , alg
88+ )
7889 # compute eigenvector
7990 T = TransferMatrix (above. AL, operator, below. AL)
8091 λ, envs. GLs[1 ] = fixedpoint (flip (T), envs. GLs[1 ], :LM , alg)
8192 # push through unitcell
8293 for i in 2 : length (operator)
8394 envs. GLs[i] = envs. GLs[i - 1 ] *
84- TransferMatrix (above. AL[i - 1 ], operator[i - 1 ], below. AL[i - 1 ])
95+ TransferMatrix (above. AL[i - 1 ], operator[i - 1 ], below. AL[i - 1 ])
8596 end
8697 return λ, envs
8798end
8899
89- function compute_rightenvs! (envs:: InfiniteEnvironments , below:: InfiniteMPS ,
90- operator:: InfiniteMPO , above:: InfiniteMPS , alg)
100+ function compute_rightenvs! (
101+ envs:: InfiniteEnvironments , below:: InfiniteMPS , operator:: InfiniteMPO ,
102+ above:: InfiniteMPS , alg
103+ )
91104 # compute eigenvector
92105 T = TransferMatrix (above. AR, operator, below. AR)
93106 λ, envs. GRs[end ] = fixedpoint (T, envs. GRs[end ], :LM , alg)
94107 # push through unitcell
95108 for i in reverse (1 : (length (operator) - 1 ))
96- envs. GRs[i] = TransferMatrix (above. AR[i + 1 ], operator[i + 1 ],
97- below. AR[i + 1 ]) * envs. GRs[i + 1 ]
109+ envs. GRs[i] = TransferMatrix (
110+ above. AR[i + 1 ], operator[i + 1 ],
111+ below. AR[i + 1 ]
112+ ) * envs. GRs[i + 1 ]
98113 end
99114 return λ, envs
100115end
104119# - normalize the left environment to have overlap 1
105120# this avoids catastrophic blow-up of norms, while keeping the total normalized
106121# and does not lead to issues for negative overlaps and real entries.
107- function TensorKit. normalize! (envs:: InfiniteEnvironments , below:: InfiniteMPS ,
108- operator:: InfiniteMPO , above:: InfiniteMPS )
122+ function TensorKit. normalize! (
123+ envs:: InfiniteEnvironments , below:: InfiniteMPS , operator:: InfiniteMPO ,
124+ above:: InfiniteMPS
125+ )
109126 for i in 1 : length (operator)
110127 normalize! (envs. GRs[i])
111128 Hc = C_hamiltonian (i, below, operator, above, envs)
117134
118135# InfiniteMPOHamiltonian environments
119136# -----------------------------------
120- function initialize_environments (below:: InfiniteMPS , operator:: InfiniteMPOHamiltonian ,
121- above:: InfiniteMPS = below)
137+ function initialize_environments (
138+ below:: InfiniteMPS , operator:: InfiniteMPOHamiltonian ,
139+ above:: InfiniteMPS = below
140+ )
122141 L = check_length (above, operator, below)
123142 GLs = PeriodicVector ([allocate_GL (below, operator, above, i) for i in 1 : L])
124143 GRs = PeriodicVector ([allocate_GR (below, operator, above, i) for i in 1 : L])
@@ -146,8 +165,10 @@ function initialize_environments(below::InfiniteMPS, operator::InfiniteMPOHamilt
146165 return GLs, GRs
147166end
148167
149- function compute_leftenvs! (envs:: InfiniteEnvironments , below:: InfiniteMPS ,
150- operator:: InfiniteMPOHamiltonian , above:: InfiniteMPS , alg)
168+ function compute_leftenvs! (
169+ envs:: InfiniteEnvironments , below:: InfiniteMPS ,
170+ operator:: InfiniteMPOHamiltonian , above:: InfiniteMPS , alg
171+ )
151172 L = check_length (below, above, operator)
152173 GLs = envs. GLs
153174 vsize = length (first (GLs))
@@ -181,8 +202,7 @@ function compute_leftenvs!(envs::InfiniteEnvironments, below::InfiniteMPS,
181202 # go through the unitcell, again subtracting fixpoints
182203 for site in 1 : L
183204 @plansor GLs[site][i][- 1 - 2 ; - 3 ] -= GLs[site][i][1 - 2 ; 2 ] *
184- r_LL (above, site - 1 )[2 ; 1 ] *
185- l_LL (above, site)[- 1 ; - 3 ]
205+ r_LL (above, site - 1 )[2 ; 1 ] * l_LL (above, site)[- 1 ; - 3 ]
186206 end
187207
188208 else
@@ -200,20 +220,24 @@ function compute_leftenvs!(envs::InfiniteEnvironments, below::InfiniteMPS,
200220 return GLs
201221end
202222
203- function left_cyclethrough! (index:: Int , GL, below:: InfiniteMPS , H:: InfiniteMPOHamiltonian ,
204- above:: InfiniteMPS = below)
223+ function left_cyclethrough! (
224+ index:: Int , GL, below:: InfiniteMPS , H:: InfiniteMPOHamiltonian ,
225+ above:: InfiniteMPS = below
226+ )
205227 # TODO : efficient transfer matrix slicing for large unitcells
206228 leftinds = 1 : index
207229 for site in eachindex (GL)
208- GL[site + 1 ][index] = GL[site][leftinds] * TransferMatrix (above . AL[site],
209- H[site][leftinds, 1 , 1 , index],
210- below . AL[site] )
230+ GL[site + 1 ][index] = GL[site][leftinds] * TransferMatrix (
231+ above . AL[site], H[site][leftinds, 1 , 1 , index], below . AL[site]
232+ )
211233 end
212234 return GL
213235end
214236
215- function compute_rightenvs! (envs:: InfiniteEnvironments , below:: InfiniteMPS ,
216- operator:: InfiniteMPOHamiltonian , above:: InfiniteMPS , alg)
237+ function compute_rightenvs! (
238+ envs:: InfiniteEnvironments , below:: InfiniteMPS ,
239+ operator:: InfiniteMPOHamiltonian , above:: InfiniteMPS , alg
240+ )
217241 L = check_length (above, operator, below)
218242 GRs = envs. GRs
219243 vsize = length (last (GRs))
@@ -248,8 +272,7 @@ function compute_rightenvs!(envs::InfiniteEnvironments, below::InfiniteMPS,
248272 # go through the unitcell, again subtracting fixpoints
249273 for site in 1 : L
250274 @plansor GRs[site][i][- 1 - 2 ; - 3 ] -= GRs[site][i][1 - 2 ; 2 ] *
251- l_RR (above, site + 1 )[2 ; 1 ] *
252- r_RR (above, site)[- 1 ; - 3 ]
275+ l_RR (above, site + 1 )[2 ; 1 ] * r_RR (above, site)[- 1 ; - 3 ]
253276 end
254277 else
255278 if ! isemptylevel (operator, i)
@@ -267,22 +290,25 @@ function compute_rightenvs!(envs::InfiniteEnvironments, below::InfiniteMPS,
267290 return GRs
268291end
269292
270- function right_cyclethrough! (index:: Int , GR, below:: InfiniteMPS ,
271- operator:: InfiniteMPOHamiltonian ,
272- above:: InfiniteMPS = below)
293+ function right_cyclethrough! (
294+ index:: Int , GR, below:: InfiniteMPS , operator:: InfiniteMPOHamiltonian ,
295+ above:: InfiniteMPS = below
296+ )
273297 # TODO : efficient transfer matrix slicing for large unitcells
274298 for site in reverse (eachindex (GR))
275299 rightinds = index: length (GR[site])
276- GR[site - 1 ][index] = TransferMatrix (above . AR[site],
277- operator[site][index, 1 , 1 , rightinds],
278- below . AR[site] ) * GR[site][rightinds]
300+ GR[site - 1 ][index] = TransferMatrix (
301+ above . AR[site], operator[site][index, 1 , 1 , rightinds], below . AR[site]
302+ ) * GR[site][rightinds]
279303 end
280304 return GR
281305end
282306
283307# no normalization necessary -- for consistant interface
284- function TensorKit. normalize! (envs:: InfiniteEnvironments , below:: InfiniteMPS ,
285- operator:: InfiniteMPOHamiltonian , above:: InfiniteMPS )
308+ function TensorKit. normalize! (
309+ envs:: InfiniteEnvironments , below:: InfiniteMPS ,
310+ operator:: InfiniteMPOHamiltonian , above:: InfiniteMPS
311+ )
286312 return envs
287313end
288314
0 commit comments