Skip to content

Commit

Permalink
Add InfinitePEPS constructor with integers
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos committed Mar 8, 2024
1 parent 3f525e8 commit 6f14da5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 29 deletions.
10 changes: 1 addition & 9 deletions examples/heisenberg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ function square_lattice_heisenberg(; Jx=-1, Jy=1, Jz=-1)
return NLocalOperator{NearestNeighbor}(H)
end

# Initialize InfinitePEPS with random & complex entries by default
function init_peps(d, D, Lx, Ly, finit=randn, dtype=ComplexF64)
Pspaces = fill(ℂ^d, Lx, Ly)
Nspaces = fill(ℂ^D, Lx, Ly)
Espaces = fill(ℂ^D, Lx, Ly)
return InfinitePEPS(finit, dtype, Pspaces, Nspaces, Espaces)
end

# Parameters
H = square_lattice_heisenberg(; Jx=-1, Jy=1, Jz=-1)
χbond = 2
Expand All @@ -42,7 +34,7 @@ alg = PEPSOptimize{LinSolve}(;
)

# Ground state search
ψ₀ = init_peps(2, χbond, 1, 1)
ψ₀ = InfinitePEPS(2, χbond)
env₀ = leading_boundary(ψ₀, ctmalg, CTMRGEnv(ψ₀; Venv=^χenv))
result = fixedpoint(ψ₀, H, alg, env₀)
@show result.E
10 changes: 1 addition & 9 deletions examples/test_gauge_fixing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,11 @@ using LinearAlgebra
using TensorKit, MPSKitModels, OptimKit
using PEPSKit

# Initialize InfinitePEPS with random & complex entries by default
function init_peps(d, D, Lx, Ly, finit=randn, dtype=ComplexF64)
Pspaces = fill(ℂ^d, Lx, Ly)
Nspaces = fill(ℂ^D, Lx, Ly)
Espaces = fill(ℂ^D, Lx, Ly)
return InfinitePEPS(finit, dtype, Pspaces, Nspaces, Espaces)
end

# Initialize PEPS and environment
χbond = 2
χenv = 20
ctmalg = CTMRG(; trscheme=truncdim(χenv), tol=1e-10, miniter=4, maxiter=100, verbosity=2)
ψ = init_peps(2, χbond, 2, 2)
ψ = InfinitePEPS(2, χbond; unitcell=(2, 2))
env = leading_boundary(ψ, ctmalg, CTMRGEnv(ψ; Venv=^χenv))

println("\nBefore gauge-fixing:")
Expand Down
10 changes: 1 addition & 9 deletions examples/test_gradients.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,12 @@ function square_lattice_heisenberg(; Jx=-1.0, Jy=1.0, Jz=-1.0)
return NLocalOperator{NearestNeighbor}(H)
end

# Initialize InfinitePEPS with random & complex entries by default
function init_peps(d, D, Lx, Ly, finit=randn, dtype=ComplexF64)
Pspaces = fill(ℂ^d, Lx, Ly)
Nspaces = fill(ℂ^D, Lx, Ly)
Espaces = fill(ℂ^D, Lx, Ly)
return InfinitePEPS(finit, dtype, Pspaces, Nspaces, Espaces)
end

# Initialize PEPS and environment
H = square_lattice_heisenberg()
χbond = 2
χenv = 20
ctmalg = CTMRG(; trscheme=truncdim(χenv), tol=1e-12, miniter=4, maxiter=100, verbosity=2)
ψ = init_peps(2, χbond, 1, 1)
ψ = InfinitePEPS(2, χbond)
env = leading_boundary(ψ, ctmalg, CTMRGEnv(ψ; Venv=^χenv))

# Compute CTM gradient in four different ways (set reuse_env=false to not mutate environment)
Expand Down
4 changes: 2 additions & 2 deletions src/states/infinitepeps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ Allow users to pass in arrays of spaces.
"""
function InfinitePEPS(
Pspaces::A, Nspaces::A, Espaces::A
) where {A<:AbstractArray{<:ElementarySpace,2}}
) where {A<:AbstractMatrix{<:Union{Int,ElementarySpace}}}
return InfinitePEPS(randn, ComplexF64, Pspaces, Nspaces, Espaces)
end
function InfinitePEPS(
f, T, Pspaces::M, Nspaces::M, Espaces::M=Nspaces
) where {M<:AbstractArray{<:ElementarySpace,2}}
) where {M<:AbstractMatrix{<:Union{Int,ElementarySpace}}}
size(Pspaces) == size(Nspaces) == size(Espaces) ||
throw(ArgumentError("Input spaces should have equal sizes."))

Expand Down

0 comments on commit 6f14da5

Please sign in to comment.