Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

Fix canonize function and enhance index semantics #8

Merged
merged 8 commits into from
Feb 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/Ansatz/Chain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,13 @@ function Chain(::Operator, boundary::Open, arrays::Vector{<:AbstractArray})
end

rightsite(tn::Chain, site::Site) = rightsite(boundary(tn), tn, site)
rightsite(::Open, tn::Chain, site::Site) = Site(site.id + 1)
rightsite(::Union{Open, Periodic}, tn::Chain, site::Site) = Site(site.id + 1)

leftsite(tn::Chain, site::Site) = leftsite(boundary(tn), tn, site)
leftsite(::Open, tn::Chain, site::Site) = Site(site.id - 1)
leftsite(::Union{Open, Periodic}, tn::Chain, site::Site) = Site(site.id - 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we canonize a periodic MPS? If so, doing a ::Union{Open,Periodic} is probably not the best solution.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can, but we need to include the proper logic on the canonize function. Nevertheless, we can always do leftsite and rightsite of Periodic MPS.

However, maybe it would be a good idea to put here a check so we don't go to the left of the Site(1), in the case of Open MPS.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to do 2 separa methods:

  • One, the leftsite(::Open) as it is now
  • The other leftsite(::Periodic) that wraps the i with the period

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, what do you think?

Copy link
Member

@mofeing mofeing Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better, but we should check whether site is in range for the Periodic case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary, right? In Periodic we can assume Site(4) is effectively Site(1), for a periodic cell of 3 sites.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do that, but we have to stick to it then.


leftindex(tn::Chain, site::Site) = leftindex(boundary(tn), tn, site)
leftindex(::Periodic, tn::Chain, site::Site) = (select(tn, :tensor, site)|>inds)[end-1]
function leftindex(::Open, tn::Chain, site::Site)
function leftindex(::Union{Open, Periodic}, tn::Chain, site::Site)
if site == site"1"
nothing
else
Expand All @@ -129,8 +128,7 @@ function leftindex(::Open, tn::Chain, site::Site)
end

rightindex(tn::Chain, site::Site) = rightindex(boundary(tn), tn, site)
rightindex(::Periodic, tn::Chain, site::Site) = (select(tn, :tensor, site)|>inds)[end]
function rightindex(::Open, tn::Chain, site::Site)
function rightindex(::Union{Open, Periodic}, tn::Chain, site::Site)
if site == Site(nsites(tn)) # TODO review
nothing
else
Expand Down
Loading