diff --git a/README.md b/README.md index 5f20ef98a..e85167616 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ ctmrg_tol = 1e-10 grad_tol = 1e-4 # initialize a PEPS and CTMRG environment -peps₀ = InfinitePEPS(2, D) +peps₀ = InfinitePEPS(ComplexSpace(2), ComplexSpace(D)) env₀, = leading_boundary(CTMRGEnv(peps₀, ComplexSpace(χ)), peps₀; tol=ctmrg_tol) # ground state search diff --git a/docs/src/index.md b/docs/src/index.md index 994995ea1..4423033dd 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -41,7 +41,7 @@ ctmrg_tol = 1e-10 grad_tol = 1e-4 # initialize a PEPS and CTMRG environment -peps₀ = InfinitePEPS(2, D) +peps₀ = InfinitePEPS(ComplexSpace(2), ComplexSpace(D)) env₀, = leading_boundary(CTMRGEnv(peps₀, ComplexSpace(χ)), peps₀; tol=ctmrg_tol) # ground state search diff --git a/src/environments/ctmrg_environments.jl b/src/environments/ctmrg_environments.jl index ef269d270..b6f8bab76 100644 --- a/src/environments/ctmrg_environments.jl +++ b/src/environments/ctmrg_environments.jl @@ -31,37 +31,22 @@ struct CTMRGEnv{C, T} edges::Array{T, 3} end -const ProductSpaceLike{N} = Union{ - NTuple{N, Int}, NTuple{N, <:ElementarySpace}, ProductSpace{<:ElementarySpace, N}, -} -const SpaceLike = Union{ElementarySpaceLike, ProductSpaceLike} - -_elementwise_dual(s::NTuple{N, <:ElementarySpace}) where {N} = dual.(s) - -_spacetype(::Int) = ComplexSpace -_spacetype(::S) where {S <: ElementarySpace} = S -_spacetype(s::ProductSpaceLike) = _spacetype(first(s)) - -_to_space(χ::Int) = ℂ^χ -_to_space(χ::ElementarySpace) = χ -_to_space(χ::ProductSpaceLike) = prod(_to_space, χ) - function _corner_tensor( f, ::Type{T}, left_vspace::S, right_vspace::S = left_vspace - ) where {T, S <: ElementarySpaceLike} - return f(T, _to_space(left_vspace) ← _to_space(right_vspace)) + ) where {T, S <: ElementarySpace} + return f(T, left_vspace ← right_vspace) end function _edge_tensor( f, ::Type{T}, left_vspace::S, pspaces::P, right_vspace::S = left_vspace - ) where {T, S <: ElementarySpaceLike, P <: ProductSpaceLike} - return f(T, _to_space(left_vspace) ⊗ _to_space(pspaces), _to_space(right_vspace)) + ) where {T, S <: ElementarySpace, P <: ProductSpace} + return f(T, left_vspace ⊗ pspaces, right_vspace) end """ CTMRGEnv( [f=randn, T=ComplexF64], Ds_north::A, Ds_east::A, chis_north::B, [chis_east::B], [chis_south::B], [chis_west::B] - ) where {A<:AbstractMatrix{<:SpaceLike}, B<:AbstractMatrix{<:ElementarySpaceLike}} + ) where {A<:AbstractMatrix{<:VectorSpace}, B<:AbstractMatrix{<:ElementarySpace}} Construct a CTMRG environment by specifying matrices of north and east virtual spaces of the corresponding partition function and the north, east, south and west virtual spaces of the @@ -76,32 +61,27 @@ of the corresponding edge tensor for each direction. Specifically, for a given s `chis_west[r, c]` corresponds to the north space of the west edge tensor. Each entry of the `Ds_north` and `Ds_east` matrices corresponds to an effective local space -of the partition function, represented as a tuple of elementary spaces encoding a product -space. This can either contain a single elementary space for the case of a partition -function defined in terms of local rank-4 tensors, or a tuple of elementary spaces -representing a product space for the case of a partition function representing overlaps of -PEPSs and PEPOs. +of the partition function, and can be represented as an `ElementarySpace` (e.g. for the case +of a partition function defined in terms of local rank-4 tensors) or a `ProductSpace` (e.g. +for the case of a network representing overlaps of PEPSs and PEPOs). """ function CTMRGEnv( - Ds_north::A, Ds_east::A, - chis_north::B, chis_east::B = chis_north, chis_south::B = chis_north, chis_west::B = chis_north, - ) where {A <: AbstractMatrix{<:ProductSpaceLike}, B <: AbstractMatrix{<:ElementarySpaceLike}} - return CTMRGEnv( - randn, ComplexF64, N, Ds_north, Ds_east, chis_north, chis_east, chis_south, chis_west, - ) -end -function CTMRGEnv( - f, T, - Ds_north::A, Ds_east::A, - chis_north::B, chis_east::B = chis_north, chis_south::B = chis_north, chis_west::B = chis_north, - ) where {A <: AbstractMatrix{<:ProductSpaceLike}, B <: AbstractMatrix{<:ElementarySpaceLike}} + f, T, Ds_north::A, Ds_east::A, chis_north::B, chis_east::B = chis_north, + chis_south::B = chis_north, chis_west::B = chis_north, + ) where { + A <: AbstractMatrix{<:ProductSpace}, B <: AbstractMatrix{<:ElementarySpace}, + } + # check all of the sizes + size(Ds_north) == size(Ds_east) == size(chis_north) == size(chis_east) == + size(chis_south) == size(chis_west) || throw(ArgumentError("Input spaces should have equal sizes.")) + # no recursive broadcasting? Ds_south = _elementwise_dual.(circshift(Ds_north, (-1, 0))) Ds_west = _elementwise_dual.(circshift(Ds_east, (0, 1))) # do the whole thing N = length(first(Ds_north)) - st = _spacetype(first(Ds_north)) + st = spacetype(first(Ds_north)) C_type = tensormaptype(st, 1, 1, T) T_type = tensormaptype(st, N + 1, 1, T) @@ -140,12 +120,37 @@ function CTMRGEnv( edges[:, :, :] ./= norm.(edges[:, :, :]) return CTMRGEnv(corners, edges) end +function CTMRGEnv(D_north::P, args...; kwargs...) where {P <: Union{Matrix{VectorSpace}, VectorSpace}} + return CTMRGEnv(randn, ComplexF64, D_north, args...; kwargs...) +end + +# expand physical edge spaces to unit cell size +function _fill_edge_physical_spaces( + D_north::S, D_east::S = D_north; unitcell::Tuple{Int, Int} = (1, 1) + ) where {S <: VectorSpace} + return fill(ProductSpace(D_north), unitcell), fill(ProductSpace(D_east), unitcell) +end + +# expand virtual environment spaces to unit cell size +function _fill_environment_virtual_spaces( + chis_north::S, chis_east::S = chis_north, chis_south::S = chis_north, chis_west::S = chis_north; + unitcell::Tuple{Int, Int} = (1, 1) + ) where {S <: ElementarySpace} + return fill(chis_north, unitcell), fill(chis_east, unitcell), fill(chis_south, unitcell), fill(chis_west, unitcell) +end +function _fill_environment_virtual_spaces( + chis_north::M, chis_east::M = chis_north, chis_south::M = chis_north, chis_west::M = chis_north; + unitcell::Tuple{Int, Int} = (1, 1) + ) where {M <: AbstractMatrix{<:ElementarySpace}} + @assert size(chis_north) == size(chis_east) == size(chis_south) == size(chis_west) == unitcell "Incompatible size" + return chis_north, chis_east, chis_south, chis_west +end """ CTMRGEnv( [f=randn, T=ComplexF64], D_north::P, D_east::P, chi_north::S, [chi_east::S], [chi_south::S], [chi_west::S]; unitcell::Tuple{Int,Int}=(1, 1), - ) where {P<:ProductSpaceLike,S<:ElementarySpaceLike} + ) where {P<:VectorSpace,S<:ElementarySpace} Construct a CTMRG environment by specifying the north and east virtual spaces of the corresponding [`InfiniteSquareNetwork`](@ref) and the north, east, south and west virtual @@ -156,122 +161,55 @@ same. The environment virtual spaces for each site correspond to virtual space of the corresponding edge tensor for each direction. """ -function CTMRGEnv( - D_north::P, D_east::P, - chi_north::S, chi_east::S = chi_north, chi_south::S = chi_north, chi_west::S = chi_north; - unitcell::Tuple{Int, Int} = (1, 1), - ) where {P <: ProductSpaceLike, S <: ElementarySpaceLike} - return CTMRGEnv( - randn, ComplexF64, - fill(D_north, unitcell), fill(D_east, unitcell), - fill(chi_north, unitcell), fill(chi_east, unitcell), - fill(chi_south, unitcell), fill(chi_west, unitcell), - ) -end -function CTMRGEnv( - f, T, - D_north::P, D_east::P, - chi_north::S, chi_east::S = chi_north, - chi_south::S = chi_north, chi_west::S = chi_north; - unitcell::Tuple{Int, Int} = (1, 1), - ) where {P <: ProductSpaceLike, S <: ElementarySpaceLike} - return CTMRGEnv( - f, T, N, - fill(D_north, unitcell), fill(D_east, unitcell), - fill(chi_north, unitcell), fill(chi_east, unitcell), - fill(chi_south, unitcell), fill(chi_west, unitcell), - ) -end - -""" - CTMRGEnv( - [f=randn, T=ComplexF64], network::InfiniteSquareNetwork, chis_north::A, [chis_east::A], [chis_south::A], [chis_west::A] - ) where {A<:AbstractMatrix{<:ElementarySpaceLike}}} - -Construct a CTMRG environment by specifying a corresponding [`InfiniteSquareNetwork`](@ref), and the -north, east, south and west virtual spaces of the environment as matrices. Each respective -matrix entry corresponds to a site in the unit cell. By default, the virtual spaces for all -directions are taken to be the same. - -The environment virtual spaces for each site correspond to the north or east virtual space -of the corresponding edge tensor for each direction. Specifically, for a given site -`(r, c)`, `chis_north[r, c]` corresponds to the east space of the north edge tensor, -`chis_east[r, c]` corresponds to the north space of the east edge tensor, -`chis_south[r, c]` corresponds to the east space of the south edge tensor, and -`chis_west[r, c]` corresponds to the north space of the west edge tensor. -""" -function CTMRGEnv( - network::InfiniteSquareNetwork, - chis_north::A, chis_east::A = chis_north, chis_south::A = chis_north, chis_west::A = chis_north, - ) where {A <: AbstractMatrix{<:ElementarySpaceLike}} - Ds_north = _north_env_spaces(network) - Ds_east = _east_env_spaces(network) - return CTMRGEnv( - randn, scalartype(network), - Ds_north, Ds_east, - _to_space.(chis_north), _to_space.(chis_east), _to_space.(chis_south), _to_space.(chis_west), - ) -end function CTMRGEnv( f, T, - network::InfiniteSquareNetwork, - chis_north::A, chis_east::A = chis_north, chis_south::A = chis_north, chis_west::A = chis_north, - ) where {A <: AbstractMatrix{<:ElementarySpaceLike}} - Ds_north = _north_env_spaces(network) - Ds_east = _east_env_spaces(network) + D_north::S, D_east::S, virtual_spaces...; unitcell::Tuple{Int, Int} = (1, 1), + ) where {S <: VectorSpace} return CTMRGEnv( f, T, - Ds_north, Ds_east, - _to_space.(chis_north), _to_space.(chis_east), _to_space.(chis_south), _to_space.(chis_west), + _fill_edge_physical_spaces(D_north, D_east; unitcell)..., + _fill_environment_virtual_spaces(virtual_spaces...; unitcell)..., ) end -function _north_env_spaces(network::InfiniteSquareNetwork) +# get edge physical spaces from network +function _north_edge_physical_spaces(network::InfiniteSquareNetwork) return map(ProductSpace ∘ _elementwise_dual ∘ north_virtualspace, unitcell(network)) end -function _east_env_spaces(network::InfiniteSquareNetwork) +function _east_edge_physical_spaces(network::InfiniteSquareNetwork) return map(ProductSpace ∘ _elementwise_dual ∘ east_virtualspace, unitcell(network)) end """ CTMRGEnv( - [f=randn, T=ComplexF64,] network::InfiniteSquareNetwork, chi_north::S, [chi_east::S], [chi_south::S], [chi_west::S], - ) where {S<:ElementarySpaceLike} + [f=randn, T=ComplexF64], network::InfiniteSquareNetwork, chis_north::A, [chis_east::A], [chis_south::A], [chis_west::A] + ) where {A<:Union{AbstractMatrix{<:ElementarySpace}, ElementarySpace}} Construct a CTMRG environment by specifying a corresponding [`InfiniteSquareNetwork`](@ref), and the north, east, south and west virtual spaces of the -environment. By default, the virtual spaces for all directions are taken to be the same. +environment. The virtual spaces can either be specified as matrices of `ElementarySpace`s, +or as individual `ElementarySpace`s which are then filled to match the size of the unit +cell. Each respective matrix entry corresponds to a site in the unit cell. By default, the +virtual spaces for all directions are taken to be the same. -The environment virtual spaces for each site correspond to virtual space of the -corresponding edge tensor for each direction. +The environment virtual spaces for each site correspond to the north or east virtual space +of the corresponding edge tensor for each direction. Specifically, for a given site +`(r, c)`, `chis_north[r, c]` corresponds to the east space of the north edge tensor, +`chis_east[r, c]` corresponds to the north space of the east edge tensor, +`chis_south[r, c]` corresponds to the east space of the south edge tensor, and +`chis_west[r, c]` corresponds to the north space of the west edge tensor. """ -function CTMRGEnv( - network::InfiniteSquareNetwork, - chi_north::S, chi_east::S = chi_north, chi_south::S = chi_north, chi_west::S = chi_north, - ) where {S <: ElementarySpaceLike} - return CTMRGEnv( - network, - fill(chi_north, size(network)), fill(chi_east, size(network)), - fill(chi_south, size(network)), fill(chi_west, size(network)), - ) +function CTMRGEnv(f, T, network::InfiniteSquareNetwork, virtual_spaces...) + Ds_north = _north_edge_physical_spaces(network) + Ds_east = _east_edge_physical_spaces(network) + virtual_spaces = _fill_environment_virtual_spaces(virtual_spaces...; unitcell = size(network)) + return CTMRGEnv(f, T, Ds_north, Ds_east, virtual_spaces...) end -function CTMRGEnv( - f, T, - network::InfiniteSquareNetwork, - chi_north::S, chi_east::S = chi_north, chi_south::S = chi_north, chi_west::S = chi_north, - ) where {S <: ElementarySpaceLike} - return CTMRGEnv( - f, T, - network, - fill(chi_north, size(network)), fill(chi_east, size(network)), - fill(chi_south, size(network)), fill(chi_west, size(network)), - ) +function CTMRGEnv(network::Union{InfiniteSquareNetwork, InfinitePartitionFunction, InfinitePEPS}, virtual_spaces...) + return CTMRGEnv(randn, scalartype(network), network, virtual_spaces...) end # allow constructing environments for implicitly defined contractible networks -function CTMRGEnv(state::Union{InfinitePartitionFunction, InfinitePEPS}, args...) - return CTMRGEnv(InfiniteSquareNetwork(state), args...) -end function CTMRGEnv(f, T, state::Union{InfinitePartitionFunction, InfinitePEPS}, args...) return CTMRGEnv(f, T, InfiniteSquareNetwork(state), args...) end diff --git a/src/states/infinitepartitionfunction.jl b/src/states/infinitepartitionfunction.jl index cec961c62..9bd8d6dfc 100644 --- a/src/states/infinitepartitionfunction.jl +++ b/src/states/infinitepartitionfunction.jl @@ -49,14 +49,9 @@ Create an `InfinitePartitionFunction` by specifying the physical, north virtual of the PEPS tensor at each site in the unit cell as a matrix. Each individual space can be specified as either an `Int` or an `ElementarySpace`. """ -function InfinitePartitionFunction( - Nspaces::A, Espaces::A - ) where {A <: AbstractMatrix{<:ElementarySpaceLike}} - return InfinitePartitionFunction(randn, ComplexF64, Nspaces, Espaces) -end function InfinitePartitionFunction( f, T, Nspaces::M, Espaces::M = Nspaces - ) where {M <: AbstractMatrix{<:ElementarySpaceLike}} + ) where {M <: AbstractMatrix{<:ElementarySpace}} size(Nspaces) == size(Espaces) || throw(ArgumentError("Input spaces should have equal sizes.")) @@ -69,6 +64,9 @@ function InfinitePartitionFunction( return InfinitePartitionFunction(A) end +function InfinitePartitionFunction(Nspaces::A, args...) where {A <: Union{AbstractMatrix{<:ElementarySpace}, ElementarySpace}} + return InfinitePartitionFunction(randn, ComplexF64, Nspaces, args...) +end """ InfinitePartitionFunction(A; unitcell=(1, 1)) @@ -99,22 +97,15 @@ end """ InfinitePartitionFunction( [f=randn, T=ComplexF64,] Pspace::S, Nspace::S, [Espace::S]; unitcell=(1,1) - ) where {S<:ElementarySpaceLike} + ) where {S<:ElementarySpace} Create an InfinitePartitionFunction by specifying its physical, north and east spaces and unit cell. Spaces can be specified either via `Int` or via `ElementarySpace`. """ -function InfinitePartitionFunction( - Nspace::S, Espace::S = Nspace; unitcell::Tuple{Int, Int} = (1, 1) - ) where {S <: ElementarySpaceLike} - return InfinitePartitionFunction( - randn, ComplexF64, fill(Nspace, unitcell), fill(Espace, unitcell) - ) -end function InfinitePartitionFunction( f, T, Nspace::S, Espace::S = Nspace; unitcell::Tuple{Int, Int} = (1, 1) - ) where {S <: ElementarySpaceLike} - return InfinitePartitionFunction(f, T, fill(Nspace, unitcell), fill(Espace, unitcell)) + ) where {S <: ElementarySpace} + return InfinitePartitionFunction(f, T, _fill_state_virtual_spaces(Nspace, Espace; unitcell)...) end ## Unit cell interface diff --git a/src/states/infinitepeps.jl b/src/states/infinitepeps.jl index 09ae6ae2c..4da54d0e0 100644 --- a/src/states/infinitepeps.jl +++ b/src/states/infinitepeps.jl @@ -26,8 +26,6 @@ end ## Constructors -const ElementarySpaceLike = Union{Int, ElementarySpace} - """ InfinitePEPS(A::AbstractMatrix{T}) @@ -39,20 +37,14 @@ function InfinitePEPS(A::AbstractMatrix{<:PEPSTensor}) end """ - InfinitePEPS([f=randn, T=ComplexF64,] Pspaces::A, Nspaces::A, [Espaces::A]) where {A<:AbstractMatrix{<:Union{Int,ElementarySpace}}} + InfinitePEPS([f=randn, T=ComplexF64,] Pspaces::A, Nspaces::A, [Espaces::A]) where {A<:AbstractMatrix{ElementarySpace}} Create an `InfinitePEPS` by specifying the physical, north virtual and east virtual spaces -of the PEPS tensor at each site in the unit cell as a matrix. Each individual space can be -specified as either an `Int` or an `ElementarySpace`. +of the PEPS tensor at each site in the unit cell as a matrix. """ function InfinitePEPS( - Pspaces::A, Nspaces::A, Espaces::A - ) where {A <: AbstractMatrix{<:ElementarySpaceLike}} - return InfinitePEPS(randn, ComplexF64, Pspaces, Nspaces, Espaces) -end -function InfinitePEPS( - f, T, Pspaces::M, Nspaces::M, Espaces::M = Nspaces - ) where {M <: AbstractMatrix{<:ElementarySpaceLike}} + f, T::Type{<:Number}, Pspaces::M, Nspaces::M, Espaces::M = Nspaces + ) where {M <: AbstractMatrix{<:ElementarySpace}} size(Pspaces) == size(Nspaces) == size(Espaces) || throw(ArgumentError("Input spaces should have equal sizes.")) @@ -65,6 +57,11 @@ function InfinitePEPS( return InfinitePEPS(A) end +function InfinitePEPS( + Pspaces::A, virtual_spaces...; kwargs... + ) where {A <: Union{AbstractMatrix{<:ElementarySpace}, ElementarySpace}} + return InfinitePEPS(randn, ComplexF64, Pspaces, virtual_spaces...; kwargs...) +end """ InfinitePEPS(A::PEPSTensor; unitcell=(1, 1)) @@ -90,25 +87,30 @@ function InfinitePEPS(A::T; unitcell::Tuple{Int, Int} = (1, 1)) where {T <: PEPS return InfinitePEPS(fill(A, unitcell)) end +# expand PEPS spaces to unit cell size +function _fill_state_physical_spaces( + Pspace::S; unitcell::Tuple{Int, Int} = (1, 1) + ) where {S <: ElementarySpace} + return fill(Pspace, unitcell) +end +function _fill_state_virtual_spaces( + Nspace::S, Espace::S = Nspace; unitcell::Tuple{Int, Int} = (1, 1) + ) where {S <: ElementarySpace} + return fill(Nspace, unitcell), fill(Espace, unitcell) +end + """ InfinitePEPS([f=randn, T=ComplexF64,] Pspace, Nspace, [Espace]; unitcell=(1,1)) Create an InfinitePEPS by specifying its physical, north and east spaces and unit cell. -Spaces can be specified either via `Int` or via `ElementarySpace`. """ function InfinitePEPS( - Pspace::S, Nspace::S, Espace::S = Nspace; unitcell::Tuple{Int, Int} = (1, 1) - ) where {S <: ElementarySpaceLike} - return InfinitePEPS( - randn, ComplexF64, - fill(Pspace, unitcell), fill(Nspace, unitcell), fill(Espace, unitcell), - ) -end -function InfinitePEPS( - f, T, Pspace::S, Nspace::S, Espace::S = Nspace; unitcell::Tuple{Int, Int} = (1, 1) - ) where {S <: ElementarySpaceLike} + f, T::Type{<:Number}, Pspace::S, vspaces...; unitcell::Tuple{Int, Int} = (1, 1) + ) where {S <: ElementarySpace} return InfinitePEPS( - f, T, fill(Pspace, unitcell), fill(Nspace, unitcell), fill(Espace, unitcell) + f, T, + _fill_state_physical_spaces(Pspace; unitcell), + _fill_state_virtual_spaces(vspaces...; unitcell)..., ) end diff --git a/test/ctmrg/fixed_iterscheme.jl b/test/ctmrg/fixed_iterscheme.jl index dbf4b5ba5..e6f305d44 100644 --- a/test/ctmrg/fixed_iterscheme.jl +++ b/test/ctmrg/fixed_iterscheme.jl @@ -32,7 +32,7 @@ atol = 1.0e-5 # initialize states Random.seed!(2394823842) - psi = InfinitePEPS(2, χbond; unitcell) + psi = InfinitePEPS(ComplexSpace(2), ComplexSpace(χbond); unitcell) n = InfiniteSquareNetwork(psi) env_conv1, = leading_boundary(CTMRGEnv(psi, ComplexSpace(χenv)), psi, ctm_alg) @@ -62,7 +62,7 @@ end # initialize states Random.seed!(91283219347) - psi = InfinitePEPS(2, χbond) + psi = InfinitePEPS(ComplexSpace(2), ComplexSpace(χbond)) n = InfiniteSquareNetwork(psi) env₀ = CTMRGEnv(psi, ComplexSpace(χenv)) env_conv1, = leading_boundary(env₀, psi, ctm_alg_iter) diff --git a/test/ctmrg/flavors.jl b/test/ctmrg/flavors.jl index b7605b769..e222c2e0c 100644 --- a/test/ctmrg/flavors.jl +++ b/test/ctmrg/flavors.jl @@ -14,7 +14,7 @@ projector_algs = [:halfinfinite, :fullinfinite] Iterators.product(unitcells, projector_algs) # compute environments Random.seed!(32350283290358) - psi = InfinitePEPS(2, χbond; unitcell) + psi = InfinitePEPS(ComplexSpace(2), ComplexSpace(χbond); unitcell) env_sequential, = leading_boundary( CTMRGEnv(psi, ComplexSpace(χenv)), psi; alg = :sequential, projector_alg ) @@ -54,10 +54,10 @@ end # test fixedspace actually fixes space @testset "Fixedspace truncation using $alg and $projector_alg" for (alg, projector_alg) in Iterators.product([:sequential, :simultaneous], projector_algs) - Ds = fill(2, 3, 3) - χs = [16 17 18; 15 20 21; 14 19 22] + Ds = ComplexSpace.(fill(2, 3, 3)) + χs = ComplexSpace.([16 17 18; 15 20 21; 14 19 22]) psi = InfinitePEPS(Ds, Ds, Ds) - env = CTMRGEnv(psi, rand(10:20, 3, 3), rand(10:20, 3, 3)) + env = CTMRGEnv(psi, ComplexSpace.(rand(10:20, 3, 3)), ComplexSpace.(rand(10:20, 3, 3))) env2, = leading_boundary( env, psi; alg, maxiter = 1, trscheme = FixedSpaceTruncation(), projector_alg ) diff --git a/test/ctmrg/jacobian_real_linear.jl b/test/ctmrg/jacobian_real_linear.jl index 0e3509621..20e232ca7 100644 --- a/test/ctmrg/jacobian_real_linear.jl +++ b/test/ctmrg/jacobian_real_linear.jl @@ -19,7 +19,7 @@ Dbond, χenv = 2, 16 @testset "$iterscheme and $ctm_alg" for (iterscheme, ctm_alg) in algs Random.seed!(123521938519) - state = InfinitePEPS(2, Dbond) + state = InfinitePEPS(ComplexSpace(2), ComplexSpace(Dbond)) env, = leading_boundary(CTMRGEnv(state, ComplexSpace(χenv)), state, ctm_alg) # follow code of _rrule diff --git a/test/ctmrg/unitcell.jl b/test/ctmrg/unitcell.jl index cae8733bf..68382f0db 100644 --- a/test/ctmrg/unitcell.jl +++ b/test/ctmrg/unitcell.jl @@ -27,11 +27,11 @@ function test_unitcell( # compute random expecation value to test matching bonds random_op = LocalOperator( - PEPSKit._to_space.(Pspaces), + Pspaces, [ (c,) => randn( scalartype(peps), - PEPSKit._to_space(Pspaces[c]), PEPSKit._to_space(Pspaces[c]), + Pspaces[c], Pspaces[c], ) for c in CartesianIndices(unitcell) ]..., ) @@ -55,23 +55,6 @@ function random_dualize!(M::AbstractMatrix{<:ElementarySpace}) return M end -@testset "Integer space specifiers with $ctm_alg" for ctm_alg in ctm_algs - unitcell = (3, 3) - - Pspaces = rand(2:3, unitcell...) - Nspaces = rand(2:4, unitcell...) - Espaces = rand(2:4, unitcell...) - chis_north = rand(5:10, unitcell...) - chis_east = rand(5:10, unitcell...) - chis_south = rand(5:10, unitcell...) - chis_west = rand(5:10, unitcell...) - - test_unitcell( - ctm_alg, unitcell, - Pspaces, Nspaces, Espaces, chis_north, chis_east, chis_south, chis_west, - ) -end - @testset "Random Cartesian spaces with $ctm_alg" for ctm_alg in ctm_algs unitcell = (3, 3) diff --git a/test/examples/heisenberg.jl b/test/examples/heisenberg.jl index 1c109913c..9a390d914 100644 --- a/test/examples/heisenberg.jl +++ b/test/examples/heisenberg.jl @@ -18,7 +18,7 @@ E_ref = -0.6602310934799577 # initialize states Random.seed!(123) H = heisenberg_XYZ(InfiniteSquare()) - peps₀ = InfinitePEPS(2, Dbond) + peps₀ = InfinitePEPS(ComplexSpace(2), ComplexSpace(Dbond)) env₀, = leading_boundary(CTMRGEnv(peps₀, ComplexSpace(χenv)), peps₀) # optimize energy and compute correlation lengths @@ -34,7 +34,7 @@ end Random.seed!(456) unitcell = (1, 2) H = heisenberg_XYZ(InfiniteSquare(unitcell...)) - peps₀ = InfinitePEPS(2, Dbond; unitcell) + peps₀ = InfinitePEPS(ComplexSpace(2), ComplexSpace(Dbond); unitcell) env₀, = leading_boundary(CTMRGEnv(peps₀, ComplexSpace(χenv)), peps₀) # optimize energy and compute correlation lengths diff --git a/test/examples/j1j2_model.jl b/test/examples/j1j2_model.jl index 743d90406..b155d5264 100644 --- a/test/examples/j1j2_model.jl +++ b/test/examples/j1j2_model.jl @@ -12,7 +12,7 @@ using OptimKit # initialize states Random.seed!(91283219347) H = j1_j2_model(InfiniteSquare(); J2 = 0.25) -peps₀ = product_peps(2, χbond; noise_amp = 1.0e-1) +peps₀ = product_peps(ComplexSpace(2), ComplexSpace(χbond); noise_amp = 1.0e-1) peps₀ = symmetrize!(peps₀, RotateReflect()) env₀, = leading_boundary(CTMRGEnv(peps₀, ComplexSpace(χenv)), peps₀) diff --git a/test/examples/tf_ising.jl b/test/examples/tf_ising.jl index 5646ef40b..9be741d5a 100644 --- a/test/examples/tf_ising.jl +++ b/test/examples/tf_ising.jl @@ -24,7 +24,7 @@ gradtol = 1.0e-3 # initialize states H = transverse_field_ising(InfiniteSquare(); g) Random.seed!(2928528935) -peps₀ = InfinitePEPS(2, χbond) +peps₀ = InfinitePEPS(ComplexSpace(2), ComplexSpace(χbond)) env₀, = leading_boundary(CTMRGEnv(peps₀, ComplexSpace(χenv)), peps₀) # find fixedpoint diff --git a/test/utility/svd_wrapper.jl b/test/utility/svd_wrapper.jl index 7f382836e..45e7f4aa8 100644 --- a/test/utility/svd_wrapper.jl +++ b/test/utility/svd_wrapper.jl @@ -126,7 +126,7 @@ end # ctm_alg = CTMRG(; tol=1e-10, verbosity=2, svd_alg=SVDAdjoint()) # Random.seed!(91283219347) # H = heisenberg_XYZ(InfiniteSquare()) -# psi = InfinitePEPS(2, χbond) +# psi = InfinitePEPS(ComplexSpace(2), ComplexSpace(χbond)) # env = leading_boundary(CTMRGEnv(psi, ComplexSpace(χenv)), psi, ctm_alg); # hienv = HalfInfiniteEnv( # env.corners[1], diff --git a/test/utility/symmetrization.jl b/test/utility/symmetrization.jl index 1e3749c70..f59b550b4 100644 --- a/test/utility/symmetrization.jl +++ b/test/utility/symmetrization.jl @@ -4,7 +4,7 @@ using PEPSKit: herm_depth, herm_width, _fit_spaces using TensorKit @testset "ReflectDepth" for unitcell in [(1, 1), (2, 2), (3, 3)] - peps = InfinitePEPS(2, 2; unitcell) + peps = InfinitePEPS(ComplexSpace(2), ComplexSpace(2); unitcell) peps_depth = symmetrize!(deepcopy(peps), ReflectDepth()) peps_reflect = _fit_spaces( @@ -14,7 +14,7 @@ using TensorKit end @testset "ReflectWidth" for unitcell in [(1, 1), (2, 2), (3, 3)] - peps = InfinitePEPS(2, 2; unitcell) + peps = InfinitePEPS(ComplexSpace(2), ComplexSpace(2); unitcell) peps_width = symmetrize!(deepcopy(peps), ReflectWidth()) peps_reflect = _fit_spaces( @@ -24,7 +24,7 @@ end end @testset "Rotate" for unitcell in [(1, 1), (2, 2), (3, 3)] - peps = InfinitePEPS(2, 2; unitcell) + peps = InfinitePEPS(ComplexSpace(2), ComplexSpace(2); unitcell) peps_rot = symmetrize!(deepcopy(peps), Rotate()) @test peps_rot ≈ _fit_spaces(rotl90(peps_rot), peps_rot) @@ -33,7 +33,7 @@ end end @testset "RotateReflect" for unitcell in [(1, 1), (2, 2), (3, 3)] - peps = InfinitePEPS(2, 2; unitcell) + peps = InfinitePEPS(ComplexSpace(2), ComplexSpace(2); unitcell) peps_full = symmetrize!(deepcopy(peps), RotateReflect()) @test peps_full ≈ _fit_spaces(rotl90(peps_full), peps_full)