Skip to content

Commit

Permalink
Docstrings and defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
leburgel committed Jul 12, 2024
1 parent d5506fd commit 3634123
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 29 deletions.
113 changes: 92 additions & 21 deletions src/environments/ctmrgenv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@
struct CTMRGEnv{C,T}
Corner transfer-matrix environment containing unit-cell arrays of corner and edge tensors.
The last two indices of the arrays correspond to the row and column indices of the unit
cell, whereas the first index corresponds to the direction of the corner or edge tensor. The
directions are labeled in clockwise direction, starting from the north-west corner and north
edge respectively.
Given arrays of corners `c` and edges `t`, they connect to the PEPS tensors at site `(r, c)`
isn the unit cell as:
```
c[1,r-1,c-1]---t[1,r-1,c]----c[2,r-1,c+1]
| || |
t[4,r,c-1]=====AA[r,c]=======t[2,r,c+1]
| || |
c[4,r+1,c-1]---t[3,r+1,c]----c[3,r+1,c+1]
```
# Fields
- `corners::Array{C,3}`: Array of corner tensors.
- `edges::Array{T,3}`: Array of edge tensors.
"""
struct CTMRGEnv{C,T}
corners::Array{C,3}
Expand Down Expand Up @@ -38,20 +56,42 @@ end

"""
CTMRGEnv(
[f=randn, ComplexF64], Ds_east::A, chis_north::A, chis_east::A, chis_south::A, chis_west::A
[f=randn, ComplexF64], Ds_north, Ds_east::A, chis_north::A, [chis_east::A], [chis_south::A], [chis_west::A]
) where {A<:AbstractMatrix{<:Union{Int,ElementarySpace}}}
TODO: docstring.
Construct a CTMRG environment by specifying matrices of north and east virtual spaces of the
corresponding [`InfinitePEPS`](@ref) and the north, east, south and west virtual spaces of
the environment. Each respective matrix entry corresponds to a site in the unit cell. By
default, the virtual environment 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(
Ds_north::A, Ds_east::A, chis_north::A, chis_east::A, chis_south::A, chis_west::A
Ds_north::A,
Ds_east::A,
chis_north::A,
chis_east::A=chis_north,
chis_south::A=chis_north,
chis_west::A=chis_north,
) where {A<:AbstractMatrix{<:Union{Int,ElementarySpace}}}
return CTMRGEnv(
randn, ComplexF64, 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::A, chis_east::A, chis_south::A, chis_west::A
f,
T,
Ds_north::A,
Ds_east::A,
chis_north::A,
chis_east::A=chis_north,
chis_south::A=chis_north,
chis_west::A=chis_north,
) where {A<:AbstractMatrix{<:Union{Int,ElementarySpace}}}
Ds_south = adjoint.(circshift(Ds_north, (-1, 0)))
Ds_west = adjoint.(circshift(Ds_east, (0, 1)))
Expand Down Expand Up @@ -119,18 +159,24 @@ end

