Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 benchmark/MPSKitBenchmarks/scripts/setup_heisenberg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function initial_state(H)
@assert allequal(physicalspace(H))

pspace = physicalspace(H, 1)
A = rand(oneunit(pspace) ⊗ pspace^2 ← oneunit(pspace))
A = rand(unitspace(pspace) ⊗ pspace^2 ← unitspace(pspace))
As = MPSKit.decompose_localmps(A)
return FiniteMPS(repeat(As, length(H) ÷ 2))
end
Expand Down
1 change: 1 addition & 0 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ When releasing a new version, move the "Unreleased" changes to a new version sec
### Fixed

- `convert(TensorMap, H)` for single-site `FiniteMPOHamiltonian`s no longer contracts the site tensor with itself. ([#252](https://github.com/QuantumKitHub/MPSKit.jl/pull/252))
- `show` methods for finite MPS/MPOs no longer check unit space condition through `oneunit`, which is not defined for multifusion spaces. ([#538](https://github.com/QuantumKitHub/MPSKit.jl/pull/538))

### Performance

Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/quantum1d/6.hubbard/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ charges = fill(FermionParity(1) ⊠ U1Irrep(1) ⊠ SU2Irrep(0), 2);
H_u1_su2 = MPSKit.add_physical_charge(H_u1_su2, charges);

pspaces = physicalspace.(Ref(H_u1_su2), 1:2)
vspaces = [oneunit(eltype(pspaces)), first(pspaces)]
vspaces = [unitspace(eltype(pspaces)), first(pspaces)]
psi = InfiniteMPS(pspaces, vspaces)
psi = compute_groundstate(psi, H_u1_su2; expansionfactor = 1 / 3)
E = real(expectation_value(psi, H_u1_su2)) / 2
Expand Down
4 changes: 2 additions & 2 deletions docs/src/examples/quantum1d/6.hubbard/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@
"H_u1_su2 = MPSKit.add_physical_charge(H_u1_su2, charges);\n",
"\n",
"pspaces = physicalspace.(Ref(H_u1_su2), 1:2)\n",
"vspaces = [oneunit(eltype(pspaces)), first(pspaces)]\n",
"vspaces = [unitspace(eltype(pspaces)), first(pspaces)]\n",
"psi = InfiniteMPS(pspaces, vspaces)\n",
"psi = compute_groundstate(psi, H_u1_su2; expansionfactor = 1 / 3)\n",
"E = real(expectation_value(psi, H_u1_su2)) / 2\n",
Expand Down Expand Up @@ -499,4 +499,4 @@
},
"nbformat": 4,
"nbformat_minor": 3
}
}
2 changes: 1 addition & 1 deletion examples/quantum1d/6.hubbard/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ charges = fill(FermionParity(1) ⊠ U1Irrep(1) ⊠ SU2Irrep(0), 2);
H_u1_su2 = MPSKit.add_physical_charge(H_u1_su2, charges);

pspaces = physicalspace.(Ref(H_u1_su2), 1:2)
vspaces = [oneunit(eltype(pspaces)), first(pspaces)]
vspaces = [unitspace(eltype(pspaces)), first(pspaces)]
psi = InfiniteMPS(pspaces, vspaces)
psi = compute_groundstate(psi, H_u1_su2; expansionfactor = 1 / 3)
E = real(expectation_value(psi, H_u1_su2)) / 2
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/timestep/clusterexpansion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ end

function exponentiate_onsite_tensor(ham_tensor, τ, ::Type{A}) where {A}
physical_space = physicalspace(ham_tensor)
levels = ⊞(oneunit(physical_space))
levels = ⊞(rightunitspace(physical_space))
blocktype = tensormaptype(spacetype(physical_space), 2, 2, A)
tensor = SparseBlockTensorMap{blocktype}(undef, levels ⊗ physical_space ← physical_space ⊗ levels)
onsite = removeunit(removeunit(ham_tensor[1, 1, 1, end], 4), 1)
Expand Down
8 changes: 4 additions & 4 deletions src/utility/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ function Base.show(io::IO, ::MIME"text/plain", ψ::FiniteMPS)

# special handling of edge spaces => don't print if trivial
Vright = right_virtualspace(ψ, L)
right_trivial = Vright == oneunit(Vright)
right_trivial = isunitspace(Vright)
Vleft = left_virtualspace(ψ, 1)
left_trivial = Vleft == oneunit(Vleft)
left_trivial = isunitspace(Vleft)


right_trivial || println(io, "│ ", Vright)
Expand Down Expand Up @@ -122,9 +122,9 @@ function Base.show(io::IO, ::MIME"text/plain", mpo::AbstractMPO)
if isfinite(mpo)
# special handling of edge spaces => don't print if trivial
Vright = right_virtualspace(mpo, L)
right_trivial = Vright == oneunit(Vright)
right_trivial = isunitspace(Vright)
Vleft = left_virtualspace(mpo, 1)
left_trivial = Vleft == oneunit(Vleft)
left_trivial = isunitspace(Vleft)

right_trivial || println(io, "│ ", Vright)
for i in reverse(1:L)
Expand Down
2 changes: 1 addition & 1 deletion test/algorithms/changebonds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ end
H = kitaev_model(ComplexF64, Trivial; t = 1.0, mu = 0, Delta = 0, L = L)
P = physicalspace(H)[1]
S = typeof(P)
Vtriv = oneunit(P)
Vtriv = unitspace(P)
Vodd = S(c => dim(P, c) for c in sectors(P) if !isone(c))
# single particle created on the last site: interior bonds carry only the even sector, so
# the expansion content on them is exactly zero
Expand Down
8 changes: 4 additions & 4 deletions test/groundstate/approximate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ end
function _random_mpo_mps(pspace, Dspace, L; elt = ComplexF64)
Random.seed!(1357)
Wspace = Dspace
Vspaces = [oneunit(Wspace); fill(Wspace, L - 1); oneunit(Wspace)]
Vspaces = [unitspace(Wspace); fill(Wspace, L - 1); unitspace(Wspace)]
O = FiniteMPO(
[rand(ComplexF64, Vspaces[i] ⊗ pspace ← pspace ⊗ Vspaces[i + 1]) for i in 1:L]
)
Expand Down Expand Up @@ -211,7 +211,7 @@ end
@test info.truncation_errors ≈ info_ref.truncation_errors

# a destination with unrelated contents is overwritten entirely
dst = FiniteMPS(rand, ComplexF64, length(ψ), pspace, oneunit(Dspace) ⊕ Dspace ⊕ Dspace)
dst = FiniteMPS(rand, ComplexF64, length(ψ), pspace, unitspace(Dspace) ⊕ Dspace ⊕ Dspace)
got, info = approximate!(dst, (O, ψ), alg)
@test norm(ref - got) / norm(ref) < 1.0e-12
@test info.truncation_errors ≈ info_ref.truncation_errors
Expand Down Expand Up @@ -248,8 +248,8 @@ end
@testset "Zip-up with non-square MPO $(spacetype(pspace))" for (pspace, Dspace, _) in zipup_spacelist
Random.seed!(1357)
L = 4
pspace′ = pspace ⊕ oneunit(pspace) # output physical space, different from the input one
Vspaces = [oneunit(Dspace); fill(Dspace, L - 1); oneunit(Dspace)]
pspace′ = pspace ⊕ unitspace(pspace) # output physical space, different from the input one
Vspaces = [unitspace(Dspace); fill(Dspace, L - 1); unitspace(Dspace)]
O = FiniteMPO(
[rand(ComplexF64, Vspaces[i] ⊗ pspace′ ← pspace ⊗ Vspaces[i + 1]) for i in 1:L]
)
Expand Down
4 changes: 2 additions & 2 deletions test/hamiltonian/mixed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Ts = fast_tests ? (Float64,) : (Float64, ComplexF64)
((i, i + 2) => h for i in 1:(L - 2))...,
((i, i + 3) => h for i in 1:(L - 3))...,
)
mps1 = FiniteMPS(physicalspace(H1), oneunit(V))
mps1 = FiniteMPS(physicalspace(H1), unitspace(V))

for T in Ts
H2 = if VERSION <= v"1.12"
Expand All @@ -106,7 +106,7 @@ Ts = fast_tests ? (Float64,) : (Float64, ComplexF64)
end

H3 = InfiniteMPOHamiltonian(fill(V, L), (1, 2) => h, (1, 3) => h, (1, 4) => h)
mps2 = InfiniteMPS(physicalspace(H3), [oneunit(V)])
mps2 = InfiniteMPS(physicalspace(H3), [unitspace(V)])
for T in Ts
H4 = if VERSION <= v"1.12"
# this is type unstable for LTS for some reason
Expand Down
2 changes: 1 addition & 1 deletion test/states/infinitemps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ end
end

# product state has zero entropy everywhere
ψ_product = InfiniteMPS([d, d], [oneunit(D), oneunit(D)])
ψ_product = InfiniteMPS([d, d], [unitspace(D), unitspace(D)])
Ss_product = entropy(ψ_product)
@test all(S -> isapprox(S, 0; atol = 1.0e-10), Ss_product)
end
Expand Down
Loading