diff --git a/tests/python/operators/fermi_hubbard_test.py b/tests/python/operators/fermi_hubbard_test.py index 9b6cb1805..e9c395969 100644 --- a/tests/python/operators/fermi_hubbard_test.py +++ b/tests/python/operators/fermi_hubbard_test.py @@ -23,472 +23,460 @@ def test_fermi_hubbard_1d(): """Test terms of the one-dimensional Fermi-Hubbard model Hamiltonian.""" # open boundary conditions - op = fermi_hubbard_1d( - norb=4, - tunneling=1, - interaction=2, - chemical_potential=3, - nearest_neighbor_interaction=4, - ) - np.testing.assert_equal( - dict(op), - { - (cre_a(0), des_a(1)): -1, - (cre_b(0), des_b(1)): -1, - (cre_a(1), des_a(0)): -1, - (cre_b(1), des_b(0)): -1, - (cre_a(1), des_a(2)): -1, - (cre_b(1), des_b(2)): -1, - (cre_a(2), des_a(1)): -1, - (cre_b(2), des_b(1)): -1, - (cre_a(2), des_a(3)): -1, - (cre_b(2), des_b(3)): -1, - (cre_a(3), des_a(2)): -1, - (cre_b(3), des_b(2)): -1, - (cre_a(0), des_a(0), cre_b(0), des_b(0)): 2, - (cre_a(1), des_a(1), cre_b(1), des_b(1)): 2, - (cre_a(2), des_a(2), cre_b(2), des_b(2)): 2, - (cre_a(3), des_a(3), cre_b(3), des_b(3)): 2, - (cre_a(0), des_a(0)): -3, - (cre_b(0), des_b(0)): -3, - (cre_a(1), des_a(1)): -3, - (cre_b(1), des_b(1)): -3, - (cre_a(2), des_a(2)): -3, - (cre_b(2), des_b(2)): -3, - (cre_a(3), des_a(3)): -3, - (cre_b(3), des_b(3)): -3, - (cre_a(0), des_a(0), cre_a(1), des_a(1)): 4, - (cre_a(0), des_a(0), cre_b(1), des_b(1)): 4, - (cre_b(0), des_b(0), cre_a(1), des_a(1)): 4, - (cre_b(0), des_b(0), cre_b(1), des_b(1)): 4, - (cre_a(1), des_a(1), cre_a(2), des_a(2)): 4, - (cre_a(1), des_a(1), cre_b(2), des_b(2)): 4, - (cre_b(1), des_b(1), cre_a(2), des_a(2)): 4, - (cre_b(1), des_b(1), cre_b(2), des_b(2)): 4, - (cre_a(2), des_a(2), cre_a(3), des_a(3)): 4, - (cre_a(2), des_a(2), cre_b(3), des_b(3)): 4, - (cre_b(2), des_b(2), cre_a(3), des_a(3)): 4, - (cre_b(2), des_b(2), cre_b(3), des_b(3)): 4, - }, - ) + assert dict( + fermi_hubbard_1d( + norb=4, + tunneling=1, + interaction=2, + chemical_potential=3, + nearest_neighbor_interaction=4, + ) + ) == { + (cre_a(0), des_a(1)): -1, + (cre_b(0), des_b(1)): -1, + (cre_a(1), des_a(0)): -1, + (cre_b(1), des_b(0)): -1, + (cre_a(1), des_a(2)): -1, + (cre_b(1), des_b(2)): -1, + (cre_a(2), des_a(1)): -1, + (cre_b(2), des_b(1)): -1, + (cre_a(2), des_a(3)): -1, + (cre_b(2), des_b(3)): -1, + (cre_a(3), des_a(2)): -1, + (cre_b(3), des_b(2)): -1, + (cre_a(0), des_a(0), cre_b(0), des_b(0)): 2, + (cre_a(1), des_a(1), cre_b(1), des_b(1)): 2, + (cre_a(2), des_a(2), cre_b(2), des_b(2)): 2, + (cre_a(3), des_a(3), cre_b(3), des_b(3)): 2, + (cre_a(0), des_a(0)): -3, + (cre_b(0), des_b(0)): -3, + (cre_a(1), des_a(1)): -3, + (cre_b(1), des_b(1)): -3, + (cre_a(2), des_a(2)): -3, + (cre_b(2), des_b(2)): -3, + (cre_a(3), des_a(3)): -3, + (cre_b(3), des_b(3)): -3, + (cre_a(0), des_a(0), cre_a(1), des_a(1)): 4, + (cre_a(0), des_a(0), cre_b(1), des_b(1)): 4, + (cre_b(0), des_b(0), cre_a(1), des_a(1)): 4, + (cre_b(0), des_b(0), cre_b(1), des_b(1)): 4, + (cre_a(1), des_a(1), cre_a(2), des_a(2)): 4, + (cre_a(1), des_a(1), cre_b(2), des_b(2)): 4, + (cre_b(1), des_b(1), cre_a(2), des_a(2)): 4, + (cre_b(1), des_b(1), cre_b(2), des_b(2)): 4, + (cre_a(2), des_a(2), cre_a(3), des_a(3)): 4, + (cre_a(2), des_a(2), cre_b(3), des_b(3)): 4, + (cre_b(2), des_b(2), cre_a(3), des_a(3)): 4, + (cre_b(2), des_b(2), cre_b(3), des_b(3)): 4, + } # periodic boundary conditions - op_periodic = fermi_hubbard_1d( - norb=4, - tunneling=1, - interaction=2, - chemical_potential=3, - nearest_neighbor_interaction=4, - periodic=True, - ) - np.testing.assert_equal( - dict(op_periodic), - { - (cre_a(0), des_a(1)): -1, - (cre_b(0), des_b(1)): -1, - (cre_a(1), des_a(0)): -1, - (cre_b(1), des_b(0)): -1, - (cre_a(1), des_a(2)): -1, - (cre_b(1), des_b(2)): -1, - (cre_a(2), des_a(1)): -1, - (cre_b(2), des_b(1)): -1, - (cre_a(2), des_a(3)): -1, - (cre_b(2), des_b(3)): -1, - (cre_a(3), des_a(2)): -1, - (cre_b(3), des_b(2)): -1, - (cre_a(3), des_a(0)): -1, - (cre_b(3), des_b(0)): -1, - (cre_a(0), des_a(3)): -1, - (cre_b(0), des_b(3)): -1, - (cre_a(0), des_a(0), cre_b(0), des_b(0)): 2, - (cre_a(1), des_a(1), cre_b(1), des_b(1)): 2, - (cre_a(2), des_a(2), cre_b(2), des_b(2)): 2, - (cre_a(3), des_a(3), cre_b(3), des_b(3)): 2, - (cre_a(0), des_a(0)): -3, - (cre_b(0), des_b(0)): -3, - (cre_a(1), des_a(1)): -3, - (cre_b(1), des_b(1)): -3, - (cre_a(2), des_a(2)): -3, - (cre_b(2), des_b(2)): -3, - (cre_a(3), des_a(3)): -3, - (cre_b(3), des_b(3)): -3, - (cre_a(0), des_a(0), cre_a(1), des_a(1)): 4, - (cre_a(0), des_a(0), cre_b(1), des_b(1)): 4, - (cre_b(0), des_b(0), cre_a(1), des_a(1)): 4, - (cre_b(0), des_b(0), cre_b(1), des_b(1)): 4, - (cre_a(1), des_a(1), cre_a(2), des_a(2)): 4, - (cre_a(1), des_a(1), cre_b(2), des_b(2)): 4, - (cre_b(1), des_b(1), cre_a(2), des_a(2)): 4, - (cre_b(1), des_b(1), cre_b(2), des_b(2)): 4, - (cre_a(2), des_a(2), cre_a(3), des_a(3)): 4, - (cre_a(2), des_a(2), cre_b(3), des_b(3)): 4, - (cre_b(2), des_b(2), cre_a(3), des_a(3)): 4, - (cre_b(2), des_b(2), cre_b(3), des_b(3)): 4, - (cre_a(3), des_a(3), cre_a(0), des_a(0)): 4, - (cre_a(3), des_a(3), cre_b(0), des_b(0)): 4, - (cre_b(3), des_b(3), cre_a(0), des_a(0)): 4, - (cre_b(3), des_b(3), cre_b(0), des_b(0)): 4, - }, - ) + assert dict( + fermi_hubbard_1d( + norb=4, + tunneling=1, + interaction=2, + chemical_potential=3, + nearest_neighbor_interaction=4, + periodic=True, + ) + ) == { + (cre_a(0), des_a(1)): -1, + (cre_b(0), des_b(1)): -1, + (cre_a(1), des_a(0)): -1, + (cre_b(1), des_b(0)): -1, + (cre_a(1), des_a(2)): -1, + (cre_b(1), des_b(2)): -1, + (cre_a(2), des_a(1)): -1, + (cre_b(2), des_b(1)): -1, + (cre_a(2), des_a(3)): -1, + (cre_b(2), des_b(3)): -1, + (cre_a(3), des_a(2)): -1, + (cre_b(3), des_b(2)): -1, + (cre_a(3), des_a(0)): -1, + (cre_b(3), des_b(0)): -1, + (cre_a(0), des_a(3)): -1, + (cre_b(0), des_b(3)): -1, + (cre_a(0), des_a(0), cre_b(0), des_b(0)): 2, + (cre_a(1), des_a(1), cre_b(1), des_b(1)): 2, + (cre_a(2), des_a(2), cre_b(2), des_b(2)): 2, + (cre_a(3), des_a(3), cre_b(3), des_b(3)): 2, + (cre_a(0), des_a(0)): -3, + (cre_b(0), des_b(0)): -3, + (cre_a(1), des_a(1)): -3, + (cre_b(1), des_b(1)): -3, + (cre_a(2), des_a(2)): -3, + (cre_b(2), des_b(2)): -3, + (cre_a(3), des_a(3)): -3, + (cre_b(3), des_b(3)): -3, + (cre_a(0), des_a(0), cre_a(1), des_a(1)): 4, + (cre_a(0), des_a(0), cre_b(1), des_b(1)): 4, + (cre_b(0), des_b(0), cre_a(1), des_a(1)): 4, + (cre_b(0), des_b(0), cre_b(1), des_b(1)): 4, + (cre_a(1), des_a(1), cre_a(2), des_a(2)): 4, + (cre_a(1), des_a(1), cre_b(2), des_b(2)): 4, + (cre_b(1), des_b(1), cre_a(2), des_a(2)): 4, + (cre_b(1), des_b(1), cre_b(2), des_b(2)): 4, + (cre_a(2), des_a(2), cre_a(3), des_a(3)): 4, + (cre_a(2), des_a(2), cre_b(3), des_b(3)): 4, + (cre_b(2), des_b(2), cre_a(3), des_a(3)): 4, + (cre_b(2), des_b(2), cre_b(3), des_b(3)): 4, + (cre_a(3), des_a(3), cre_a(0), des_a(0)): 4, + (cre_a(3), des_a(3), cre_b(0), des_b(0)): 4, + (cre_b(3), des_b(3), cre_a(0), des_a(0)): 4, + (cre_b(3), des_b(3), cre_b(0), des_b(0)): 4, + } # periodic boundary conditions (edge case) - op_periodic_edge = fermi_hubbard_1d( - norb=2, - tunneling=1, - interaction=2, - chemical_potential=3, - nearest_neighbor_interaction=4, - periodic=True, - ) - np.testing.assert_equal( - dict(op_periodic_edge), - { - (cre_a(0), des_a(1)): -2, - (cre_b(0), des_b(1)): -2, - (cre_a(1), des_a(0)): -2, - (cre_b(1), des_b(0)): -2, - (cre_a(0), des_a(0), cre_b(0), des_b(0)): 2, - (cre_a(1), des_a(1), cre_b(1), des_b(1)): 2, - (cre_a(0), des_a(0)): -3, - (cre_b(0), des_b(0)): -3, - (cre_a(1), des_a(1)): -3, - (cre_b(1), des_b(1)): -3, - (cre_a(0), des_a(0), cre_a(1), des_a(1)): 4, - (cre_a(0), des_a(0), cre_b(1), des_b(1)): 4, - (cre_b(0), des_b(0), cre_a(1), des_a(1)): 4, - (cre_b(0), des_b(0), cre_b(1), des_b(1)): 4, - (cre_a(1), des_a(1), cre_a(0), des_a(0)): 4, - (cre_a(1), des_a(1), cre_b(0), des_b(0)): 4, - (cre_b(1), des_b(1), cre_a(0), des_a(0)): 4, - (cre_b(1), des_b(1), cre_b(0), des_b(0)): 4, - }, - ) + assert dict( + fermi_hubbard_1d( + norb=2, + tunneling=1, + interaction=2, + chemical_potential=3, + nearest_neighbor_interaction=4, + periodic=True, + ) + ) == { + (cre_a(0), des_a(1)): -2, + (cre_b(0), des_b(1)): -2, + (cre_a(1), des_a(0)): -2, + (cre_b(1), des_b(0)): -2, + (cre_a(0), des_a(0), cre_b(0), des_b(0)): 2, + (cre_a(1), des_a(1), cre_b(1), des_b(1)): 2, + (cre_a(0), des_a(0)): -3, + (cre_b(0), des_b(0)): -3, + (cre_a(1), des_a(1)): -3, + (cre_b(1), des_b(1)): -3, + (cre_a(0), des_a(0), cre_a(1), des_a(1)): 4, + (cre_a(0), des_a(0), cre_b(1), des_b(1)): 4, + (cre_b(0), des_b(0), cre_a(1), des_a(1)): 4, + (cre_b(0), des_b(0), cre_b(1), des_b(1)): 4, + (cre_a(1), des_a(1), cre_a(0), des_a(0)): 4, + (cre_a(1), des_a(1), cre_b(0), des_b(0)): 4, + (cre_b(1), des_b(1), cre_a(0), des_a(0)): 4, + (cre_b(1), des_b(1), cre_b(0), des_b(0)): 4, + } def test_fermi_hubbard_2d(): """Test terms of the two-dimensional Fermi-Hubbard model Hamiltonian.""" # open boundary conditions - op = fermi_hubbard_2d( - norb_x=2, - norb_y=2, - tunneling=1, - interaction=2, - chemical_potential=3, - nearest_neighbor_interaction=4, - ) - np.testing.assert_equal( - dict(op), - { - (cre_a(0), des_a(1)): -1, - (cre_b(0), des_b(1)): -1, - (cre_a(1), des_a(0)): -1, - (cre_b(1), des_b(0)): -1, - (cre_a(0), des_a(2)): -1, - (cre_b(0), des_b(2)): -1, - (cre_a(2), des_a(0)): -1, - (cre_b(2), des_b(0)): -1, - (cre_a(2), des_a(3)): -1, - (cre_b(2), des_b(3)): -1, - (cre_a(3), des_a(2)): -1, - (cre_b(3), des_b(2)): -1, - (cre_a(1), des_a(3)): -1, - (cre_b(1), des_b(3)): -1, - (cre_a(3), des_a(1)): -1, - (cre_b(3), des_b(1)): -1, - (cre_a(0), des_a(0), cre_b(0), des_b(0)): 2, - (cre_a(1), des_a(1), cre_b(1), des_b(1)): 2, - (cre_a(2), des_a(2), cre_b(2), des_b(2)): 2, - (cre_a(3), des_a(3), cre_b(3), des_b(3)): 2, - (cre_a(0), des_a(0)): -3, - (cre_b(0), des_b(0)): -3, - (cre_a(1), des_a(1)): -3, - (cre_b(1), des_b(1)): -3, - (cre_a(2), des_a(2)): -3, - (cre_b(2), des_b(2)): -3, - (cre_a(3), des_a(3)): -3, - (cre_b(3), des_b(3)): -3, - (cre_a(0), des_a(0), cre_a(1), des_a(1)): 4, - (cre_a(0), des_a(0), cre_b(1), des_b(1)): 4, - (cre_b(0), des_b(0), cre_a(1), des_a(1)): 4, - (cre_b(0), des_b(0), cre_b(1), des_b(1)): 4, - (cre_a(0), des_a(0), cre_a(2), des_a(2)): 4, - (cre_a(0), des_a(0), cre_b(2), des_b(2)): 4, - (cre_b(0), des_b(0), cre_a(2), des_a(2)): 4, - (cre_b(0), des_b(0), cre_b(2), des_b(2)): 4, - (cre_a(2), des_a(2), cre_a(3), des_a(3)): 4, - (cre_a(2), des_a(2), cre_b(3), des_b(3)): 4, - (cre_b(2), des_b(2), cre_a(3), des_a(3)): 4, - (cre_b(2), des_b(2), cre_b(3), des_b(3)): 4, - (cre_a(1), des_a(1), cre_a(3), des_a(3)): 4, - (cre_a(1), des_a(1), cre_b(3), des_b(3)): 4, - (cre_b(1), des_b(1), cre_a(3), des_a(3)): 4, - (cre_b(1), des_b(1), cre_b(3), des_b(3)): 4, - }, - ) + assert dict( + fermi_hubbard_2d( + norb_x=2, + norb_y=2, + tunneling=1, + interaction=2, + chemical_potential=3, + nearest_neighbor_interaction=4, + ) + ) == { + (cre_a(0), des_a(1)): -1, + (cre_b(0), des_b(1)): -1, + (cre_a(1), des_a(0)): -1, + (cre_b(1), des_b(0)): -1, + (cre_a(0), des_a(2)): -1, + (cre_b(0), des_b(2)): -1, + (cre_a(2), des_a(0)): -1, + (cre_b(2), des_b(0)): -1, + (cre_a(2), des_a(3)): -1, + (cre_b(2), des_b(3)): -1, + (cre_a(3), des_a(2)): -1, + (cre_b(3), des_b(2)): -1, + (cre_a(1), des_a(3)): -1, + (cre_b(1), des_b(3)): -1, + (cre_a(3), des_a(1)): -1, + (cre_b(3), des_b(1)): -1, + (cre_a(0), des_a(0), cre_b(0), des_b(0)): 2, + (cre_a(1), des_a(1), cre_b(1), des_b(1)): 2, + (cre_a(2), des_a(2), cre_b(2), des_b(2)): 2, + (cre_a(3), des_a(3), cre_b(3), des_b(3)): 2, + (cre_a(0), des_a(0)): -3, + (cre_b(0), des_b(0)): -3, + (cre_a(1), des_a(1)): -3, + (cre_b(1), des_b(1)): -3, + (cre_a(2), des_a(2)): -3, + (cre_b(2), des_b(2)): -3, + (cre_a(3), des_a(3)): -3, + (cre_b(3), des_b(3)): -3, + (cre_a(0), des_a(0), cre_a(1), des_a(1)): 4, + (cre_a(0), des_a(0), cre_b(1), des_b(1)): 4, + (cre_b(0), des_b(0), cre_a(1), des_a(1)): 4, + (cre_b(0), des_b(0), cre_b(1), des_b(1)): 4, + (cre_a(0), des_a(0), cre_a(2), des_a(2)): 4, + (cre_a(0), des_a(0), cre_b(2), des_b(2)): 4, + (cre_b(0), des_b(0), cre_a(2), des_a(2)): 4, + (cre_b(0), des_b(0), cre_b(2), des_b(2)): 4, + (cre_a(2), des_a(2), cre_a(3), des_a(3)): 4, + (cre_a(2), des_a(2), cre_b(3), des_b(3)): 4, + (cre_b(2), des_b(2), cre_a(3), des_a(3)): 4, + (cre_b(2), des_b(2), cre_b(3), des_b(3)): 4, + (cre_a(1), des_a(1), cre_a(3), des_a(3)): 4, + (cre_a(1), des_a(1), cre_b(3), des_b(3)): 4, + (cre_b(1), des_b(1), cre_a(3), des_a(3)): 4, + (cre_b(1), des_b(1), cre_b(3), des_b(3)): 4, + } # periodic boundary conditions - op_periodic = fermi_hubbard_2d( - norb_x=3, - norb_y=3, - tunneling=1, - interaction=2, - chemical_potential=3, - nearest_neighbor_interaction=4, - periodic=True, - ) - np.testing.assert_equal( - dict(op_periodic), - { - (cre_a(0), des_a(1)): -1, - (cre_b(0), des_b(1)): -1, - (cre_a(1), des_a(0)): -1, - (cre_b(1), des_b(0)): -1, - (cre_a(0), des_a(3)): -1, - (cre_b(0), des_b(3)): -1, - (cre_a(3), des_a(0)): -1, - (cre_b(3), des_b(0)): -1, - (cre_a(3), des_a(4)): -1, - (cre_b(3), des_b(4)): -1, - (cre_a(4), des_a(3)): -1, - (cre_b(4), des_b(3)): -1, - (cre_a(3), des_a(6)): -1, - (cre_b(3), des_b(6)): -1, - (cre_a(6), des_a(3)): -1, - (cre_b(6), des_b(3)): -1, - (cre_a(6), des_a(7)): -1, - (cre_b(6), des_b(7)): -1, - (cre_a(7), des_a(6)): -1, - (cre_b(7), des_b(6)): -1, - (cre_a(6), des_a(0)): -1, - (cre_b(6), des_b(0)): -1, - (cre_a(0), des_a(6)): -1, - (cre_b(0), des_b(6)): -1, - (cre_a(1), des_a(2)): -1, - (cre_b(1), des_b(2)): -1, - (cre_a(2), des_a(1)): -1, - (cre_b(2), des_b(1)): -1, - (cre_a(1), des_a(4)): -1, - (cre_b(1), des_b(4)): -1, - (cre_a(4), des_a(1)): -1, - (cre_b(4), des_b(1)): -1, - (cre_a(4), des_a(5)): -1, - (cre_b(4), des_b(5)): -1, - (cre_a(5), des_a(4)): -1, - (cre_b(5), des_b(4)): -1, - (cre_a(4), des_a(7)): -1, - (cre_b(4), des_b(7)): -1, - (cre_a(7), des_a(4)): -1, - (cre_b(7), des_b(4)): -1, - (cre_a(7), des_a(8)): -1, - (cre_b(7), des_b(8)): -1, - (cre_a(8), des_a(7)): -1, - (cre_b(8), des_b(7)): -1, - (cre_a(7), des_a(1)): -1, - (cre_b(7), des_b(1)): -1, - (cre_a(1), des_a(7)): -1, - (cre_b(1), des_b(7)): -1, - (cre_a(2), des_a(0)): -1, - (cre_b(2), des_b(0)): -1, - (cre_a(0), des_a(2)): -1, - (cre_b(0), des_b(2)): -1, - (cre_a(2), des_a(5)): -1, - (cre_b(2), des_b(5)): -1, - (cre_a(5), des_a(2)): -1, - (cre_b(5), des_b(2)): -1, - (cre_a(5), des_a(3)): -1, - (cre_b(5), des_b(3)): -1, - (cre_a(3), des_a(5)): -1, - (cre_b(3), des_b(5)): -1, - (cre_a(5), des_a(8)): -1, - (cre_b(5), des_b(8)): -1, - (cre_a(8), des_a(5)): -1, - (cre_b(8), des_b(5)): -1, - (cre_a(8), des_a(6)): -1, - (cre_b(8), des_b(6)): -1, - (cre_a(6), des_a(8)): -1, - (cre_b(6), des_b(8)): -1, - (cre_a(8), des_a(2)): -1, - (cre_b(8), des_b(2)): -1, - (cre_a(2), des_a(8)): -1, - (cre_b(2), des_b(8)): -1, - (cre_a(0), des_a(0), cre_b(0), des_b(0)): 2, - (cre_a(1), des_a(1), cre_b(1), des_b(1)): 2, - (cre_a(2), des_a(2), cre_b(2), des_b(2)): 2, - (cre_a(3), des_a(3), cre_b(3), des_b(3)): 2, - (cre_a(4), des_a(4), cre_b(4), des_b(4)): 2, - (cre_a(5), des_a(5), cre_b(5), des_b(5)): 2, - (cre_a(6), des_a(6), cre_b(6), des_b(6)): 2, - (cre_a(7), des_a(7), cre_b(7), des_b(7)): 2, - (cre_a(8), des_a(8), cre_b(8), des_b(8)): 2, - (cre_a(0), des_a(0)): -3, - (cre_b(0), des_b(0)): -3, - (cre_a(1), des_a(1)): -3, - (cre_b(1), des_b(1)): -3, - (cre_a(2), des_a(2)): -3, - (cre_b(2), des_b(2)): -3, - (cre_a(3), des_a(3)): -3, - (cre_b(3), des_b(3)): -3, - (cre_a(4), des_a(4)): -3, - (cre_b(4), des_b(4)): -3, - (cre_a(5), des_a(5)): -3, - (cre_b(5), des_b(5)): -3, - (cre_a(6), des_a(6)): -3, - (cre_b(6), des_b(6)): -3, - (cre_a(7), des_a(7)): -3, - (cre_b(7), des_b(7)): -3, - (cre_a(8), des_a(8)): -3, - (cre_b(8), des_b(8)): -3, - (cre_a(0), des_a(0), cre_a(1), des_a(1)): 4, - (cre_a(0), des_a(0), cre_b(1), des_b(1)): 4, - (cre_b(0), des_b(0), cre_a(1), des_a(1)): 4, - (cre_b(0), des_b(0), cre_b(1), des_b(1)): 4, - (cre_a(0), des_a(0), cre_a(3), des_a(3)): 4, - (cre_a(0), des_a(0), cre_b(3), des_b(3)): 4, - (cre_b(0), des_b(0), cre_a(3), des_a(3)): 4, - (cre_b(0), des_b(0), cre_b(3), des_b(3)): 4, - (cre_a(3), des_a(3), cre_a(4), des_a(4)): 4, - (cre_a(3), des_a(3), cre_b(4), des_b(4)): 4, - (cre_b(3), des_b(3), cre_a(4), des_a(4)): 4, - (cre_b(3), des_b(3), cre_b(4), des_b(4)): 4, - (cre_a(3), des_a(3), cre_a(6), des_a(6)): 4, - (cre_a(3), des_a(3), cre_b(6), des_b(6)): 4, - (cre_b(3), des_b(3), cre_a(6), des_a(6)): 4, - (cre_b(3), des_b(3), cre_b(6), des_b(6)): 4, - (cre_a(6), des_a(6), cre_a(7), des_a(7)): 4, - (cre_a(6), des_a(6), cre_b(7), des_b(7)): 4, - (cre_b(6), des_b(6), cre_a(7), des_a(7)): 4, - (cre_b(6), des_b(6), cre_b(7), des_b(7)): 4, - (cre_a(6), des_a(6), cre_a(0), des_a(0)): 4, - (cre_a(6), des_a(6), cre_b(0), des_b(0)): 4, - (cre_b(6), des_b(6), cre_a(0), des_a(0)): 4, - (cre_b(6), des_b(6), cre_b(0), des_b(0)): 4, - (cre_a(1), des_a(1), cre_a(2), des_a(2)): 4, - (cre_a(1), des_a(1), cre_b(2), des_b(2)): 4, - (cre_b(1), des_b(1), cre_a(2), des_a(2)): 4, - (cre_b(1), des_b(1), cre_b(2), des_b(2)): 4, - (cre_a(1), des_a(1), cre_a(4), des_a(4)): 4, - (cre_a(1), des_a(1), cre_b(4), des_b(4)): 4, - (cre_b(1), des_b(1), cre_a(4), des_a(4)): 4, - (cre_b(1), des_b(1), cre_b(4), des_b(4)): 4, - (cre_a(4), des_a(4), cre_a(5), des_a(5)): 4, - (cre_a(4), des_a(4), cre_b(5), des_b(5)): 4, - (cre_b(4), des_b(4), cre_a(5), des_a(5)): 4, - (cre_b(4), des_b(4), cre_b(5), des_b(5)): 4, - (cre_a(4), des_a(4), cre_a(7), des_a(7)): 4, - (cre_a(4), des_a(4), cre_b(7), des_b(7)): 4, - (cre_b(4), des_b(4), cre_a(7), des_a(7)): 4, - (cre_b(4), des_b(4), cre_b(7), des_b(7)): 4, - (cre_a(7), des_a(7), cre_a(8), des_a(8)): 4, - (cre_a(7), des_a(7), cre_b(8), des_b(8)): 4, - (cre_b(7), des_b(7), cre_a(8), des_a(8)): 4, - (cre_b(7), des_b(7), cre_b(8), des_b(8)): 4, - (cre_a(7), des_a(7), cre_a(1), des_a(1)): 4, - (cre_a(7), des_a(7), cre_b(1), des_b(1)): 4, - (cre_b(7), des_b(7), cre_a(1), des_a(1)): 4, - (cre_b(7), des_b(7), cre_b(1), des_b(1)): 4, - (cre_a(2), des_a(2), cre_a(0), des_a(0)): 4, - (cre_a(2), des_a(2), cre_b(0), des_b(0)): 4, - (cre_b(2), des_b(2), cre_a(0), des_a(0)): 4, - (cre_b(2), des_b(2), cre_b(0), des_b(0)): 4, - (cre_a(2), des_a(2), cre_a(5), des_a(5)): 4, - (cre_a(2), des_a(2), cre_b(5), des_b(5)): 4, - (cre_b(2), des_b(2), cre_a(5), des_a(5)): 4, - (cre_b(2), des_b(2), cre_b(5), des_b(5)): 4, - (cre_a(5), des_a(5), cre_a(3), des_a(3)): 4, - (cre_a(5), des_a(5), cre_b(3), des_b(3)): 4, - (cre_b(5), des_b(5), cre_a(3), des_a(3)): 4, - (cre_b(5), des_b(5), cre_b(3), des_b(3)): 4, - (cre_a(5), des_a(5), cre_a(8), des_a(8)): 4, - (cre_a(5), des_a(5), cre_b(8), des_b(8)): 4, - (cre_b(5), des_b(5), cre_a(8), des_a(8)): 4, - (cre_b(5), des_b(5), cre_b(8), des_b(8)): 4, - (cre_a(8), des_a(8), cre_a(6), des_a(6)): 4, - (cre_a(8), des_a(8), cre_b(6), des_b(6)): 4, - (cre_b(8), des_b(8), cre_a(6), des_a(6)): 4, - (cre_b(8), des_b(8), cre_b(6), des_b(6)): 4, - (cre_a(8), des_a(8), cre_a(2), des_a(2)): 4, - (cre_a(8), des_a(8), cre_b(2), des_b(2)): 4, - (cre_b(8), des_b(8), cre_a(2), des_a(2)): 4, - (cre_b(8), des_b(8), cre_b(2), des_b(2)): 4, - }, - ) + assert dict( + fermi_hubbard_2d( + norb_x=3, + norb_y=3, + tunneling=1, + interaction=2, + chemical_potential=3, + nearest_neighbor_interaction=4, + periodic=True, + ) + ) == { + (cre_a(0), des_a(1)): -1, + (cre_b(0), des_b(1)): -1, + (cre_a(1), des_a(0)): -1, + (cre_b(1), des_b(0)): -1, + (cre_a(0), des_a(3)): -1, + (cre_b(0), des_b(3)): -1, + (cre_a(3), des_a(0)): -1, + (cre_b(3), des_b(0)): -1, + (cre_a(3), des_a(4)): -1, + (cre_b(3), des_b(4)): -1, + (cre_a(4), des_a(3)): -1, + (cre_b(4), des_b(3)): -1, + (cre_a(3), des_a(6)): -1, + (cre_b(3), des_b(6)): -1, + (cre_a(6), des_a(3)): -1, + (cre_b(6), des_b(3)): -1, + (cre_a(6), des_a(7)): -1, + (cre_b(6), des_b(7)): -1, + (cre_a(7), des_a(6)): -1, + (cre_b(7), des_b(6)): -1, + (cre_a(6), des_a(0)): -1, + (cre_b(6), des_b(0)): -1, + (cre_a(0), des_a(6)): -1, + (cre_b(0), des_b(6)): -1, + (cre_a(1), des_a(2)): -1, + (cre_b(1), des_b(2)): -1, + (cre_a(2), des_a(1)): -1, + (cre_b(2), des_b(1)): -1, + (cre_a(1), des_a(4)): -1, + (cre_b(1), des_b(4)): -1, + (cre_a(4), des_a(1)): -1, + (cre_b(4), des_b(1)): -1, + (cre_a(4), des_a(5)): -1, + (cre_b(4), des_b(5)): -1, + (cre_a(5), des_a(4)): -1, + (cre_b(5), des_b(4)): -1, + (cre_a(4), des_a(7)): -1, + (cre_b(4), des_b(7)): -1, + (cre_a(7), des_a(4)): -1, + (cre_b(7), des_b(4)): -1, + (cre_a(7), des_a(8)): -1, + (cre_b(7), des_b(8)): -1, + (cre_a(8), des_a(7)): -1, + (cre_b(8), des_b(7)): -1, + (cre_a(7), des_a(1)): -1, + (cre_b(7), des_b(1)): -1, + (cre_a(1), des_a(7)): -1, + (cre_b(1), des_b(7)): -1, + (cre_a(2), des_a(0)): -1, + (cre_b(2), des_b(0)): -1, + (cre_a(0), des_a(2)): -1, + (cre_b(0), des_b(2)): -1, + (cre_a(2), des_a(5)): -1, + (cre_b(2), des_b(5)): -1, + (cre_a(5), des_a(2)): -1, + (cre_b(5), des_b(2)): -1, + (cre_a(5), des_a(3)): -1, + (cre_b(5), des_b(3)): -1, + (cre_a(3), des_a(5)): -1, + (cre_b(3), des_b(5)): -1, + (cre_a(5), des_a(8)): -1, + (cre_b(5), des_b(8)): -1, + (cre_a(8), des_a(5)): -1, + (cre_b(8), des_b(5)): -1, + (cre_a(8), des_a(6)): -1, + (cre_b(8), des_b(6)): -1, + (cre_a(6), des_a(8)): -1, + (cre_b(6), des_b(8)): -1, + (cre_a(8), des_a(2)): -1, + (cre_b(8), des_b(2)): -1, + (cre_a(2), des_a(8)): -1, + (cre_b(2), des_b(8)): -1, + (cre_a(0), des_a(0), cre_b(0), des_b(0)): 2, + (cre_a(1), des_a(1), cre_b(1), des_b(1)): 2, + (cre_a(2), des_a(2), cre_b(2), des_b(2)): 2, + (cre_a(3), des_a(3), cre_b(3), des_b(3)): 2, + (cre_a(4), des_a(4), cre_b(4), des_b(4)): 2, + (cre_a(5), des_a(5), cre_b(5), des_b(5)): 2, + (cre_a(6), des_a(6), cre_b(6), des_b(6)): 2, + (cre_a(7), des_a(7), cre_b(7), des_b(7)): 2, + (cre_a(8), des_a(8), cre_b(8), des_b(8)): 2, + (cre_a(0), des_a(0)): -3, + (cre_b(0), des_b(0)): -3, + (cre_a(1), des_a(1)): -3, + (cre_b(1), des_b(1)): -3, + (cre_a(2), des_a(2)): -3, + (cre_b(2), des_b(2)): -3, + (cre_a(3), des_a(3)): -3, + (cre_b(3), des_b(3)): -3, + (cre_a(4), des_a(4)): -3, + (cre_b(4), des_b(4)): -3, + (cre_a(5), des_a(5)): -3, + (cre_b(5), des_b(5)): -3, + (cre_a(6), des_a(6)): -3, + (cre_b(6), des_b(6)): -3, + (cre_a(7), des_a(7)): -3, + (cre_b(7), des_b(7)): -3, + (cre_a(8), des_a(8)): -3, + (cre_b(8), des_b(8)): -3, + (cre_a(0), des_a(0), cre_a(1), des_a(1)): 4, + (cre_a(0), des_a(0), cre_b(1), des_b(1)): 4, + (cre_b(0), des_b(0), cre_a(1), des_a(1)): 4, + (cre_b(0), des_b(0), cre_b(1), des_b(1)): 4, + (cre_a(0), des_a(0), cre_a(3), des_a(3)): 4, + (cre_a(0), des_a(0), cre_b(3), des_b(3)): 4, + (cre_b(0), des_b(0), cre_a(3), des_a(3)): 4, + (cre_b(0), des_b(0), cre_b(3), des_b(3)): 4, + (cre_a(3), des_a(3), cre_a(4), des_a(4)): 4, + (cre_a(3), des_a(3), cre_b(4), des_b(4)): 4, + (cre_b(3), des_b(3), cre_a(4), des_a(4)): 4, + (cre_b(3), des_b(3), cre_b(4), des_b(4)): 4, + (cre_a(3), des_a(3), cre_a(6), des_a(6)): 4, + (cre_a(3), des_a(3), cre_b(6), des_b(6)): 4, + (cre_b(3), des_b(3), cre_a(6), des_a(6)): 4, + (cre_b(3), des_b(3), cre_b(6), des_b(6)): 4, + (cre_a(6), des_a(6), cre_a(7), des_a(7)): 4, + (cre_a(6), des_a(6), cre_b(7), des_b(7)): 4, + (cre_b(6), des_b(6), cre_a(7), des_a(7)): 4, + (cre_b(6), des_b(6), cre_b(7), des_b(7)): 4, + (cre_a(6), des_a(6), cre_a(0), des_a(0)): 4, + (cre_a(6), des_a(6), cre_b(0), des_b(0)): 4, + (cre_b(6), des_b(6), cre_a(0), des_a(0)): 4, + (cre_b(6), des_b(6), cre_b(0), des_b(0)): 4, + (cre_a(1), des_a(1), cre_a(2), des_a(2)): 4, + (cre_a(1), des_a(1), cre_b(2), des_b(2)): 4, + (cre_b(1), des_b(1), cre_a(2), des_a(2)): 4, + (cre_b(1), des_b(1), cre_b(2), des_b(2)): 4, + (cre_a(1), des_a(1), cre_a(4), des_a(4)): 4, + (cre_a(1), des_a(1), cre_b(4), des_b(4)): 4, + (cre_b(1), des_b(1), cre_a(4), des_a(4)): 4, + (cre_b(1), des_b(1), cre_b(4), des_b(4)): 4, + (cre_a(4), des_a(4), cre_a(5), des_a(5)): 4, + (cre_a(4), des_a(4), cre_b(5), des_b(5)): 4, + (cre_b(4), des_b(4), cre_a(5), des_a(5)): 4, + (cre_b(4), des_b(4), cre_b(5), des_b(5)): 4, + (cre_a(4), des_a(4), cre_a(7), des_a(7)): 4, + (cre_a(4), des_a(4), cre_b(7), des_b(7)): 4, + (cre_b(4), des_b(4), cre_a(7), des_a(7)): 4, + (cre_b(4), des_b(4), cre_b(7), des_b(7)): 4, + (cre_a(7), des_a(7), cre_a(8), des_a(8)): 4, + (cre_a(7), des_a(7), cre_b(8), des_b(8)): 4, + (cre_b(7), des_b(7), cre_a(8), des_a(8)): 4, + (cre_b(7), des_b(7), cre_b(8), des_b(8)): 4, + (cre_a(7), des_a(7), cre_a(1), des_a(1)): 4, + (cre_a(7), des_a(7), cre_b(1), des_b(1)): 4, + (cre_b(7), des_b(7), cre_a(1), des_a(1)): 4, + (cre_b(7), des_b(7), cre_b(1), des_b(1)): 4, + (cre_a(2), des_a(2), cre_a(0), des_a(0)): 4, + (cre_a(2), des_a(2), cre_b(0), des_b(0)): 4, + (cre_b(2), des_b(2), cre_a(0), des_a(0)): 4, + (cre_b(2), des_b(2), cre_b(0), des_b(0)): 4, + (cre_a(2), des_a(2), cre_a(5), des_a(5)): 4, + (cre_a(2), des_a(2), cre_b(5), des_b(5)): 4, + (cre_b(2), des_b(2), cre_a(5), des_a(5)): 4, + (cre_b(2), des_b(2), cre_b(5), des_b(5)): 4, + (cre_a(5), des_a(5), cre_a(3), des_a(3)): 4, + (cre_a(5), des_a(5), cre_b(3), des_b(3)): 4, + (cre_b(5), des_b(5), cre_a(3), des_a(3)): 4, + (cre_b(5), des_b(5), cre_b(3), des_b(3)): 4, + (cre_a(5), des_a(5), cre_a(8), des_a(8)): 4, + (cre_a(5), des_a(5), cre_b(8), des_b(8)): 4, + (cre_b(5), des_b(5), cre_a(8), des_a(8)): 4, + (cre_b(5), des_b(5), cre_b(8), des_b(8)): 4, + (cre_a(8), des_a(8), cre_a(6), des_a(6)): 4, + (cre_a(8), des_a(8), cre_b(6), des_b(6)): 4, + (cre_b(8), des_b(8), cre_a(6), des_a(6)): 4, + (cre_b(8), des_b(8), cre_b(6), des_b(6)): 4, + (cre_a(8), des_a(8), cre_a(2), des_a(2)): 4, + (cre_a(8), des_a(8), cre_b(2), des_b(2)): 4, + (cre_b(8), des_b(8), cre_a(2), des_a(2)): 4, + (cre_b(8), des_b(8), cre_b(2), des_b(2)): 4, + } # periodic boundary conditions (edge case) - op_periodic_edge = fermi_hubbard_2d( - norb_x=2, - norb_y=2, - tunneling=1, - interaction=2, - chemical_potential=3, - nearest_neighbor_interaction=4, - periodic=True, - ) - np.testing.assert_equal( - dict(op_periodic_edge), - { - (cre_a(0), des_a(1)): -2, - (cre_b(0), des_b(1)): -2, - (cre_a(1), des_a(0)): -2, - (cre_b(1), des_b(0)): -2, - (cre_a(0), des_a(2)): -2, - (cre_b(0), des_b(2)): -2, - (cre_a(2), des_a(0)): -2, - (cre_b(2), des_b(0)): -2, - (cre_a(2), des_a(3)): -2, - (cre_b(2), des_b(3)): -2, - (cre_a(3), des_a(2)): -2, - (cre_b(3), des_b(2)): -2, - (cre_a(1), des_a(3)): -2, - (cre_b(1), des_b(3)): -2, - (cre_a(3), des_a(1)): -2, - (cre_b(3), des_b(1)): -2, - (cre_a(0), des_a(0), cre_b(0), des_b(0)): 2, - (cre_a(1), des_a(1), cre_b(1), des_b(1)): 2, - (cre_a(2), des_a(2), cre_b(2), des_b(2)): 2, - (cre_a(3), des_a(3), cre_b(3), des_b(3)): 2, - (cre_a(0), des_a(0)): -3, - (cre_b(0), des_b(0)): -3, - (cre_a(1), des_a(1)): -3, - (cre_b(1), des_b(1)): -3, - (cre_a(2), des_a(2)): -3, - (cre_b(2), des_b(2)): -3, - (cre_a(3), des_a(3)): -3, - (cre_b(3), des_b(3)): -3, - (cre_a(0), des_a(0), cre_a(1), des_a(1)): 4, - (cre_a(0), des_a(0), cre_b(1), des_b(1)): 4, - (cre_b(0), des_b(0), cre_a(1), des_a(1)): 4, - (cre_b(0), des_b(0), cre_b(1), des_b(1)): 4, - (cre_a(0), des_a(0), cre_a(2), des_a(2)): 4, - (cre_a(0), des_a(0), cre_b(2), des_b(2)): 4, - (cre_b(0), des_b(0), cre_a(2), des_a(2)): 4, - (cre_b(0), des_b(0), cre_b(2), des_b(2)): 4, - (cre_a(2), des_a(2), cre_a(3), des_a(3)): 4, - (cre_a(2), des_a(2), cre_b(3), des_b(3)): 4, - (cre_b(2), des_b(2), cre_a(3), des_a(3)): 4, - (cre_b(2), des_b(2), cre_b(3), des_b(3)): 4, - (cre_a(2), des_a(2), cre_a(0), des_a(0)): 4, - (cre_a(2), des_a(2), cre_b(0), des_b(0)): 4, - (cre_b(2), des_b(2), cre_a(0), des_a(0)): 4, - (cre_b(2), des_b(2), cre_b(0), des_b(0)): 4, - (cre_a(1), des_a(1), cre_a(0), des_a(0)): 4, - (cre_a(1), des_a(1), cre_b(0), des_b(0)): 4, - (cre_b(1), des_b(1), cre_a(0), des_a(0)): 4, - (cre_b(1), des_b(1), cre_b(0), des_b(0)): 4, - (cre_a(1), des_a(1), cre_a(3), des_a(3)): 4, - (cre_a(1), des_a(1), cre_b(3), des_b(3)): 4, - (cre_b(1), des_b(1), cre_a(3), des_a(3)): 4, - (cre_b(1), des_b(1), cre_b(3), des_b(3)): 4, - (cre_a(3), des_a(3), cre_a(2), des_a(2)): 4, - (cre_a(3), des_a(3), cre_b(2), des_b(2)): 4, - (cre_b(3), des_b(3), cre_a(2), des_a(2)): 4, - (cre_b(3), des_b(3), cre_b(2), des_b(2)): 4, - (cre_a(3), des_a(3), cre_a(1), des_a(1)): 4, - (cre_a(3), des_a(3), cre_b(1), des_b(1)): 4, - (cre_b(3), des_b(3), cre_a(1), des_a(1)): 4, - (cre_b(3), des_b(3), cre_b(1), des_b(1)): 4, - }, - ) + assert dict( + fermi_hubbard_2d( + norb_x=2, + norb_y=2, + tunneling=1, + interaction=2, + chemical_potential=3, + nearest_neighbor_interaction=4, + periodic=True, + ) + ) == { + (cre_a(0), des_a(1)): -2, + (cre_b(0), des_b(1)): -2, + (cre_a(1), des_a(0)): -2, + (cre_b(1), des_b(0)): -2, + (cre_a(0), des_a(2)): -2, + (cre_b(0), des_b(2)): -2, + (cre_a(2), des_a(0)): -2, + (cre_b(2), des_b(0)): -2, + (cre_a(2), des_a(3)): -2, + (cre_b(2), des_b(3)): -2, + (cre_a(3), des_a(2)): -2, + (cre_b(3), des_b(2)): -2, + (cre_a(1), des_a(3)): -2, + (cre_b(1), des_b(3)): -2, + (cre_a(3), des_a(1)): -2, + (cre_b(3), des_b(1)): -2, + (cre_a(0), des_a(0), cre_b(0), des_b(0)): 2, + (cre_a(1), des_a(1), cre_b(1), des_b(1)): 2, + (cre_a(2), des_a(2), cre_b(2), des_b(2)): 2, + (cre_a(3), des_a(3), cre_b(3), des_b(3)): 2, + (cre_a(0), des_a(0)): -3, + (cre_b(0), des_b(0)): -3, + (cre_a(1), des_a(1)): -3, + (cre_b(1), des_b(1)): -3, + (cre_a(2), des_a(2)): -3, + (cre_b(2), des_b(2)): -3, + (cre_a(3), des_a(3)): -3, + (cre_b(3), des_b(3)): -3, + (cre_a(0), des_a(0), cre_a(1), des_a(1)): 4, + (cre_a(0), des_a(0), cre_b(1), des_b(1)): 4, + (cre_b(0), des_b(0), cre_a(1), des_a(1)): 4, + (cre_b(0), des_b(0), cre_b(1), des_b(1)): 4, + (cre_a(0), des_a(0), cre_a(2), des_a(2)): 4, + (cre_a(0), des_a(0), cre_b(2), des_b(2)): 4, + (cre_b(0), des_b(0), cre_a(2), des_a(2)): 4, + (cre_b(0), des_b(0), cre_b(2), des_b(2)): 4, + (cre_a(2), des_a(2), cre_a(3), des_a(3)): 4, + (cre_a(2), des_a(2), cre_b(3), des_b(3)): 4, + (cre_b(2), des_b(2), cre_a(3), des_a(3)): 4, + (cre_b(2), des_b(2), cre_b(3), des_b(3)): 4, + (cre_a(2), des_a(2), cre_a(0), des_a(0)): 4, + (cre_a(2), des_a(2), cre_b(0), des_b(0)): 4, + (cre_b(2), des_b(2), cre_a(0), des_a(0)): 4, + (cre_b(2), des_b(2), cre_b(0), des_b(0)): 4, + (cre_a(1), des_a(1), cre_a(0), des_a(0)): 4, + (cre_a(1), des_a(1), cre_b(0), des_b(0)): 4, + (cre_b(1), des_b(1), cre_a(0), des_a(0)): 4, + (cre_b(1), des_b(1), cre_b(0), des_b(0)): 4, + (cre_a(1), des_a(1), cre_a(3), des_a(3)): 4, + (cre_a(1), des_a(1), cre_b(3), des_b(3)): 4, + (cre_b(1), des_b(1), cre_a(3), des_a(3)): 4, + (cre_b(1), des_b(1), cre_b(3), des_b(3)): 4, + (cre_a(3), des_a(3), cre_a(2), des_a(2)): 4, + (cre_a(3), des_a(3), cre_b(2), des_b(2)): 4, + (cre_b(3), des_b(3), cre_a(2), des_a(2)): 4, + (cre_b(3), des_b(3), cre_b(2), des_b(2)): 4, + (cre_a(3), des_a(3), cre_a(1), des_a(1)): 4, + (cre_a(3), des_a(3), cre_b(1), des_b(1)): 4, + (cre_b(3), des_b(3), cre_a(1), des_a(1)): 4, + (cre_b(3), des_b(3), cre_b(1), des_b(1)): 4, + } def test_non_interacting_fermi_hubbard_1d_eigenvalue():