Skip to content

Commit 3fe94d2

Browse files
committed
centralize regularization calls
1 parent 0f50dc5 commit 3fe94d2

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

src/algorithms/excitation/exci_transfer_system.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ function left_excitation_transfer_system(
5959
T = TransferMatrix(exci.right_gs.AR, H_partial, exci.left_gs.AL)
6060
start = scale!(last(found[1:i] * T), cis(-mom * len))
6161
if exci.trivial && isidentitylevel(H, i)
62-
@plansor start[-1 -2; -3 -4] -= start[1 4; -3 2] * r_RL(exci.right_gs)[2; 3] *
63-
τ[3 4; 5 1] * l_RL(exci.right_gs)[-1; 6] * τ[5 6; -4 -2]
62+
ρ_left = l_RL(exci.right_gs)
63+
ρ_right = r_RL(exci.right_gs)
64+
regularize!(start, ρ_right, ρ_left)
6465
end
6566

6667
found[i] = add!(start, GBL[i])
@@ -147,8 +148,9 @@ function right_excitation_transfer_system(
147148
T = TransferMatrix(exci.left_gs.AL, H_partial, exci.right_gs.AR)
148149
start = scale!(first(T * found[i:odim]), cis(mom * len))
149150
if exci.trivial && isidentitylevel(H, i)
150-
@plansor start[-1 -2; -3 -4] -= τ[6 2; 3 4] * start[3 4; -3 5] *
151-
l_LR(exci.right_gs)[5; 2] * r_LR(exci.right_gs)[-1; 1] * τ[-2 -4; 1 6]
151+
ρ_left = l_LR(exci.right_gs)
152+
ρ_right = r_LR(exci.right_gs)
153+
regularize!(start, ρ_left, ρ_right)
152154
end
153155

154156
found[i] = add!(start, GBR[i])

src/environments/qp_envs.jl

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ function environments(exci::InfiniteQP, H::InfiniteMPOHamiltonian, lenvs, renvs;
6262
lBs[pos + 1] += leftenv(lenvs, pos, exci.left_gs) *
6363
TransferMatrix(exci[pos], H[pos], AL[pos]) / cis(exci.momentum)
6464

65-
if exci.trivial # regularization of trivial excitations
65+
if exci.trivial && !isempty(ids) # regularization of trivial excitations
66+
ρ_left = l_RL(exci.left_gs, pos + 1)
67+
ρ_right = r_RL(exci.left_gs, pos)
6668
for i in ids
67-
@plansor lBs[pos + 1][i][-1 -2; -3 -4] -= lBs[pos + 1][i][1 4; -3 2] *
68-
r_RL(exci.left_gs, pos)[2; 3] * τ[3 4; 5 1] *
69-
l_RL(exci.left_gs, pos + 1)[ -1; 6 ] * τ[5 6; -4 -2]
69+
regularize!(lBs[pos + 1][i], ρ_right, ρ_left)
7070
end
7171
end
7272
end
@@ -78,12 +78,11 @@ function environments(exci::InfiniteQP, H::InfiniteMPOHamiltonian, lenvs, renvs;
7878
rBs[pos - 1] += TransferMatrix(exci[pos], H[pos], AR[pos]) *
7979
rightenv(renvs, pos, exci.right_gs) * cis(exci.momentum)
8080

81-
if exci.trivial
81+
if exci.trivial && !isempty(ids)
82+
ρ_left = l_LR(exci.left_gs, pos)
83+
ρ_right = r_LR(exci.left_gs, pos - 1)
8284
for i in ids
83-
ρ_left = l_LR(exci.left_gs, pos)
84-
ρ_right = r_LR(exci.left_gs, pos - 1)
85-
@plansor rBs[pos - 1][i][-1 -2; -3 -4] -= τ[6 4; 1 3] *
86-
rBs[pos - 1][i][1 3; -3 2] * ρ_left[2; 4] * ρ_right[-1; 5] * τ[-2 -4; 5 6]
85+
regularize!(rBs[pos - 1][i], ρ_left, ρ_right)
8786
end
8887
end
8988
end
@@ -101,12 +100,11 @@ function environments(exci::InfiniteQP, H::InfiniteMPOHamiltonian, lenvs, renvs;
101100
for i in 1:(length(exci) - 1)
102101
lB_cur = lB_cur * TransferMatrix(AR[i], H[i], AL[i]) / cis(exci.momentum)
103102

104-
if exci.trivial
103+
if exci.trivial && !isempty(ids)
104+
ρ_left = l_RL(exci.left_gs, i + 1)
105+
ρ_right = r_RL(exci.left_gs, i)
105106
for k in ids
106-
ρ_left = l_RL(exci.left_gs, i + 1)
107-
ρ_right = r_RL(exci.left_gs, i)
108-
@plansor lB_cur[k][-1 -2; -3 -4] -= lB_cur[k][1 4; -3 2] *
109-
ρ_right[2; 3] * τ[3 4; 5 1] * ρ_left[-1; 6] * τ[5 6; -4 -2]
107+
regularize!(lB_cur[k], ρ_right, ρ_left)
110108
end
111109
end
112110

@@ -117,12 +115,11 @@ function environments(exci::InfiniteQP, H::InfiniteMPOHamiltonian, lenvs, renvs;
117115
for i in length(exci):-1:2
118116
rB_cur = TransferMatrix(AL[i], H[i], AR[i]) * rB_cur * cis(exci.momentum)
119117

120-
if exci.trivial
118+
if exci.trivial && !isempty(ids)
119+
ρ_left = l_LR(exci.left_gs, i)
120+
ρ_right = r_LR(exci.left_gs, i - 1)
121121
for k in ids
122-
ρ_left = l_LR(exci.left_gs, i)
123-
ρ_right = r_LR(exci.left_gs, i - 1)
124-
@plansor rB_cur[k][-1 -2; -3 -4] -= τ[6 4; 1 3] *
125-
rB_cur[k][1 3; -3 2] * ρ_left[2; 4] * ρ_right[-1; 5] * τ[-2 -4; 5 6]
122+
regularize!(rB_cur[k], ρ_left, ρ_right)
126123
end
127124
end
128125

0 commit comments

Comments
 (0)