1+ function MPSKit. _localupdate_sweep_idmrg! (ψ:: AbstractMPS , H:: MPIOperator , envs, alg_eigsolve, :: IDMRG )
2+ C_old = ψ. C[0 ]
3+ # left to right sweep
4+ for pos in 1 : length (ψ)
5+ h = AC_hamiltonian (pos, ψ, H, ψ, envs)
6+ _, ψ. AC[pos] = fixedpoint (h, ψ. AC[pos], :SR , alg_eigsolve)
7+ if pos == length (ψ)
8+ # AC needed in next sweep
9+ ψ. AL[pos], ψ. C[pos] = mpi_left_orth (ψ. AC[pos])
10+ else
11+ ψ. AL[pos], ψ. C[pos] = mpi_left_orth! (ψ. AC[pos])
12+ end
13+ transfer_leftenv! (envs, ψ, H, ψ, pos + 1 )
14+ end
15+
16+ # right to left sweep
17+ for pos in length (ψ): - 1 : 1
18+ h = AC_hamiltonian (pos, ψ, H, ψ, envs)
19+ _, ψ. AC[pos] = fixedpoint (h, ψ. AC[pos], :SR , alg_eigsolve)
20+
21+ ψ. C[pos - 1 ], temp = mpi_right_orth! (_transpose_tail (ψ. AC[pos]; copy = (pos == 1 )))
22+ ψ. AR[pos] = _transpose_front (temp)
23+
24+ transfer_rightenv! (envs, ψ, H, ψ, pos - 1 )
25+ end
26+ return ψ, envs, C_old
27+ end
28+
29+ function MPSKit. _localupdate_sweep_idmrg! (ψ:: AbstractMPS , H:: MPIOperator , envs, alg_eigsolve, alg:: IDMRG2 )
30+ # sweep from left to right
31+ for pos in 1 : (length (ψ) - 1 )
32+ ac2 = AC2 (ψ, pos; kind = :ACAR )
33+ h_ac2 = AC2_hamiltonian (pos, ψ, H, ψ, envs)
34+ _, ac2′ = fixedpoint (h_ac2, ac2, :SR , alg_eigsolve)
35+
36+ al, c, ar = mpi_svd_trunc! (ac2′; trunc = alg. trscheme, alg = alg. alg_svd)
37+ normalize! (c)
38+
39+ ψ. AL[pos] = al
40+ ψ. C[pos] = complex (c)
41+ ψ. AR[pos + 1 ] = _transpose_front (ar)
42+ ψ. AC[pos + 1 ] = _transpose_front (c * ar)
43+
44+ transfer_leftenv! (envs, ψ, H, ψ, pos + 1 )
45+ transfer_rightenv! (envs, ψ, H, ψ, pos)
46+ end
47+
48+ # update the edge
49+ ψ. AL[end ] = ψ. AC[end ] / ψ. C[end ]
50+ ψ. AC[1 ] = _mul_tail (ψ. AL[1 ], ψ. C[1 ])
51+ ac2 = AC2 (ψ, 0 ; kind = :ALAC )
52+ h_ac2 = AC2_hamiltonian (0 , ψ, H, ψ, envs)
53+ _, ac2′ = fixedpoint (h_ac2, ac2, :SR , alg_eigsolve)
54+
55+ al, c, ar = mpi_svd_trunc! (ac2′; trunc = alg. trscheme, alg = alg. alg_svd)
56+ normalize! (c)
57+
58+ ψ. AL[end ] = al
59+ ψ. C[end ] = complex (c)
60+ ψ. AR[1 ] = _transpose_front (ar)
61+
62+ ψ. AC[end ] = _mul_tail (al, c)
63+ ψ. AC[1 ] = _transpose_front (c * ar)
64+ ψ. AL[1 ] = ψ. AC[1 ] / ψ. C[1 ]
65+
66+ C_old = complex (c)
67+
68+ # update environments
69+ transfer_leftenv! (envs, ψ, H, ψ, 1 )
70+ transfer_rightenv! (envs, ψ, H, ψ, 0 )
71+
72+ # sweep from right to left
73+ for pos in (length (ψ) - 1 ): - 1 : 1
74+ ac2 = AC2 (ψ, pos; kind = :ALAC )
75+ h_ac2 = AC2_hamiltonian (pos, ψ, H, ψ, envs)
76+ _, ac2′ = fixedpoint (h_ac2, ac2, :SR , alg_eigsolve)
77+
78+ al, c, ar = mpi_svd_trunc! (ac2′; trunc = alg. trscheme, alg = alg. alg_svd)
79+ normalize! (c)
80+
81+ ψ. AL[pos] = al
82+ ψ. AC[pos] = _mul_tail (al, c)
83+ ψ. C[pos] = complex (c)
84+ ψ. AR[pos + 1 ] = _transpose_front (ar)
85+ ψ. AC[pos + 1 ] = _transpose_front (c * ar)
86+
87+ transfer_leftenv! (envs, ψ, H, ψ, pos + 1 )
88+ transfer_rightenv! (envs, ψ, H, ψ, pos)
89+ end
90+
91+ # update the edge
92+ ψ. AC[end ] = _mul_front (ψ. C[end - 1 ], ψ. AR[end ])
93+ ψ. AR[1 ] = _transpose_front (ψ. C[end ] \ _transpose_tail (ψ. AC[1 ]))
94+ ac2 = AC2 (ψ, 0 ; kind = :ACAR )
95+ h_ac2 = AC2_hamiltonian (0 , ψ, H, ψ, envs)
96+ _, ac2′ = fixedpoint (h_ac2, ac2, :SR , alg_eigsolve)
97+ al, c, ar = mpi_svd_trunc! (ac2′; trunc = alg. trscheme, alg = alg. alg_svd)
98+ normalize! (c)
99+
100+ ψ. AL[end ] = al
101+ ψ. C[end ] = complex (c)
102+ ψ. AR[1 ] = _transpose_front (ar)
103+
104+ ψ. AR[end ] = _transpose_front (ψ. C[end - 1 ] \ _transpose_tail (al * c))
105+ ψ. AC[1 ] = _transpose_front (c * ar)
106+
107+ transfer_leftenv! (envs, ψ, H, ψ, 1 )
108+ transfer_rightenv! (envs, ψ, H, ψ, 0 )
109+
110+ return ψ, envs, C_old
111+ end
0 commit comments