Skip to content
Snippets Groups Projects
Commit 7036afd3 authored by Christoph Groth's avatar Christoph Groth
Browse files

make neighbors() work for lattices that live in higher-dimensional space

Additionally, make sure to test the LLL code accordingly.
parent f57b8612
No related branches found
No related tags found
No related merge requests found
......@@ -298,7 +298,7 @@ class Polyatomic:
Site = builder.Site
sls = self.sublattices
shortest_hopping = sls[0].n_closest(
Site(sls[0], ([0] * sls[0].dim)).pos, 2)[-1]
sls[0].pos(([0] * sls[0].lattice_dim)), 2)[-1]
eps *= np.linalg.norm(self.vec(shortest_hopping))
nvec = len(self._prim_vecs)
sublat_pairs = [(i, j) for (i, j) in product(sls, sls)
......
......@@ -24,10 +24,11 @@ def test_lll():
def test_cvp():
rng = ensure_rng(0)
for i in range(10):
mat = rng.randn(4, 4)
mat = lll.lll(mat)[0]
for j in range(4):
point = 50 * rng.randn(4)
assert np.array_equal(lll.cvp(point, mat, 10)[:3],
lll.cvp(point, mat, 3))
for i in range(1, 5):
for j in range(i, 5):
mat = rng.randn(i, j)
mat = lll.lll(mat)[0]
for k in range(4):
point = 50 * rng.randn(j)
assert np.array_equal(lll.cvp(point, mat, 10)[:3],
lll.cvp(point, mat, 3))
......@@ -46,7 +46,7 @@ def test_neighbors():
lat = lattice.honeycomb(1e-10)
num_nth_nearest = [len(lat.neighbors(n)) for n in range(5)]
assert num_nth_nearest == [2, 3, 6, 3, 6]
lat = lattice.square(1e8)
lat = lattice.general([(0, 1e8, 0, 0), (0, 0, 1e8, 0)])
num_nth_nearest = [len(lat.neighbors(n)) for n in range(5)]
assert num_nth_nearest == [1, 2, 2, 2, 4]
lat = lattice.chain(1e-10)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment