Skip to content

Commit 43b85d1

Browse files
committed
Add istrivial and istopological
1 parent f99504a commit 43b85d1

File tree

4 files changed

+43
-30
lines changed

4 files changed

+43
-30
lines changed

src/algorithms/excitation/exci_transfer_system.jl

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ function left_excitation_transfer_system(
66
found = zerovector(GBL)
77
odim = length(GBL)
88

9+
if istrivial(exci)
10+
ρ_left = l_RL(exci.right_gs)
11+
ρ_right = r_RL(exci.right_gs)
12+
end
13+
914
for i in 1:odim
1015
# this operation can in principle be even further optimized for larger unit cells
1116
# as we only require the terms that end at level i.
@@ -14,9 +19,7 @@ function left_excitation_transfer_system(
1419
H_partial = map(h -> getindex(h, 1:i, 1, 1, 1:i), parent(H))
1520
T = TransferMatrix(exci.right_gs.AR, H_partial, exci.left_gs.AL)
1621
start = scale!(last(found[1:i] * T), cis(-mom * len))
17-
if exci.trivial && isidentitylevel(H, i)
18-
ρ_left = l_RL(exci.right_gs)
19-
ρ_right = r_RL(exci.right_gs)
22+
if istrivial(exci) && isidentitylevel(H, i)
2023
regularize!(start, ρ_right, ρ_left)
2124
end
2225

@@ -25,8 +28,8 @@ function left_excitation_transfer_system(
2528
if !isemptylevel(H, i)
2629
if isidentitylevel(H, i)
2730
T = TransferMatrix(exci.right_gs.AR, exci.left_gs.AL)
28-
if exci.trivial
29-
T = regularize(T, l_RL(exci.right_gs), r_RL(exci.right_gs))
31+
if istrivial(exci)
32+
T = regularize(T, ρ_left, ρ_right)
3033
end
3134
else
3235
T = TransferMatrix(
@@ -53,6 +56,11 @@ function right_excitation_transfer_system(
5356
found = zerovector(GBR)
5457
odim = length(GBR)
5558

59+
if istrivial(exci)
60+
ρ_left = l_LR(exci.right_gs)
61+
ρ_right = r_LR(exci.right_gs)
62+
end
63+
5664
for i in odim:-1:1
5765
# this operation can in principle be even further optimized for larger unit cells
5866
# as we only require the terms that end at level i.
@@ -61,9 +69,7 @@ function right_excitation_transfer_system(
6169
H_partial = map(h -> h[i:end, 1, 1, i:end], parent(H))
6270
T = TransferMatrix(exci.left_gs.AL, H_partial, exci.right_gs.AR)
6371
start = scale!(first(T * found[i:odim]), cis(mom * len))
64-
if exci.trivial && isidentitylevel(H, i)
65-
ρ_left = l_LR(exci.right_gs)
66-
ρ_right = r_LR(exci.right_gs)
72+
if istrivial(exci) && isidentitylevel(H, i)
6773
regularize!(start, ρ_left, ρ_right)
6874
end
6975

@@ -72,8 +78,8 @@ function right_excitation_transfer_system(
7278
if !isemptylevel(H, i)
7379
if isidentitylevel(H, i)
7480
tm = TransferMatrix(exci.left_gs.AL, exci.right_gs.AR)
75-
if exci.trivial
76-
tm = regularize(tm, l_LR(exci.left_gs), r_LR(exci.right_gs))
81+
if istrivial(exci)
82+
tm = regularize(tm, ρ_left, ρ_right)
7783
end
7884
else
7985
tm = TransferMatrix(
@@ -82,8 +88,7 @@ function right_excitation_transfer_system(
8288
end
8389

8490
found[i], convhist = linsolve(
85-
tm, found[i], found[i], solver, 1,
86-
-cis(mom * len)
91+
tm, found[i], found[i], solver, 1, -cis(mom * len)
8792
)
8893
convhist.converged < 1 &&
8994
@warn "GBR$i failed to converge: normres = $(convhist.normres)"

src/algorithms/excitation/quasiparticleexcitation.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function excitations(H, alg::QuasiparticleAnsatz, ϕ₀::InfiniteQP, lenvs, renv
5757
end
5858
function excitations(H, alg::QuasiparticleAnsatz, ϕ₀::InfiniteQP, lenvs; num = 1, kwargs...)
5959
# Infer `renvs` in function body as it depends on `solver`.
60-
renvs = ϕ₀.trivial ? lenvs : environments(ϕ₀.right_gs, H; kwargs...)
60+
renvs = !istopological(ϕ₀) ? lenvs : environments(ϕ₀.right_gs, H; kwargs...)
6161
return excitations(H, alg, ϕ₀, lenvs, renvs; num, kwargs...)
6262
end
6363
function excitations(H, alg::QuasiparticleAnsatz, ϕ₀::InfiniteQP; num = 1, kwargs...)
@@ -136,7 +136,7 @@ end
136136
function excitations(
137137
H, alg::QuasiparticleAnsatz, ϕ₀::FiniteQP,
138138
lenvs = environments(ϕ₀.left_gs, H),
139-
renvs = ϕ₀.trivial ? lenvs : environments(ϕ₀.right_gs, H);
139+
renvs = !istopological(ϕ₀) ? lenvs : environments(ϕ₀.right_gs, H);
140140
num = 1
141141
)
142142
E = effective_excitation_renormalization_energy(H, ϕ₀, lenvs, renvs)
@@ -223,7 +223,7 @@ function excitations(
223223
kwargs...
224224
)
225225
# Infer `renvs` in function body as it depends on `solver`.
226-
renvs = ϕ₀.trivial ? lenvs : environments(ϕ₀.right_gs, H; kwargs...)
226+
renvs = !istopological(ϕ₀) ? lenvs : environments(ϕ₀.right_gs, H; kwargs...)
227227
return excitations(H, alg, ϕ₀, lenvs, renvs; kwargs...)
228228
end
229229
function excitations(
@@ -372,7 +372,7 @@ function effective_excitation_renormalization_energy(H, ϕ, lenvs, renvs)
372372
E[i] = contract_mpo_expval(
373373
ψ_left.AC[i], leftenv(lenvs, i, ψ_left), H[i], rightenv(lenvs, i, ψ_left)
374374
)
375-
if !ϕ.trivial
375+
if istopological(ϕ)
376376
E[i] += contract_mpo_expval(
377377
ψ_right.AC[i], leftenv(renvs, i, ψ_right), H[i], rightenv(renvs, i, ψ_right)
378378
)

src/environments/qp_envs.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function environments(exci::Union{InfiniteQP, MultilineQP}, H; kwargs...)
3333
return environments(exci, H, lenvs; kwargs...)
3434
end
3535
function environments(exci::Union{InfiniteQP, MultilineQP}, H, lenvs; kwargs...)
36-
renvs = exci.trivial ? lenvs : environments(exci.right_gs, H; kwargs...)
36+
renvs = !istopological(exci) ? lenvs : environments(exci.right_gs, H; kwargs...)
3737
return environments(exci, H, lenvs, renvs; kwargs...)
3838
end
3939

@@ -62,7 +62,7 @@ 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 && !isempty(ids) # regularization of trivial excitations
65+
if istrivial(exci) && !isempty(ids) # regularization of trivial excitations
6666
ρ_left = l_RL(exci.left_gs, pos + 1)
6767
ρ_right = r_RL(exci.left_gs, pos)
6868
for i in ids
@@ -78,7 +78,7 @@ 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 && !isempty(ids)
81+
if istrivial(exci) && !isempty(ids)
8282
ρ_left = l_LR(exci.left_gs, pos)
8383
ρ_right = r_LR(exci.left_gs, pos - 1)
8484
for i in ids
@@ -100,7 +100,7 @@ function environments(exci::InfiniteQP, H::InfiniteMPOHamiltonian, lenvs, renvs;
100100
for i in 1:(length(exci) - 1)
101101
lB_cur = lB_cur * TransferMatrix(AR[i], H[i], AL[i]) / cis(exci.momentum)
102102

103-
if exci.trivial && !isempty(ids)
103+
if istrivial(exci) && !isempty(ids)
104104
ρ_left = l_RL(exci.left_gs, i + 1)
105105
ρ_right = r_RL(exci.left_gs, i)
106106
for k in ids
@@ -115,7 +115,7 @@ function environments(exci::InfiniteQP, H::InfiniteMPOHamiltonian, lenvs, renvs;
115115
for i in length(exci):-1:2
116116
rB_cur = TransferMatrix(AL[i], H[i], AR[i]) * rB_cur * cis(exci.momentum)
117117

118-
if exci.trivial && !isempty(ids)
118+
if istrivial(exci) && !isempty(ids)
119119
ρ_left = l_LR(exci.left_gs, i)
120120
ρ_right = r_LR(exci.left_gs, i - 1)
121121
for k in ids
@@ -132,7 +132,7 @@ end
132132
function environments(
133133
exci::FiniteQP, H::FiniteMPOHamiltonian,
134134
lenvs = environments(exci.left_gs, H),
135-
renvs = exci.trivial ? lenvs : environments(exci.right_gs, H);
135+
renvs = !istopological(exci) ? lenvs : environments(exci.right_gs, H);
136136
kwargs...
137137
)
138138
AL = exci.left_gs.AL
@@ -161,7 +161,7 @@ function environments(
161161
end
162162

163163
function environments(exci::InfiniteQP, O::InfiniteMPO, lenvs, renvs; kwargs...)
164-
exci.trivial ||
164+
istopological(exci) &&
165165
@warn "there is a phase ambiguity in topologically nontrivial statmech excitations"
166166
solver = environment_alg(exci, O, exci; kwargs...)
167167

@@ -203,7 +203,7 @@ function environments(exci::InfiniteQP, O::InfiniteMPO, lenvs, renvs; kwargs...)
203203
T_RL = TransferMatrix(right_gs.AR, O, left_gs.AL)
204204
T_LR = TransferMatrix(left_gs.AL, O, right_gs.AR)
205205

206-
if exci.trivial
206+
if istrivial(exci)
207207
@plansor rvec[-1 -2; -3] := rightenv(lenvs, 0, left_gs)[-1 -2; 1] *
208208
conj(left_gs.C[0][-3; 1])
209209
@plansor lvec[-1 -2; -3] := leftenv(lenvs, 1, left_gs)[-1 -2; 1] *

src/states/quasiparticle_state.jl

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function Base.convert(
133133

134134
tm = TransferMatrix(input.left_gs.AL, input.right_gs.AR)
135135

136-
if input.trivial
136+
if istrivial(input)
137137
tm = regularize(tm, l_LR(input.right_gs), r_LR(input.right_gs))
138138
end
139139

@@ -180,7 +180,7 @@ function Base.convert(
180180
end
181181

182182
tm = TransferMatrix(input.right_gs.AR, input.left_gs.AL)
183-
if input.trivial
183+
if istrivial(input)
184184
tm = regularize(tm, l_RL(input.right_gs), r_RL(input.right_gs))
185185
end
186186

@@ -222,9 +222,12 @@ left_virtualspace(state::QP) = map(Base.Fix1(left_virtualspace, state), eachsite
222222
right_virtualspace(state::QP, i::Int) = right_virtualspace(state.right_gs, i)
223223
right_virtualspace(state::QP) = map(Base.Fix1(right_virtualspace, state), eachsite(state))
224224
auxiliaryspace(state::QP) = space(state.Xs[1], 2)
225-
225+
auxiliarysector(state::QP) = only(sectors(auxiliaryspace(state)))
226226
eachsite(state::QP) = eachsite(state.left_gs)
227227

228+
istopological(qp::QP) = qp.left_gs !== qp.right_gs
229+
istrivial(qp::QP) = !istopological(qp) && isone(auxiliarysector(qp))
230+
228231
Base.copy(a::QP) = copy!(similar(a), a)
229232
Base.copyto!(a::QP, b::QP) = copy!(a, b)
230233
function Base.copy!(a::T, b::T) where {T <: QP}
@@ -233,9 +236,10 @@ function Base.copy!(a::T, b::T) where {T <: QP}
233236
end
234237
return a
235238
end
236-
function Base.getproperty(v::QP, s::Symbol)
239+
Base.@constprop :aggressive function Base.getproperty(v::QP, s::Symbol)
237240
if s == :trivial
238-
return v.left_gs === v.right_gs
241+
Base.depwarn("`qp.trivial` is deprecated in favor of `istrivial` and `istopological`", :trivial)
242+
return !istopological(qp)
239243
else
240244
return getfield(v, s)
241245
end
@@ -402,7 +406,7 @@ function Base.convert(::Type{<:FiniteMPS}, v::QP{S}) where {S <: FiniteMPS}
402406
return FiniteMPS(Ls + Rs + Bs; normalize = false)
403407
end
404408

405-
function Base.getproperty(exci::MultilineQP, s::Symbol)
409+
Base.@constprop :aggressive function Base.getproperty(exci::MultilineQP, s::Symbol)
406410
if s == :momentum
407411
return first(exci.data).momentum
408412
elseif s == :left_gs
@@ -416,6 +420,10 @@ function Base.getproperty(exci::MultilineQP, s::Symbol)
416420
end
417421
end
418422

423+
# These should really all be the same, so it might make sense to take the first instead
424+
istrivial(exci::MultilineQP) = all(istrivial, exci.data)
425+
istopological(exci::MultilineQP) = all(istopological, exci.data)
426+
419427
# VectorInterface
420428
# ---------------
421429

0 commit comments

Comments
 (0)