"""
CTMRGEnv(
[f=randn, ComplexF64], D_north::S, D_south::S, chi_north::S, chi_east::S, chi_south::S, chi_west::S; unitcell::Tuple{Int,Int}=(1, 1),
[f=randn, ComplexF64], D_north::S, D_south::S, chi_north::S, [chi_east::S], [chi_south::S], [chi_west::S]; unitcell::Tuple{Int,Int}=(1, 1),
) where {S<:Union{Int,ElementarySpace}}
TODO: docstring.
Construct a CTMRG environment by specifying the north and east virtual spaces of the
corresponding [`InfinitePEPS`](@ref) and the north, east, south and west virtual spaces of
the environment. The PEPS unit cell can be specified by the `unitcell` keyword argument. By
default, the virtual environment 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.
"""
function CTMRGEnv(
D_north::S,
D_south::S,
chi_north::S,
chi_east::S,
chi_south::S,
chi_west::S;
chi_east::S=chi_north,
chi_south::S=chi_north,
chi_west::S=chi_north;
unitcell::Tuple{Int,Int}=(1, 1),
) where {S<:Union{Int,ElementarySpace}}
return CTMRGEnv(
Expand All @@ -150,9 +196,9 @@ function CTMRGEnv(
D_north::S,
D_south::S,
chi_north::S,
chi_east::S,
chi_south::S,
chi_west::S;
chi_east::S=chi_north,
chi_south::S=chi_north,
chi_west::S=chi_north;
unitcell::Tuple{Int,Int}=(1, 1),
) where {S<:Union{Int,ElementarySpace}}
return CTMRGEnv(
Expand All @@ -168,14 +214,28 @@ function CTMRGEnv(
end

"""
function CTMRGEnv(
[f=randn, T=ComplexF64], peps::InfinitePEPS, chis_north::A, chis_east::A, chis_south::A, chis_west::A
CTMRGEnv(
[f=randn, T=ComplexF64], peps::InfinitePEPS, chis_north::A, [chis_east::A], [chis_south::A], [chis_west::A]
) where {A<:AbstractMatrix{<:Union{Int,ElementarySpace}}}
TODO: docstring.
Construct a CTMRG environment by specifying a corresponding [`InfinitePEPS`](@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(
peps::InfinitePEPS, chis_north::A, chis_east::A, chis_south::A, chis_west::A
peps::InfinitePEPS,
chis_north::A,
chis_east::A=chis_north,
chis_south::A=chis_north,
chis_west::A=chis_north,
) where {A<:AbstractMatrix{<:Union{Int,ElementarySpace}}}
Ds_north = map(peps.A) do t
return adjoint(space(t, 2))
Expand All @@ -195,7 +255,13 @@ function CTMRGEnv(
)
end
function CTMRGEnv(
f, T, peps::InfinitePEPS, chis_north::A, chis_east::A, chis_south::A, chis_west::A
f,
T,
peps::InfinitePEPS,
chis_north::A,
chis_east::A=chis_north,
chis_south::A=chis_north,
chis_west::A=chis_north,
) where {A<:AbstractMatrix{<:Union{Int,ElementarySpace}}}
Ds_north = map(peps.A) do t
return adjoint(space(t, 2))
Expand All @@ -216,11 +282,16 @@ function CTMRGEnv(
end

"""
function CTMRGEnv(
peps::InfinitePEPS, chi_north::S, chi_east::S=chi_north, chi_south::S=chi_north, chi_west::S=chi_north,
) where {S<:Union{Int,ElementarySpace}}
CTMRGEnv(
peps::InfinitePEPS, chi_north::S, [chi_east::S], [chi_south::S], [chi_west::S],
) where {S<:Union{Int,ElementarySpace}}
Construct a CTMRG environment by specifying a corresponding [`InfinitePEPS`](@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.
TODO: docstring.
The environment virtual spaces for each site correspond to virtual space of the
corresponding edge tensor for each direction.
"""
function CTMRGEnv(
peps::InfinitePEPS,
Expand Down
3 changes: 2 additions & 1 deletion src/states/abstractpeps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
const PEPSTensor{S}
Default type for PEPS tensors with a single physical index, and 4 virtual indices,
conventionally ordered as: T : P ← N ⊗ E ⊗ S ⊗ W.
conventionally ordered as: ``T : P ← N ⊗ E ⊗ S ⊗ W``. Here, ``P``, ``N``, ``E``, ``S`` and
``W`` denote the physics, north, east, south and west spaces, respectively.
"""
const PEPSTensor{S} = AbstractTensorMap{S,1,4} where {S<:ElementarySpace}

Expand Down
19 changes: 12 additions & 7 deletions src/states/infinitepeps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,23 @@ end

## Constructors
"""
InfinitePEPS(A::AbstractArray{T, 2})
InfinitePEPS(A::AbstractMatrix{T})
Allow users to pass in an array of tensors.
Create an `InfinitePEPS` by specifying a matrix containing the PEPS tensors at each site in
the unit cell.
"""
function InfinitePEPS(A::AbstractArray{T,2}) where {T<:PEPSTensor}
function InfinitePEPS(A::AbstractMatrix{T}) where {T<:PEPSTensor}
return InfinitePEPS(Array(deepcopy(A))) # TODO: find better way to copy
end

"""
InfinitePEPS(f=randn, T=ComplexF64, Pspaces, Nspaces, Espaces)
InfinitePEPS(
f=randn, T=ComplexF64, Pspaces::A, Nspaces::A, [Espaces::A]
) where {A<:AbstractMatrix{<:Union{Int,ElementarySpace}}}
Allow users to pass in arrays of spaces.
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`.
"""
function InfinitePEPS(
Pspaces::A, Nspaces::A, Espaces::A
Expand Down Expand Up @@ -82,8 +87,8 @@ end
"""
InfinitePEPS(f=randn, T=ComplexF64, Pspace, Nspace, [Espace]; unitcell=(1,1))
Create an InfinitePEPS by specifying its spaces and unit cell. Spaces can be specified
either via `Int` or via `ElementarySpace`.
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)
Expand Down

0 comments on commit 3634123

Please sign in to comment.