def test_get_neighbor_vectors(): # chain latt = Lattice.chain() latt.add_atom() latt.add_connections(2) # Nearest neighbors expected = np.array([[1], [-1]]) for idx in latt.get_neighbor_vectors(alpha=0, distidx=0): assert any((expected == idx).all(axis=1)) # Next nearest neighbors expected = np.array([[-2], [2]]) for idx in latt.get_neighbor_vectors(alpha=0, distidx=1): assert any((expected == idx).all(axis=1)) # square latt = Lattice.square() latt.add_atom() latt.add_connections(2) # Nearest neighbors expected = np.array([[1, 0], [0, -1], [0, 1], [-1, 0]]) for idx in latt.get_neighbor_vectors(alpha=0, distidx=0): assert any((expected == idx).all(axis=1)) # Next nearest neighbors expected = np.array([[1, -1], [-1, -1], [-1, 1], [1, 1]]) for idx in latt.get_neighbor_vectors(alpha=0, distidx=1): assert any((expected == idx).all(axis=1))
SiteOccupiedError, NoAtomsError, NoConnectionsError, NotAnalyzedError, ) from lattpy import Lattice, Circle, Atom import lattpy as lp settings.load_profile("lattpy") atom = Atom() PI = np.pi TWOPI = 2 * np.pi chain = Lattice.chain(a=1.0) rchain = Lattice(TWOPI) square = Lattice.square(a=1.0) rsquare = Lattice(TWOPI * np.eye(2)) rect = Lattice.rectangular(a1=2.0, a2=1.0) rrect = Lattice(PI * np.array([[1, 0], [0, 2]])) hexagonal = Lattice.hexagonal(a=1) rhexagonal = Lattice( np.array([[+2.0943951, +3.62759873], [+2.0943951, -3.62759873]])) sc = Lattice.sc(a=1.0) rsc = Lattice(TWOPI * np.eye(3)) fcc = Lattice.fcc(a=1.0)