Duplicate edges and self-loops in `Lattice` with PBC
Created by: femtobit
The Lattice
class and, by consequence, the new Grid
implementation, adds self-loops and duplicate edges when PBC are enabled:
Consider the following cases:
>>> print(Grid([1]).edges())
[(0, 0)]
>>> print(Grid([2, 1]).edges())
[(0, 0), (0, 1), (0, 1), (1, 1)]
>>> print(Grid([3, 2]).edges())
[(0, 2), (0, 4), (0, 1), (0, 1), (1, 3), (1, 5), (2, 3), (2, 3), (2, 4), (3, 5), (4, 5), (4, 5)]
While one can argue that the first two cases are ill-formed and should just throw and error, the third case does make sense if not for the fact that additional periodic edges are added along the short direction.
Since PBC along that direction do not make sense, but OTOH it would be tedious to require users to manually specify pbc=[True, False]
in such as case in my opinion, I think this should just default to assuming pbc=False
along directions of extent <= 2
(this would also address the first two problems).
I can make a PR for this, if everyone agrees this is the correct solution.