Periodic boundary conditions fails for small models with d>1
dylanljones opened this issue · 0 comments
dylanljones commented
Describe the bug
Setting periodic boundary conditions for small lattices in higher dimensions fails due a broadcasting error and raises a ValueError
.
To Reproduce
Steps to reproduce the behavior:
import lattpy as lp
latt = lp.finite_hypercubic((2, 2), periodic=True)
The resulting error is:
Traceback (most recent call last):
File "D:\Dropbox\Dev\Physics\lattpy\issue.py", line 16, in <module>
main()
File "D:\Dropbox\Dev\Physics\lattpy\issue.py", line 12, in main
latt = lp.finite_hypercubic((2, 2), periodic=True)
File "D:\Dropbox\Dev\Physics\lattpy\lattpy\__init__.py", line 451, in finite_hypercubic
latt.build(s, primitive=primitive, periodic=periodic)
File "D:\Dropbox\Dev\Physics\lattpy\lattpy\lattice.py", line 431, in build
self.set_periodic(periodic, primitive)
File "D:\Dropbox\Dev\Physics\lattpy\lattpy\lattice.py", line 620, in set_periodic
self.data.set_periodic(pidx, pdists, pnvecs, paxs)
File "D:\Dropbox\Dev\Physics\lattpy\lattpy\data.py", line 467, in set_periodic
self.neighbors[i, i0:i1] = pidx
ValueError: could not broadcast input array from shape (2,) into shape (1,)
Expected behavior
Set periodic boundary conditions if possible. In the example above this is not necessary since the sites are already neighbors.
Environment
- lattpy version: 0.7.4
- OS and Python version: All