-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement Infinite
Boundary
Conditions for MatrixProduct
and ProjectedEntangledPair
Types
#79
Conversation
Codecov Report
@@ Coverage Diff @@
## master #79 +/- ##
==========================================
- Coverage 78.27% 77.46% -0.82%
==========================================
Files 9 9
Lines 695 701 +6
==========================================
- Hits 544 543 -1
- Misses 151 158 +7
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general is ok, but I think you mixed the PR #78. Please remove anything from that other PR so I can merge this.
src/Quantum/MP.jl
Outdated
tensors(ψ::TensorNetwork{MatrixProduct{P,Infinite}}, args...) where {P<:Plug} = | ||
throw(ArgumentError("You need to specify the site for an infinite MatrixProduct$P")) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it doesn't match any method signature, it's better to let Julia throw a MethodError
.
tensors(ψ::TensorNetwork{MatrixProduct{P,Infinite}}, args...) where {P<:Plug} = | |
throw(ArgumentError("You need to specify the site for an infinite MatrixProduct$P")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I cherry-picked
the commits in #78 because I thought was necessary, I will try to remove them now.
src/Quantum/PEP.jl
Outdated
tensors(ψ::TensorNetwork{ProjectedEntangledPair{P,Infinite}}, args...) where {P<:Plug} = | ||
throw(ArgumentError("You need to specify the site for an infinite MatrixProduct$P")) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as in MP.jl
tensors(ψ::TensorNetwork{ProjectedEntangledPair{P,Infinite}}, args...) where {P<:Plug} = | |
throw(ArgumentError("You need to specify the site for an infinite MatrixProduct$P")) |
src/Quantum/Quantum.jl
Outdated
@@ -81,7 +83,7 @@ Return the `Tensor` connected to the [`TensorNetwork`](@ref) on `site`. | |||
See also: [`sites`](@ref). | |||
""" | |||
tensors(tn::TensorNetwork{<:Quantum}, site::Integer, args...) = tensors(plug(tn), tn, site, args...) | |||
tensors(::Type{State}, tn::TensorNetwork{<:Quantum}, site) = select(tn, labels(tn, :plug, site)) |> only | |||
tensors(::Union{Type{Operator}, Type{State}}, tn::TensorNetwork{<:Quantum}, site) = select(tn, labels(tn, :plug, site)) |> only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you mixed PRs.
tensors(::Union{Type{Operator}, Type{State}}, tn::TensorNetwork{<:Quantum}, site) = select(tn, labels(tn, :plug, site)) |> only | |
tensors(::Type{State}, tn::TensorNetwork{<:Quantum}, site) = select(tn, labels(tn, :plug, site)) |> only |
test/MatrixProductOperator_test.jl
Outdated
|
||
@testset "tensors" begin | ||
arrays = [rand(1, 2, 2), rand(1, 1, 2, 2), rand(1, 2, 2)] | ||
ψ = MatrixProduct{Operator,Open}(arrays, order = (:l, :r, :i, :o)) | ||
|
||
@test tensors(ψ, 1) isa Tensor | ||
@test size(tensors(ψ)) |> first == length(ψ) == 3 | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again you mixed PRs.
@testset "tensors" begin | |
arrays = [rand(1, 2, 2), rand(1, 1, 2, 2), rand(1, 2, 2)] | |
ψ = MatrixProduct{Operator,Open}(arrays, order = (:l, :r, :i, :o)) | |
@test tensors(ψ, 1) isa Tensor | |
@test size(tensors(ψ)) |> first == length(ψ) == 3 | |
end |
@mofeing, your requested changes should be fixed |
Co-authored-by: Sergio Sánchez Ramírez <[email protected]>
Summary
In this PR, we resolve #77 by extending our
MatrixProduct
andProjectedEntangledPair
types to include support for infinite boundary conditions, materialized in the infinite Matrix Product States (iMPS) and infinite Projected Entangled Pair States (iPEPS). This creates a structure where the tensors cycle periodically, emulating an infinite system by using a finite system unit cell that repeats itself.The
tensors
,Base.show
andBase.length
functions have been extended to supportTensorNetworks
withInfinte
boundary conditions. Additional unit tests have been added to ensure the proper functioning of these new boundary conditions for both theMPS
andMPO
structures.Nevertheless, the visualization of infinite boundary types is not yet supported and we should think about how to implement this.
Example
Let's create a
MatrixProduct{State, Infinite}
which consists of a cell of three tensors that repeat indefinitely: