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

Use random_itensor and random_mps #85

Merged
merged 1 commit into from
May 17, 2024
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
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ SplitApplyCombine = "03a91e81-4c3e-53e1-a0a4-9c0c8f19dd66"
[compat]
Compat = "3, 4"
HDF5 = "0.15, 0.16, 0.17"
ITensorMPS = "0.1, 0.2"
ITensors = "0.3.48, 0.4, 0.5, 0.6"
ITensorMPS = "0.2.2"
ITensors = "0.6.8"
Infinities = "0.1"
IterTools = "1"
KrylovKit = "0.5, 0.6, 0.7"
Expand Down
2 changes: 1 addition & 1 deletion examples/development/finite_mps_to_infinite_mps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function main(; N, J, h, nsites)
s = siteinds("S=1/2", N)

H = MPO(ising_opsum_finite(N; J=J, h=h), s)
ψ0 = randomMPS(s)
ψ0 = random_mps(s)

energy, ψ = dmrg(H, ψ0; nsweeps=10, cutoff=1e-10)
@show energy / N
Expand Down
2 changes: 1 addition & 1 deletion examples/development/orthogonalize_infinitemps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ s = siteinds("S=1/2", nsites; conserve_szparity=true)
space = (("SzParity", 1, 2) => χ ÷ 2) ⊕ (("SzParity", 0, 2) => χ ÷ 2)
ψ = InfiniteMPS(ComplexF64, s; space=space)
for n in 1:nsites
ψ[n] = randomITensor(inds(ψ[n]))
ψ[n] = random_itensor(inds(ψ[n]))
end

ψ = orthogonalize(ψ, :)
Expand Down
6 changes: 3 additions & 3 deletions examples/development/vumps/transfer_matrix_spectrum_arpack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ end
Nfinite = 100
sfinite = siteinds("S=1/2", Nfinite; conserve_szparity=true)
Hfinite = MPO(model, sfinite; model_params...)
ψfinite = randomMPS(sfinite, initstate)
ψfinite = random_mps(sfinite, initstate)
@show flux(ψfinite)
sweeps = Sweeps(10)
setmaxdim!(sweeps, maxdim)
Expand Down Expand Up @@ -111,8 +111,8 @@ using LinearAlgebra

T = TransferMatrix(ψ.AL)
Tᵀ = transpose(T)
vⁱᴿ = randomITensor(dag(input_inds(T)))
vⁱᴸ = randomITensor(dag(input_inds(Tᵀ)))
vⁱᴿ = random_itensor(dag(input_inds(T)))
vⁱᴸ = random_itensor(dag(input_inds(Tᵀ)))

neigs = 10
tol = 1e-10
Expand Down
2 changes: 1 addition & 1 deletion examples/development/vumps/vumps_from_dmrg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ J = 1.0
h = 1.5
model = Model("ising")
H = MPO(model, s; J=J, h=h)
ψ0 = randomMPS(s)
ψ0 = random_mps(s)

sweeps = Sweeps(10)
maxdim!(sweeps, 10)
Expand Down
2 changes: 1 addition & 1 deletion examples/development/vumps/vumps_ising_noncontiguous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ energy_infinite = expect(ψ_0, H)
Nfinite = 100
sfinite = siteinds("S=1/2", Nfinite; conserve_szparity=true)
Hfinite = MPO(model, sfinite; J=J, h=h)
ψfinite = randomMPS(sfinite, initstate; linkdims=10)
ψfinite = random_mps(sfinite, initstate; linkdims=10)
@show flux(ψfinite)
sweeps = Sweeps(15)
setmaxdim!(sweeps, maxdim)
Expand Down
2 changes: 1 addition & 1 deletion examples/development/vumps/vumps_localham_qns.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ initstate(n) = isodd(n) ? "↑" : "↓"
Nfinite = 100
sfinite = siteinds("S=1/2", Nfinite; conserve_szparity=true)
Hfinite = MPO(model, sfinite; model_kwargs...)
ψfinite = randomMPS(sfinite, initstate)
ψfinite = random_mps(sfinite, initstate)
sweeps = Sweeps(20)
setmaxdim!(sweeps, 1)
setcutoff!(sweeps, 1E-10)
Expand Down
6 changes: 3 additions & 3 deletions examples/vumps/transfer_matrix_spectrum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ subspace_expansion_kwargs = (cutoff=cutoff, maxdim=maxdim)
Nfinite = 100
sfinite = siteinds("S=1/2", Nfinite; conserve_szparity=conserve_qns)
Hfinite = MPO(model, sfinite; model_params...)
ψfinite = randomMPS(sfinite, initstate)
ψfinite = random_mps(sfinite, initstate)
@show flux(ψfinite)
sweeps = Sweeps(10)
setmaxdim!(sweeps, maxdim)
Expand Down Expand Up @@ -111,8 +111,8 @@ using LinearAlgebra

