Skip to content
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
a724420
add_util_leg spinoff for MPOHamiltonian
borisdevos Mar 25, 2025
eeefc58
apply add_util_mpoleg to correlator
borisdevos Mar 25, 2025
909e453
use add_util_mpoleg in FiniteMPO
borisdevos Mar 25, 2025
03d4001
use add_util_mpoleg in test on correlator
borisdevos Mar 25, 2025
2abc2ff
avoid `oneunit(S)` in one constructor of `InfiniteMPOHamiltonian`
borisdevos Mar 26, 2025
822d728
avoid `oneunit(S)` in one constructor of `FiniteMPOHamiltonian`
borisdevos Mar 26, 2025
4c1345e
remove type `LocalOperator` in `_oneunit`
borisdevos Mar 26, 2025
9b569d4
remove braidings in `left/right_excitation_transfer_system` of `Infin…
borisdevos Apr 9, 2025
8de0443
typo in `right_excitation_transfer_system`
borisdevos Apr 9, 2025
5fbd831
rewrite `(In)FiniteMPOHamiltonian` and the way `oneunit` was avoided
borisdevos Apr 11, 2025
b981601
Merge branch 'master' of https://github.com/borisdevos/MPSKit.jl into…
borisdevos Apr 17, 2025
c28a9c1
avoid `oneunit(spacetype(H))` evaluation
borisdevos Apr 18, 2025
37cecd3
super important typo
borisdevos Apr 18, 2025
eba85c5
Merge branch 'master' of https://github.com/QuantumKitHub/MPSKit.jl i…
borisdevos Apr 24, 2025
f584d2b
remove comments
borisdevos Jun 10, 2025
f8f6c2c
get `return_type` in `excitations` to evaluate the `sector` kwarg
borisdevos Jun 11, 2025
889873a
typo
borisdevos Jul 17, 2025
94d4d9d
manipulate `oneunit`s in addition of `MPOHamiltonian`s
borisdevos Jul 24, 2025
7597d30
Merge branch 'master' of https://github.com/QuantumKitHub/MPSKit.jl i…
borisdevos Jul 25, 2025
22d01d0
format
borisdevos Jul 25, 2025
1983070
simplify expression
borisdevos Aug 25, 2025
f6578b6
add comments
borisdevos Aug 25, 2025
cf11547
get `infinite_temperature_density_matrix` working
borisdevos Aug 25, 2025
f86dee4
generalise identifying space in `infinite_temperature_density_matrix`
borisdevos Aug 26, 2025
967f68d
make util spaces generic in `left/right_excitation_transfer_system`
borisdevos Aug 27, 2025
2114cdc
remove braiding in `InfiniteQP` environments + rename variables for c…
borisdevos Aug 27, 2025
4435fc2
Revert "remove braiding in `InfiniteQP` environments + rename variabl…
borisdevos Aug 27, 2025
309254d
add multifusion tests
borisdevos Aug 27, 2025
02a944a
actually use my variable everywhere
borisdevos Aug 27, 2025
75a6a1b
add Z2 Ising model
borisdevos Aug 27, 2025
43bbdd9
compare to Z2 Ising model + add injectivity check
borisdevos Aug 27, 2025
3930db3
remove defaulting to `Z2Irrep` for new operators
borisdevos Aug 28, 2025
0aa00ad
fix kitaev model term (even if it's not used)
borisdevos Aug 28, 2025
4b975ad
format
borisdevos Aug 28, 2025
769dbde
actually run the multifusion test
borisdevos Aug 28, 2025
b31ffa1
import TestSetup module, remove unused deps + add variance tests
borisdevos Aug 29, 2025
03dbee3
specify allowed spin for Z2 `S_zz` + don't use deprecated call
borisdevos Aug 29, 2025
a17874a
add variance tests for `FiniteMPS` + allow it to be negative (?) + ad…
borisdevos Aug 29, 2025
2c96ab1
Merge branch 'master' of https://github.com/QuantumKitHub/MPSKit.jl i…
borisdevos Sep 3, 2025
fdd95c7
Revert "Merge branch 'master' of https://github.com/QuantumKitHub/MPS…
borisdevos Sep 3, 2025
54a4f74
Revert "Revert "Merge branch 'master' of https://github.com/QuantumKi…
borisdevos Sep 3, 2025
2f1108e
Revert "Merge branch 'master' of https://github.com/QuantumKitHub/MPS…
borisdevos Sep 3, 2025
8d83a82
Revert "Revert "Merge branch 'master' of https://github.com/QuantumKi…
borisdevos Sep 3, 2025
a2027b0
fix the messed up merges hopefully
borisdevos Sep 3, 2025
05e33dd
format
borisdevos Sep 3, 2025
ca03f89
actually format everything
borisdevos Sep 3, 2025
d0a5ddf
Merge https://github.com/borisdevos/MPSKit.jl into boris-MTK-compat
borisdevos Sep 24, 2025
3e0855a
Merge branch 'main' of https://github.com/QuantumKitHub/MPSKit.jl int…
borisdevos Nov 5, 2025
4783937
typo
borisdevos Nov 25, 2025
54d5c2a
deal with float dimension
borisdevos Nov 25, 2025
a04358e
`left/rightunit` for MPS and MPO
borisdevos Dec 5, 2025
de9ad5a
using `left/rightunit(space)`
borisdevos Dec 5, 2025
0bab813
test updates
borisdevos Dec 5, 2025
18a1862
some `unitspace`s
borisdevos Dec 16, 2025
b16d01e
some `rightunitspace`s
borisdevos Dec 16, 2025
37b8241
docstring to ED
borisdevos Dec 16, 2025
de8cb81
remove ED error test
borisdevos Dec 16, 2025
68acebb
more `rightunitspace`s in tests
borisdevos Dec 16, 2025
a20612f
even more `rightunitspace`s
borisdevos Dec 16, 2025
ddbc1e3
some `unit`s, `leftunit`s and `isunit`s
borisdevos Dec 16, 2025
bf9a13c
Merge branch 'main' of https://github.com/QuantumKitHub/MPSKit.jl int…
borisdevos Dec 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/algorithms/ED.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function exact_diagonalization(

# fuse from left to right
ALs = Vector{Union{Missing, TA}}(missing, L)
left = oneunit(spacetype(H))
left = spacetype(H)(one(sector) => 1) # might need to be rightone, leave this for now
for i in 1:(middle_site - 1)
P = physicalspace(H, i)
ALs[i] = isomorphism(T, left ⊗ P ← fuse(left ⊗ P))
Expand Down
5 changes: 3 additions & 2 deletions src/algorithms/correlators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ function correlator(
end

function correlator(
state::AbstractMPS, O₁₂::AbstractTensorMap{<:Any, S, 2, 2}, i::Int, j
state::AbstractMPS, O₁₂::AbstractTensorMap{<:Any, S, 2, 2}, i::Int,
j
) where {S}
O₁, O₂ = decompose_localmpo(add_util_leg(O₁₂))
O₁, O₂ = decompose_localmpo(add_util_mpoleg(O₁₂))
return correlator(state, O₁, O₂, i, j)
end
31 changes: 25 additions & 6 deletions src/algorithms/excitation/exci_transfer_system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,14 @@ function left_excitation_transfer_system(
T = TransferMatrix(exci.right_gs.AR, H_partial, exci.left_gs.AL)
start = scale!(last(found[1:i] * T), cis(-mom * len))
if exci.trivial && isidentitylevel(H, i)
@plansor start[-1 -2; -3 -4] -= start[1 4; -3 2] * r_RL(exci.right_gs)[2; 3] *
τ[3 4; 5 1] * l_RL(exci.right_gs)[-1; 6] * τ[5 6; -4 -2]
# not using braiding tensors here, leads to extra leg
util = similar(exci.left_gs.AL[1], space(parent(H)[1], 1)[1])
fill_data!(util, one)
@plansor start[-1 -2; -3 -4] -= start[2 1; -3 3] *
util[1] *
r_RL(exci.right_gs)[3; 2] *
l_RL(exci.right_gs)[-1; -4] *
conj(util[-2])
end

found[i] = add!(start, GBL[i])
Expand All @@ -69,7 +75,10 @@ function left_excitation_transfer_system(
if isidentitylevel(H, i)
T = TransferMatrix(exci.right_gs.AR, exci.left_gs.AL)
if exci.trivial
T = regularize(T, l_RL(exci.right_gs), r_RL(exci.right_gs))
# deal with extra leg
@plansor lRL_util[-1 -2; -3] := l_RL(exci.right_gs)[-1;-3] * conj(util[-2])
@plansor rRL_util[-1 -2; -3] := r_RL(exci.right_gs)[-1;-3] * util[-2]
T = regularize(T, lRL_util, rRL_util)
end
else
T = TransferMatrix(
Expand Down Expand Up @@ -129,6 +138,7 @@ function right_excitation_transfer_system(
end
return found
end
#TODO: check that the left/right discrepancies make sense
function right_excitation_transfer_system(
GBR, H::InfiniteMPOHamiltonian, exci;
mom = exci.momentum,
Expand All @@ -147,8 +157,14 @@ function right_excitation_transfer_system(
T = TransferMatrix(exci.left_gs.AL, H_partial, exci.right_gs.AR)
start = scale!(first(T * found[i:odim]), cis(mom * len))
if exci.trivial && isidentitylevel(H, i)
@plansor start[-1 -2; -3 -4] -= τ[6 2; 3 4] * start[3 4; -3 5] *
l_LR(exci.right_gs)[5; 2] * r_LR(exci.right_gs)[-1; 1] * τ[-2 -4; 1 6]
# not using braiding tensors here, leads to extra leg
util = similar(exci.right_gs.AL[1], space(parent(H)[1], 1)[1])
fill_data!(util, one)
@plansor start[-1 -2; -3 -4] -= start[2 1; -3 3] *
conj(util[1]) *
l_LR(exci.right_gs)[3; 2] *
r_LR(exci.right_gs)[-1; -4] *
util[-2]
end

found[i] = add!(start, GBR[i])
Expand All @@ -157,7 +173,10 @@ function right_excitation_transfer_system(
if isidentitylevel(H, i)
tm = TransferMatrix(exci.left_gs.AL, exci.right_gs.AR)
if exci.trivial
tm = regularize(tm, l_LR(exci.left_gs), r_LR(exci.right_gs))
# deal with extra leg
@plansor lLR_util[-1 -2; -3] := l_LR(exci.left_gs)[-1;-3] * conj(util[-2])
@plansor rLR_util[-1 -2; -3] := r_LR(exci.right_gs)[-1;-3] * util[-2]
tm = regularize(tm, lLR_util, rLR_util)
end
else
tm = TransferMatrix(
Expand Down
27 changes: 19 additions & 8 deletions src/algorithms/excitation/quasiparticleexcitation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ end
function excitations(H, alg::QuasiparticleAnsatz, ϕ₀::InfiniteQP, lenvs, renvs; num::Int = 1)
E = effective_excitation_renormalization_energy(H, ϕ₀, lenvs, renvs)
H_eff = EffectiveExcitationHamiltonian(H, lenvs, renvs, E)

Es, ϕs, convhist = eigsolve(ϕ₀, num, :SR, alg.alg) do ϕ
return H_eff(ϕ; alg.alg_environments...)
end
Expand Down Expand Up @@ -105,13 +104,25 @@ function excitations(
verbosity = Defaults.verbosity, num = 1,
sector = one(sectortype(lmps)), parallel = true, kwargs...
)
Toutput = Core.Compiler.return_type(
excitations,
Tuple{
typeof(H), typeof(alg), eltype(momenta), typeof(lmps),
typeof(lenvs), typeof(rmps), typeof(renvs),
}
)
# wrapper to evaluate sector as positional argument
Toutput = let
function wrapper(H, alg, p, lmps, lenvs, rmps, renvs, sector; kwargs...)
return excitations(
H, alg, p, lmps, lenvs, rmps, renvs;
sector, kwargs...
)
end
Core.Compiler.return_type(
wrapper,
Tuple{
typeof(H), typeof(alg),
eltype(momenta), typeof(lmps),
typeof(lenvs),
typeof(rmps), typeof(renvs), typeof(sector),
}
)
end

results = similar(momenta, Toutput)
scheduler = parallel ? :greedy : :serial
tmap!(results, momenta; scheduler) do momentum
Expand Down
8 changes: 4 additions & 4 deletions src/algorithms/fixedpoint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
fixedpoint(A, x₀, which::Symbol; kwargs...) -> val, vec
fixedpoint(A, x₀, which::Symbol, alg) -> val, vec

Compute the fixedpoint of a linear operator `A` using the specified eigensolver `alg`. The
Compute the fixed point of a linear operator `A` using the specified eigensolver `alg`. The
fixedpoint is assumed to be unique.
"""
function fixedpoint(A, x₀, which::Symbol, alg::Lanczos)
vals, vecs, info = eigsolve(A, x₀, 1, which, alg)

if info.converged == 0
@warnv 1 "fixedpoint not converged after $(info.numiter) iterations: normres = $(info.normres[1])"
@warnv 1 "fixed point not converged after $(info.numiter) iterations: normres = $(info.normres[1])"
end

return vals[1], vecs[1]
Expand All @@ -21,10 +21,10 @@ function fixedpoint(A, x₀, which::Symbol, alg::Arnoldi)
TT, vecs, vals, info = schursolve(A, x₀, 1, which, alg)

if info.converged == 0
@warnv 1 "fixedpoint not converged after $(info.numiter) iterations: normres = $(info.normres[1])"
@warnv 1 "fixed point not converged after $(info.numiter) iterations: normres = $(info.normres[1])"
end
if size(TT, 2) > 1 && TT[2, 1] != 0
@warnv 1 "non-unique fixedpoint detected"
@warnv 1 "non-unique fixed point detected"
end

return vals[1], vecs[1]
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/groundstate/gradient_grassmann.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function find_groundstate(
ψ::S, H, alg::GradientGrassmann, envs::P = environments(ψ, H)
)::Tuple{S, P, Float64} where {S, P}
!isa(ψ, FiniteMPS) || dim(ψ.C[end]) == 1 ||
@warn "This is not fully supported - split the mps up in a sum of mps's and optimize seperately"
@warn "This is not fully supported - split the mps up in a sum of mps's and optimize separately"
normalize!(ψ)

fg(x) = GrassmannMPS.fg(x, H, envs)
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/toolbox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Return the density matrix of the infinite temperature state for a given Hamilton
This is the identity matrix in the physical space, and the identity in the auxiliary space.
"""
function infinite_temperature_density_matrix(H::MPOHamiltonian)
V = oneunit(spacetype(H))
V = oneunit(space(first(H[1]), 1))
W = map(1:length(H)) do site
return BraidingTensor{scalartype(H)}(physicalspace(H, site), V)
end
Expand Down
2 changes: 1 addition & 1 deletion src/operators/mpo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function FiniteMPO(Os::AbstractVector{O}) where {O}
end

function FiniteMPO(O::AbstractTensorMap{T, S, N, N}) where {T, S, N}
return FiniteMPO(decompose_localmpo(add_util_leg(O)))
return FiniteMPO(decompose_localmpo(add_util_mpoleg(O)))
end

"""
Expand Down
27 changes: 19 additions & 8 deletions src/operators/mpohamiltonian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,19 @@ function FiniteMPOHamiltonian(lattice::AbstractArray{<:VectorSpace}, local_opera
E = scalartype(T)
S = spacetype(T)

# avoid using one(S)
somempo = local_mpos[1].second[1]
sp_oneleg = space(somempo, 1)

_oneunit = oneunit(sp_oneleg) # should be rightoneunit, but MPOHamiltonians are always diagonal for now

virtualsumspaces = Vector{SumSpace{S}}(undef, length(lattice) + 1)
virtualsumspaces[1] = SumSpace(fill(oneunit(S), 1))
virtualsumspaces[end] = SumSpace(fill(oneunit(S), 1))
virtualsumspaces[1] = SumSpace(fill(_oneunit, 1))
virtualsumspaces[end] = SumSpace(fill(_oneunit, 1))

for i in 1:(length(lattice) - 1)
n_channels = maximum(last, nonzero_keys[i]; init = 1) + 1
V = SumSpace(fill(oneunit(S), n_channels))
V = SumSpace(fill(_oneunit, n_channels))
if n_channels > 2
for ((key_L, key_R), O) in zip(nonzero_keys[i], nonzero_opps[i])
V[key_R == 0 ? end : key_R] = if O isa Number
Expand Down Expand Up @@ -468,9 +474,14 @@ function InfiniteMPOHamiltonian(lattice′::AbstractArray{<:VectorSpace}, local_
virtualspaces = PeriodicArray(
[Vector{MissingS}(missing, operator_size) for _ in 1:length(nonzero_keys)]
)
# avoid using one(S)
somempo = local_mpos[1].second[1]
sp_oneleg = space(somempo, 1)

_oneunit = oneunit(sp_oneleg)
for V in virtualspaces
V[1] = oneunit(S)
V[end] = oneunit(S)
V[1] = _oneunit
V[end] = _oneunit
end

# start by filling in tensors -> space information available
Expand Down Expand Up @@ -516,7 +527,7 @@ function InfiniteMPOHamiltonian(lattice′::AbstractArray{<:VectorSpace}, local_
end
end

foreach(Base.Fix2(replace!, missing => oneunit(S)), virtualspaces)
foreach(Base.Fix2(replace!, missing => _oneunit), virtualspaces)
virtualsumspaces = map(virtualspaces) do V
return SumSpace(collect(S, V))
end
Expand Down Expand Up @@ -658,7 +669,7 @@ function Base.:+(
) where {O <: JordanMPOTensor}
N = check_length(H₁, H₂)
H = similar(parent(H₁))
Vtriv = oneunit(spacetype(H₁))
Vtriv = oneunit(space(first(H₁[1]), 1)) # should also be rightoneunit, but is currently diagonal

for i in 1:N
A = cat(H₁[i].A, H₂[i].A; dims = (1, 4))
Expand All @@ -682,7 +693,7 @@ function Base.:+(
) where {O <: JordanMPOTensor}
N = check_length(H₁, H₂)
H = similar(parent(H₁))
Vtriv = oneunit(spacetype(H₁))
Vtriv = oneunit(space(first(H₁[1]), 1))
for i in 1:N
A = cat(H₁[i].A, H₂[i].A; dims = (1, 4))
B = cat(H₁[i].B, H₂[i].B; dims = 1)
Expand Down
13 changes: 13 additions & 0 deletions src/utility/utility.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ function add_util_leg(tensor::AbstractTensorMap{T, S, N1, N2}) where {T, S, N1,
return util_front * tensor * util_back
end

function add_util_mpoleg(tensor::AbstractTensorMap{T, S, N1, N2}) where {T, S, N1, N2}
# separate function for mpo because add_util_leg is also used for mps from tensors
# and the additional legs there can be different depending on the fusion tree

#TODO?: might need a left and right utility space if MPO has module virtual space (doesn't happen for hamiltonians)
ou = S(one(first(blocksectors(tensor))) => 1)

util_front = isomorphism(storagetype(tensor), ou * codomain(tensor), codomain(tensor))
util_back = isomorphism(storagetype(tensor), domain(tensor), domain(tensor) * ou)

return util_front * tensor * util_back
end

function union_split(a::AbstractArray)
T = reduce((a, b) -> Union{a, b}, typeof.(a))
nA = similar(a, T)
Expand Down
2 changes: 1 addition & 1 deletion test/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ module TestAlgorithms

@test expectation_value(ψ, H) ≈
expectation_value(ψ, 1 => -g * S_x()) + expectation_value(ψ, (1, 2) => -S_zz())
Z_mpo = MPSKit.add_util_leg(S_z())
Z_mpo = MPSKit.add_util_mpoleg(S_z())
G = correlator(ψ, Z_mpo, Z_mpo, 1, 2:5)
G2 = correlator(ψ, S_zz(), 1, 3:2:5)
@test isapprox(G[2], G2[1], atol = 1.0e-2)
Expand Down
Loading