Skip to content

Commit 99da02f

Browse files
committed
define spaces for SUWeights and InfiniteWeightPEPS
1 parent 184086f commit 99da02f

File tree

2 files changed

+36
-20
lines changed

2 files changed

+36
-20
lines changed

src/states/infiniteweightpeps.jl

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
"""
33
const PEPSWeight
44
5-
Default type for PEPS bond weights with 2 virtual indices, conventionally ordered as: ``wt : WS ← EN``.
5+
Default type for PEPS bond weights with 2 virtual indices, conventionally ordered as: ``wt : WS ← EN``.
66
`WS`, `EN` denote the west/south, east/north spaces for x/y-weights on the square lattice, respectively.
77
"""
88
const PEPSWeight{T,S} = AbstractTensorMap{T,S,1,1}
99

1010
"""
1111
struct SUWeight{E<:PEPSWeight}
1212
13-
Schmidt bond weights used in simple/cluster update.
13+
Schmidt bond weights used in simple/cluster update.
1414
Weight elements are always real and non-negative.
15-
The domain and codomain of each weight matrix
15+
The domain and codomain of each weight matrix
1616
must be an un-dualed `ElementarySapce`.
1717
1818
## Fields
@@ -65,6 +65,12 @@ Base.setindex!(W::SUWeight, args...) = (Base.setindex!(W.data, args...); W)
6565
Base.axes(W::SUWeight, args...) = axes(W.data, args...)
6666
Base.iterate(W::SUWeight, args...) = iterate(W.data, args...)
6767

68+
## spaces
69+
TensorKit.spacetype(w::SUWeight) = spacetype(typeof(w))
70+
TensorKit.spacetype(::Type{T}) where {E,T<:SUWeight{E}} = spacetype(E)
71+
TensorKit.sectortype(w::SUWeight) = sectortype(typeof(w))
72+
TensorKit.sectortype(::Type{<:SUWeight{T}}) where {T} = sectortype(spacetype(T))
73+
6874
## (Approximate) equality
6975
function Base.:(==)(wts1::SUWeight, wts2::SUWeight)
7076
return wts1.data == wts2.data
@@ -97,7 +103,7 @@ end
97103
98104
Represents an infinite projected entangled-pair state on a 2D square lattice
99105
consisting of vertex tensors and bond weights.
100-
The vertex tensor, x-weight and y-weight at row `i`, column `j`
106+
The vertex tensor, x-weight and y-weight at row `i`, column `j`
101107
are defined as (the numbers show the axis order)
102108
```
103109
2
@@ -166,7 +172,7 @@ end
166172
Create an InfiniteWeightPEPS by specifying the physical, north virtual and east virtual spaces
167173
of the PEPS vertex tensor at each site in the unit cell as a matrix.
168174
Each individual space can be specified as either an `Int` or an `ElementarySpace`.
169-
Bond weights are initialized as identity matrices of element type `Float64`.
175+
Bond weights are initialized as identity matrices of element type `Float64`.
170176
"""
171177
function InfiniteWeightPEPS(
172178
Pspaces::M, Nspaces::M, Espaces::M
@@ -192,8 +198,8 @@ end
192198
InfiniteWeightPEPS([f=randn, T=ComplexF64,] Pspace::S, Nspace::S, Espace::S=Nspace; unitcell::Tuple{Int,Int}=(1, 1)) where {S<:ElementarySpace}
193199
194200
Create an InfiniteWeightPEPS by specifying its physical, north and east spaces (as `ElementarySpace`s) and unit cell size.
195-
Use `T` to specify the element type of the vertex tensors.
196-
Bond weights are initialized as identity matrices of element type `Float64`.
201+
Use `T` to specify the element type of the vertex tensors.
202+
Bond weights are initialized as identity matrices of element type `Float64`.
197203
"""
198204
function InfiniteWeightPEPS(Pspaces::S, Nspaces::S, Espaces::S) where {S<:ElementarySpace}
199205
return InfiniteWeightPEPS(randn, ComplexF64, Pspaces, Nspaces, Espaces)
@@ -210,6 +216,11 @@ function Base.size(peps::InfiniteWeightPEPS)
210216
return size(peps.vertices)
211217
end
212218

219+
TensorKit.spacetype(peps::InfiniteWeightPEPS) = spacetype(typeof(peps))
220+
TensorKit.spacetype(::Type{T}) where {E,T<:InfiniteWeightPEPS{E}} = spacetype(E)
221+
TensorKit.sectortype(peps::InfiniteWeightPEPS) = sectortype(typeof(peps))
222+
TensorKit.sectortype(::Type{<:InfiniteWeightPEPS{T}}) where {T} = sectortype(spacetype(T))
223+
213224
function _absorb_weights(
214225
t::PEPSTensor,
215226
weights::SUWeight,
@@ -271,13 +282,13 @@ position (`row`, `col`) in the unit cell. Weights around the tensor at `(row, co
271282
272283
## Arguments
273284
274-
- `t::T` : The vertex tensor to which the weight will be absorbed. The first axis of `t` should be the physical axis.
285+
- `t::T` : The vertex tensor to which the weight will be absorbed. The first axis of `t` should be the physical axis.
275286
- `row::Int` : The row index specifying the position in the tensor network.
276287
- `col::Int` : The column index specifying the position in the tensor network.
277288
- `ax::Int` : The axis into which the weight is absorbed, taking values from 1 to 4, standing for north, east, south, west respectively.
278289
- `weights::SUWeight` : The weight object to absorb into the tensor.
279290
280-
## Keyword arguments
291+
## Keyword arguments
281292
282293
- `sqrtwt::Bool=false` : If `true`, the square root of the weight is absorbed.
283294
- `invwt::Bool=false` : If `true`, the inverse of the weight is absorbed.
@@ -373,7 +384,7 @@ end
373384
: : :
374385
```
375386
376-
- After `mirror_antidiag`, x/y-weights are exchanged.
387+
- After `mirror_antidiag`, x/y-weights are exchanged.
377388
```
378389
| | |
379390
x₃₃ x₂₃ x₁₃
@@ -391,9 +402,9 @@ end
391402
x₃₃ x₂₃ x₁₃
392403
: : :
393404
```
394-
No further operations are needed.
405+
No further operations are needed.
395406
396-
- After `rotl90`, x/y-weights are exchanged.
407+
- After `rotl90`, x/y-weights are exchanged.
397408
```
398409
| | |
399410
x₁₃ x₂₃ x₃₃
@@ -414,9 +425,9 @@ end
414425
We need to further:
415426
- Move 1st column of x-weights to the last column.
416427
- Permute axes of x-weights.
417-
- Flip x-arrows from → to ←.
428+
- Flip x-arrows from → to ←.
418429
419-
- After `rotr90`, x/y-weights are exchanged.
430+
- After `rotr90`, x/y-weights are exchanged.
420431
```
421432
: : :
422433
x₃₃ x₂₃ x₁₃
@@ -435,11 +446,11 @@ end
435446
| | |
436447
```
437448
We need to further:
438-
- Move last row of y-weights to the 1st row.
439-
- Permute axes of y-weights.
440-
- Flip y-arrows from ↑ to ↓.
449+
- Move last row of y-weights to the 1st row.
450+
- Permute axes of y-weights.
451+
- Flip y-arrows from ↑ to ↓.
441452
442-
After `rot180`, x/y-weights are not exchanged.
453+
After `rot180`, x/y-weights are not exchanged.
443454
```
444455
: : :
445456
y₁₃ y₁₂ y₁₁
@@ -460,8 +471,8 @@ After `rot180`, x/y-weights are not exchanged.
460471
We need to further:
461472
- Move 1st column of x-weights to the last column.
462473
- Move last row of y-weights to the 1st row.
463-
- Permute axes of all weights and twist their axis 1.
464-
- Flip x-arrows from → to ←, and y-arrows from ↑ to ↓.
474+
- Permute axes of all weights and twist their axis 1.
475+
- Flip x-arrows from → to ←, and y-arrows from ↑ to ↓.
465476
=#
466477

467478
"""

test/utility/iwpeps_rotation.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ weights = collect(tsvd(rand(Float64, V ← V))[2] for dir in 1:2, r in 1:Nr, c i
7575
weights = SUWeight(weights)
7676
pepswt = InfiniteWeightPEPS(vertices, weights)
7777

78+
@test sectortype(weights) === sectortype(V)
79+
@test spacetype(weights) === spacetype(V)
80+
@test sectortype(pepswt) === sectortype(V)
81+
@test spacetype(pepswt) === spacetype(V)
82+
7883
test_rotation(weights)
7984
@static if pkgversion(TensorKit) >= v"0.14.6"
8085
test_rotation(pepswt)

0 commit comments

Comments
 (0)