Alphaharrius / Zipper.jl

Implementation of Zipper Entanglement Renormalization on Julia platform.
GNU General Public License v3.0
1 stars 0 forks source link

Equality of `Offset` in different `RealSpace` basis is not well defined. #19

Closed Alphaharrius closed 8 months ago

Alphaharrius commented 8 months ago

Current definition of (==)(::Offset, ::Offset) is defined as comparing only their rpos, which the implementation of rpos of Offset is first transforming it into Euclidean (identity) basis then performs the rationalization. This method allows Offset in different RealSpace basis with the same location information in Euclidean basis to hash to same value and equates, which makes location comparison easier and less technical.

Yet if we would like to include @memoize for Offset and Mode generation which attempt to reduce memory strain during runtime, it would introduce issues since it will make some Offset or Mode degenerates when reusing the memoized result.

Suggested fix (Either one)

  1. Change the behavior of (==)(::Offset, ::Offset) such that it also checks the equality of the underlying RealSpace basis, this will allows Dict to store distinct Offset and Mode even if they are informationally the same.
  2. Change the behavior of hash(::Offset) such that it also includes the hash of the underlying RealSpace basis, the benefits is the same as 1 but also preserves the convenience of == over different RealSpace basis, yet this will break the rule of hash which hash objects to the same value if they equals.
Alphaharrius commented 8 months ago

Applied fix following suggestion 1, all test cases passed.

Alphaharrius commented 8 months ago

The current full renormalization process for 192x192 Chern insulator requires 7.98GiB of RAM for the Julia environment on MacBook Pro M3 Max 14-core model; after applying @memoize on Mode it becomes 7.85GiB.

Alphaharrius commented 8 months ago

Although the fix has been applied, yet adding @memoize to the constructors of Point and Mode in hopes of reducing memory usage failed, so those changes have been reverted.