T = TransferMatrix(ψ.AL)
Tᵀ = transpose(T)
vⁱᴿ = randomITensor(dag(input_inds(T)))
vⁱᴸ = randomITensor(dag(input_inds(Tᵀ)))
vⁱᴿ = random_itensor(dag(input_inds(T)))
vⁱᴸ = random_itensor(dag(input_inds(Tᵀ)))

neigs = 10
tol = 1e-10
Expand Down
2 changes: 1 addition & 1 deletion examples/vumps/vumps_heisenberg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ energy_exact = reference(model, Observable("energy"))
Nfinite = 100
sfinite = siteinds("S=1/2", Nfinite; conserve_qns)
Hfinite = MPO(model, sfinite)
ψfinite = randomMPS(sfinite, initstate; linkdims=10)
ψfinite = random_mps(sfinite, initstate; linkdims=10)
@show flux(ψfinite)

nsweeps = 10
Expand Down
2 changes: 1 addition & 1 deletion examples/vumps/vumps_hubbard_extended.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ energy_infinite = map(b -> expect_two_site(ψ, H[b], b), bs)
Nfinite = 100
sfinite = siteinds("Electron", Nfinite; conserve_qns)
Hfinite = MPO(model, sfinite; model_params...)
ψfinite = randomMPS(sfinite, initstate; linkdims=10)
ψfinite = random_mps(sfinite, initstate; linkdims=10)
println("\nQN sector of starting finite MPS")
@show flux(ψfinite)

Expand Down
2 changes: 1 addition & 1 deletion examples/vumps/vumps_ising.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ subspace_expansion_kwargs = (cutoff=cutoff, maxdim=maxdim)
nsite_finite = 100
s_finite = siteinds("S=1/2", nsite_finite; conserve_szparity=conserve_qns)
H_finite = MPO(model, s_finite; model_params...)
ψ_finite = randomMPS(s_finite, initstate)
ψ_finite = random_mps(s_finite, initstate)
@show flux(ψ_finite)
sweeps = Sweeps(10)
setmaxdim!(sweeps, maxdim)
Expand Down
2 changes: 1 addition & 1 deletion examples/vumps/vumps_ising_extended.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ energy_infinite = expect(ψ, H)
Nfinite = 100
sfinite = siteinds("S=1/2", Nfinite; conserve_szparity=conserve_qns)
Hfinite = MPO(model, sfinite; J=J, J₂=J₂, h=h)
ψfinite = randomMPS(sfinite, initstate; linkdims=10)
ψfinite = random_mps(sfinite, initstate; linkdims=10)
@show flux(ψfinite)
dmrg_kwargs = (nsweeps=10, maxdim, cutoff)
energy_finite_total, ψfinite = dmrg(Hfinite, ψfinite; dmrg_kwargs...)
Expand Down
6 changes: 3 additions & 3 deletions src/infinitemps_approx.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function infinitemps_approx(
# XXX: Why doesn't this work?
# randn!.(A)
for n in 1:N
A[n] = randomITensor(inds(A[n]))
A[n] = random_itensor(inds(A[n]))
end
ψ∞ = orthogonalize(A, :)

Expand All @@ -62,14 +62,14 @@ function infinitemps_approx(
TR = TR * ψ[n] * ψ∞.AR[inf_range[n]]
end

L0 = randomITensor(linkind(ψ∞.AL, first(inf_range) - 1 => first(inf_range)))
L0 = random_itensor(linkind(ψ∞.AL, first(inf_range) - 1 => first(inf_range)))
vals, vecs, _ = eigsolve(transpose(ITensorMap(ψ∞.AL[inf_range], ψ)), L0)
L0 = vecs[1]
λL0 = vals[1]
LTL = L0 * TL
LTL = replaceinds(LTL, inds(LTL) => inds(L0))

RN = randomITensor(linkind(ψ∞.AR, last(inf_range) => last(inf_range) + 1))
RN = random_itensor(linkind(ψ∞.AR, last(inf_range) => last(inf_range) + 1))
vals, vecs, _ = eigsolve(ITensorMap(ψ∞.AR[inf_range], ψ), RN)
RN = vecs[1]
λRN = vals[1]
Expand Down
2 changes: 1 addition & 1 deletion src/orthogonalize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function right_orthogonalize(
T = TransferMatrix(ψ)

# TODO: make an optional initial state
v₁ᴿᴺ = randomITensor(dag(input_inds(T)))
v₁ᴿᴺ = random_itensor(dag(input_inds(T)))

# Start by getting the right eivenvector/eigenvalue of T
# TODO: make a function `right_environments(::InfiniteMPS)` that computes
Expand Down
10 changes: 5 additions & 5 deletions test/test_itensormap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ using Random

@testset "ITensorMap" begin
i = Index(2)
A1 = randomITensor(i'', dag(i))
A2 = randomITensor(i', dag(i''))
B1 = randomITensor(i'', dag(i))
B2 = randomITensor(i', dag(i''))
A1 = random_itensor(i'', dag(i))
A2 = random_itensor(i', dag(i''))
B1 = random_itensor(i'', dag(i))
B2 = random_itensor(i', dag(i''))
c1 = 2.3
c2 = 3.4

MA = ITensorMap([A1, A2])
MB = ITensorMap([B1, B2])
v = randomITensor(i)
v = random_itensor(i)

@test MA(v) ≈ noprime(A2 * A1 * v)
@test MB(v) ≈ noprime(B2 * B1 * v)
Expand Down
4 changes: 2 additions & 2 deletions test/test_vumps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ end
Nfinite = 100
sfinite = siteinds("S=1/2", Nfinite; conserve_szparity=true)
Hfinite = MPO(model, sfinite; model_kwargs...)
ψfinite = randomMPS(sfinite, initstate)
ψfinite = random_mps(sfinite, initstate)
nsweeps = 20
energy_finite_total, ψfinite = dmrg(
Hfinite, ψfinite; nsweeps, maxdim=10, cutoff=1e-10, outputlevel=0
Expand Down Expand Up @@ -139,7 +139,7 @@ end
Nfinite = 100
sfinite = siteinds("S=1/2", Nfinite; conserve_szparity=true)
Hfinite = MPO(model, sfinite; model_kwargs...)
ψfinite = randomMPS(sfinite, initstate)
ψfinite = random_mps(sfinite, initstate)
nsweeps = 20
energy_finite_total, ψfinite = dmrg(
Hfinite, ψfinite; nsweeps, maxdim=10, cutoff=1e-10, outputlevel=0
Expand Down
4 changes: 2 additions & 2 deletions test/test_vumps_extendedising.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ end
Nfinite = 100
sfinite = siteinds("S=1/2", Nfinite; conserve_szparity=true)
Hfinite = MPO(model, sfinite; model_kwargs...)
ψfinite = randomMPS(sfinite, initstate)
ψfinite = random_mps(sfinite, initstate)
energy_finite_total, ψfinite = dmrg(
Hfinite, ψfinite; outputlevel=0, nsweeps=30, maxdim=30, cutoff=1e-10
)
Expand Down Expand Up @@ -89,7 +89,7 @@ end
space = (("SzParity", 1, 2) => χ ÷ 2) ⊕ (("SzParity", 0, 2) => χ ÷ 2)
ψ = InfiniteMPS(ComplexF64, s; space=space)
for n in 1:N
ψ[n] = randomITensor(inds(ψ[n]))
ψ[n] = random_itensor(inds(ψ[n]))
end
ψ = orthogonalize(ψ, :)
@test contract(ψ.AL[1:N]) * ψ.C[N] ≈ ψ.C[0] * contract(ψ.AR[1:N])
Expand Down
6 changes: 3 additions & 3 deletions test/test_vumpsmpo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ end
Nfinite = 100
sfinite = siteinds("S=1/2", Nfinite; conserve_szparity=true)
Hfinite = MPO(model, sfinite; model_kwargs...)
ψfinite = randomMPS(sfinite, initstate)
ψfinite = random_mps(sfinite, initstate)

sweeps = Sweeps(20)
setmaxdim!(sweeps, 10)
Expand Down Expand Up @@ -102,7 +102,7 @@ end
Nfinite = 100
sfinite = siteinds("S=1/2", Nfinite; conserve_szparity=true)
Hfinite = MPO(model, sfinite; model_kwargs...)
ψfinite = randomMPS(sfinite, initstate)
ψfinite = random_mps(sfinite, initstate)
nsweeps = 20
energy_finite_total, ψfinite = dmrg(
Hfinite, ψfinite; nsweeps, maxdim=10, cutoff=1e-10, outputlevel=0
Expand Down Expand Up @@ -173,7 +173,7 @@ end
Nfinite = 100
sfinite = siteinds("S=1/2", Nfinite; conserve_szparity=true)
Hfinite = MPO(model, sfinite; model_kwargs...)
ψfinite = randomMPS(sfinite, initstate)
ψfinite = random_mps(sfinite, initstate)
sweeps = Sweeps(20)
setmaxdim!(sweeps, 10)
setcutoff!(sweeps, 1E-10)
Expand Down
Loading