def test_hubbard_square_lattice_2x2(): for periodic in (True, False): lattice = HubbardSquareLattice(2, 2, periodic=periodic) assert lattice.n_sites == 4 assert len(tuple(lattice.neighbors_iter(False))) == 4 assert len(tuple(lattice.neighbors_iter())) == 8 assert len(tuple(lattice.diagonal_neighbors_iter(False))) == 2 assert len(tuple(lattice.diagonal_neighbors_iter())) == 4
def test_hubbard_square_lattice_1xd(d): for shape, periodic in itertools.product(((1, d), (d, 1)), (True, False)): lattice = HubbardSquareLattice(*shape, periodic=periodic) assert lattice.n_sites == d assert (len(tuple(lattice.neighbors_iter())) == 2 * len(tuple(lattice.neighbors_iter(False))) == 2 * (d - (not periodic))) assert (len(tuple(lattice.diagonal_neighbors_iter())) == len( tuple(lattice.diagonal_neighbors_iter(False))) == 0)
def test_hubbard_square_lattice_2xd(d): for shape, periodic in itertools.product(((2, d), (d, 2)), (True, False)): lattice = HubbardSquareLattice(*shape, periodic=periodic) assert lattice.n_sites == 2 * d n_neighbor_pairs = 2 * (2 * (d - (not periodic)) + d) assert (len(tuple(lattice.neighbors_iter())) == 2 * len(tuple(lattice.neighbors_iter(False))) == n_neighbor_pairs) n_diagonal_neighbor_pairs = 4 * (d - (not periodic)) assert (len(tuple(lattice.diagonal_neighbors_iter())) == 2 * len(tuple(lattice.diagonal_neighbors_iter(False))) == n_diagonal_neighbor_pairs)
def test_hubbard_square_lattice_neighbors(x, y): for periodic in (True, False): lattice = HubbardSquareLattice(x, y, periodic=periodic) n_horizontal_neighbors = 2 * y * (x - (not periodic)) assert (len(tuple(lattice.horizontal_neighbors_iter())) == n_horizontal_neighbors) n_vertical_neighbors = 2 * x * (y - (not periodic)) assert (len(tuple(lattice.vertical_neighbors_iter())) == n_vertical_neighbors) n_diagonal_neighbors = 4 * (x - (not periodic)) * (y - (not periodic)) assert (len(tuple(lattice.diagonal_neighbors_iter())) == n_diagonal_neighbors)