Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CompatHelper: bump compat for VectorInterface to 0.3, (keep existing compat) #62

Merged
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
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ TensorKit = "0.11"
TensorKitManifolds = "0.5, 0.6"
TensorOperations = "4"
Transducers = "0.4"
VectorInterface = "0.2"
VectorInterface = "0.2, 0.3, 0.4"
julia = "1.6"

[extras]
Expand Down
6 changes: 4 additions & 2 deletions src/algorithms/expval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ function expectation_value(
opp * transpose(
ac, ((TensorKit.allind(ac)[2:(end - 1)]), (1, TensorKit.numind(ac)))
),
((TensorKit.numind(ac) - 1, TensorKit.allind(ac)[1:(end - 2)]...),
(TensorKit.numind(ac),)),
(
(TensorKit.numind(ac) - 1, TensorKit.allind(ac)[1:(end - 2)]...),
(TensorKit.numind(ac),),
),
),
)
end
Expand Down
2 changes: 1 addition & 1 deletion src/operators/mpohamiltonian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function Base.:+(a::H, b::H) where {H<:MPOHamiltonian}
# this is a bit of a hack because I can't figure out how to make this more specialised
# than the fallback which promotes, while still having access to S,T, and E.
S, T, E = H.parameters

a.period == b.period ||
throw(ArgumentError("periodicity should match $(a.period) ≠ $(b.period)"))
@assert sanitycheck(a)
Expand Down
10 changes: 5 additions & 5 deletions src/operators/sparsempo/sparsempo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ Base.checkbounds(a::SparseMPO, I...) = true
# promotion and conversion
# ------------------------
function Base.promote_rule(
::Type{SparseMPO{S,T₁,E₁}},
::Type{SparseMPO{S,T₂,E₂}},
::Type{SparseMPO{S,T₁,E₁}}, ::Type{SparseMPO{S,T₂,E₂}}
) where {S,T₁,E₁,T₂,E₂}
return SparseMPO{S,promote_type(T₁, T₂),promote_type(E₁, E₂)}
end
Expand Down Expand Up @@ -85,8 +84,9 @@ function SparseMPO(x::AbstractArray{Union{E,M},3}) where {M<:MPOTensor,E<:Number
(period, numrows, numcols) = size(x)

Sp = spacetype(M)
E == scalartype(M) ||
throw(ArgumentError("scalar type should match mpo scalartype $E ≠ $(scalartype(M))"))
E == scalartype(M) || throw(
ArgumentError("scalar type should match mpo scalartype $E ≠ $(scalartype(M))")
)
numrows == numcols || throw(ArgumentError("mpos have to be square"))

domspaces = PeriodicArray{Union{Missing,Sp}}(missing, period, numrows)
Expand Down Expand Up @@ -310,7 +310,7 @@ end

function Base.convert(::Type{DenseMPO}, s::SparseMPO)
embeds = PeriodicArray(_embedders.([s[i].domspaces for i in 1:length(s)]))

data = PeriodicArray(
map(1:size(s, 1)) do loc
return mapreduce(+, Iterators.product(1:(s.odim), 1:(s.odim))) do (i, j)
Expand Down
6 changes: 4 additions & 2 deletions src/states/windowmps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,11 @@ end

function TensorKit.dot(Ψ₁::WindowMPS, Ψ₂::WindowMPS)
length(Ψ₁) == length(Ψ₂) || throw(ArgumentError("MPS with different length"))
Ψ₁.left_gs == Ψ₂.left_gs || dot(Ψ₁.left_gs, Ψ₂.left_gs) ≈ 1 ||
Ψ₁.left_gs == Ψ₂.left_gs ||
dot(Ψ₁.left_gs, Ψ₂.left_gs) ≈ 1 ||
throw(ArgumentError("left InfiniteMPS are different"))
Ψ₁.right_gs == Ψ₂.right_gs || dot(Ψ₁.right_gs, Ψ₂.right_gs) ≈ 1 ||
Ψ₁.right_gs == Ψ₂.right_gs ||
dot(Ψ₁.right_gs, Ψ₂.right_gs) ≈ 1 ||
throw(ArgumentError("right InfiniteMPS are different"))

ρr = TransferMatrix(Ψ₂.AR[2:end], Ψ₁.AR[2:end]) * r_RR(Ψ₂)
Expand Down
4 changes: 3 additions & 1 deletion src/utility/utility.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ function decompose_localmpo(
U, S, V = tsvd(transpose(inpmpo, (leftind, rightind)); trunc=trunc)

A = transpose(U * S, ((2, 3), (1, 4)))
B = transpose(V, ((1, reverse(ntuple(x -> x + N, N - 2))...), ntuple(x -> x + 1, N - 1)))
B = transpose(
V, ((1, reverse(ntuple(x -> x + N, N - 2))...), ntuple(x -> x + 1, N - 1))
)
return [A; decompose_localmpo(B)]
end

Expand Down
16 changes: 6 additions & 10 deletions test/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ println("
include("setup.jl")

@testset "find_groundstate" verbose = true begin
tol = 1e-6
tol = 1e-8
verbosity = 0
infinite_algs = [
VUMPS(; tol_galerkin=tol, verbose=verbosity > 0),
Expand All @@ -19,19 +19,17 @@ include("setup.jl")
]

H = force_planar(transverse_field_ising(; g=1.1))
ψ₀ = InfiniteMPS([ℙ^2], [ℙ^10])
v₀ = variance(ψ₀, H)

@testset "Infinite $i" for (i, alg) in enumerate(infinite_algs)
L = alg isa IDMRG2 ? 2 : 1
ψ₀ = repeat(InfiniteMPS([ℙ^2], [ℙ^10]), L)
ψ₀ = repeat(InfiniteMPS([ℙ^2], [ℙ^16]), L)
H = repeat(force_planar(transverse_field_ising(; g=1.1)), L)

v₀ = variance(ψ₀, H)
ψ, envs, δ = find_groundstate(ψ₀, H, alg)
v = variance(ψ, H, envs)

@test sum(δ) < 100 * tol
@test sum(δ) < 1e-4
@test v₀ > v && v < 1e-2 # energy variance should be low
end

Expand Down Expand Up @@ -263,7 +261,7 @@ end
@testset "fidelity susceptibility" begin
X = TensorMap(ComplexF64[0 1; 1 0], ℂ^2 ← ℂ^2)
Z = TensorMap(ComplexF64[1 0; 0 -1], ℂ^2 ← ℂ^2)

H_X = MPOHamiltonian(X)
H_ZZ = MPOHamiltonian(Z ⊗ Z)

Expand Down Expand Up @@ -359,9 +357,7 @@ end
st1, _ = approximate(st, (sW1, st), VUMPS(; verbose=false))
st2, _ = approximate(st, (W2, st), VUMPS(; verbose=false))
st3, _ = approximate(st, (W1, st), IDMRG1(; verbose=false))
st4, _ = approximate(
st, (sW2, st), IDMRG2(; trscheme=truncdim(20), verbose=false)
)
st4, _ = approximate(st, (sW2, st), IDMRG2(; trscheme=truncdim(20), verbose=false))
st5, _ = timestep(st, th, dt, TDVP())
st6 = changebonds(W1 * st, SvdCut(; trscheme=truncdim(10)))

Expand Down Expand Up @@ -424,7 +420,7 @@ end
@tensor leftstart[-1 -2; -3] := l_LL(gs)[-1, -3] * conj(ut[-2])
T = TransferMatrix([gs.AC[1]; gs.AR[2:end]], translation[:], [gs.AC[1]; gs.AR[2:end]])
v = leftstart * T

expval = @tensor v[1, 2, 3] * r_RR(gs)[3, 1] * ut[2]

@test expval ≈ 1 atol = 1e-5
Expand Down
2 changes: 1 addition & 1 deletion test/other.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ end
@test !isnan(sum(entropy(ts)))
@test !isnan(sum(entropy(ts, 2)))
end
end
end
16 changes: 12 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@ const GROUP = uppercase(get(ENV, "GROUP", "ALL"))

@time begin
if GROUP == "ALL" || GROUP == "STATES"
@time @testset "States" verbose = true begin include("states.jl") end
@time @testset "States" verbose = true begin
include("states.jl")
end
end
if GROUP == "ALL" || GROUP == "OPERATORS"
@time @testset "Operators" verbose = true begin include("operators.jl") end
@time @testset "Operators" verbose = true begin
include("operators.jl")
end
end
if GROUP == "ALL" || GROUP == "ALGORITHMS"
@time @testset "Algorithms" verbose = true begin include("algorithms.jl") end
@time @testset "Algorithms" verbose = true begin
include("algorithms.jl")
end
end
if GROUP == "ALL" || GROUP == "OTHER"
@time @testset "Other" verbose = true begin include("other.jl") end
@time @testset "Other" verbose = true begin
include("other.jl")
end
end
end
4 changes: 1 addition & 3 deletions test/setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ using TensorKit: PlanarTrivial, ℙ

# using TensorOperations



force_planar(x::Number) = x
function force_planar(x::AbstractTensorMap)
cod = reduce(*, map(i -> ℙ^dim(space(x, i)), codomainind(x)))
Expand Down Expand Up @@ -93,4 +91,4 @@ function sixvertex(; a=1.0, b=1.0, c=1.0)
0 0 0 a
]
return DenseMPO(permute(TensorMap(d, ℂ^2 ⊗ ℂ^2, ℂ^2 ⊗ ℂ^2), ((1, 2), (4, 3))))
end
end
Loading