Repository: qiskit-community/ffsim (python)

Issue:
In 2-D Fermi-Hubbard model, support specifying periodic boundary conditions for each dimension separately
Currently there is a single argument `periodic`. We should also support using arguments `periodic_x` and `periodic_y` instead.

Pull request description:
add periodic_x and periodic_y to fermi-hubbard
fixes #314 

Patch:
diff --git a/python/ffsim/operators/fermi_hubbard.py b/python/ffsim/operators/fermi_hubbard.py
index be004925..df1bc6e6 100644
--- a/python/ffsim/operators/fermi_hubbard.py
+++ b/python/ffsim/operators/fermi_hubbard.py
@@ -109,6 +109,8 @@ def fermi_hubbard_2d(
     chemical_potential: float = 0,
     nearest_neighbor_interaction: float = 0,
     periodic: bool = False,
+    periodic_x: bool = False,
+    periodic_y: bool = False,
 ) -> FermionOperator:
     r"""Two-dimensional Fermi-Hubbard model Hamiltonian on a square lattice.
 
@@ -143,7 +145,10 @@ def fermi_hubbard_2d(
         chemical_potential: The chemical potential :math:`\mu`.
         nearest_neighbor_interaction: The nearest-neighbor interaction strength
             :math:`V`.
-        periodic: Whether to use periodic boundary conditions.
+        periodic: Whether to use periodic boundary conditions in all dimensions.
+            This argument overrides the `periodic_x` and `periodic_y` arguments.
+        periodic_x: Whether to use periodic boundary conditions in the X dimension.
+        periodic_y: Whether to use periodic boundary conditions in the Y dimension.
 
     Returns:
         The two-dimensional Fermi-Hubbard model Hamiltonian.
@@ -163,18 +168,18 @@ def fermi_hubbard_2d(
         orb_up = norb_x * y_up + x
 
         if tunneling:
-            if x != norb_x - 1 or periodic:
+            if x != norb_x - 1 or periodic or periodic_x:
                 coeffs[cre_a(orb), des_a(orb_right)] -= tunneling
                 coeffs[cre_a(orb_right), des_a(orb)] -= tunneling
                 coeffs[cre_b(orb), des_b(orb_right)] -= tunneling
                 coeffs[cre_b(orb_right), des_b(orb)] -= tunneling
-            if y != norb_y - 1 or periodic:
+            if y != norb_y - 1 or periodic or periodic_y:
                 coeffs[cre_a(orb), des_a(orb_up)] -= tunneling
                 coeffs[cre_a(orb_up), des_a(orb)] -= tunneling
                 coeffs[cre_b(orb), des_b(orb_up)] -= tunneling
                 coeffs[cre_b(orb_up), des_b(orb)] -= tunneling
         if nearest_neighbor_interaction:
-            if x != norb_x - 1 or periodic:
+            if x != norb_x - 1 or periodic or periodic_x:
                 coeffs[cre_a(orb), des_a(orb), cre_a(orb_right), des_a(orb_right)] += (
                     nearest_neighbor_interaction
                 )
@@ -187,7 +192,7 @@ def fermi_hubbard_2d(
                 coeffs[cre_b(orb), des_b(orb), cre_b(orb_right), des_b(orb_right)] += (
                     nearest_neighbor_interaction
                 )
-            if y != norb_y - 1 or periodic:
+            if y != norb_y - 1 or periodic or periodic_y:
                 coeffs[cre_a(orb), des_a(orb), cre_a(orb_up), des_a(orb_up)] += (
                     nearest_neighbor_interaction
                 )


Test patch:
diff --git a/tests/python/operators/fermi_hubbard_test.py b/tests/python/operators/fermi_hubbard_test.py
index 6535e5ab..82fb1283 100644
--- a/tests/python/operators/fermi_hubbard_test.py
+++ b/tests/python/operators/fermi_hubbard_test.py
@@ -220,6 +220,208 @@ def test_fermi_hubbard_2d_open():
 
 def test_fermi_hubbard_2d_periodic():
     """Test 2-D Fermi-Hubbard model, periodic boundary conditions."""
+    assert (
+        dict(
+            fermi_hubbard_2d(
+                norb_x=3,
+                norb_y=3,
+                tunneling=1,
+                interaction=2,
+                chemical_potential=3,
+                nearest_neighbor_interaction=4,
+                periodic=True,
+            )
+        )
+        == dict(
+            fermi_hubbard_2d(
+                norb_x=3,
+                norb_y=3,
+                tunneling=1,
+                interaction=2,
+                chemical_potential=3,
+                nearest_neighbor_interaction=4,
+                periodic_x=True,
+                periodic_y=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,
+        }
+    )
+
+
+def test_fermi_hubbard_2d_x_periodic():
+    """Test 2-D Fermi-Hubbard model, x-periodic boundary conditions."""
     assert dict(
         fermi_hubbard_2d(
             norb_x=3,
@@ -228,7 +430,7 @@ def test_fermi_hubbard_2d_periodic():
             interaction=2,
             chemical_potential=3,
             nearest_neighbor_interaction=4,
-            periodic=True,
+            periodic_x=True,
         )
     ) == {
         (cre_a(0), des_a(1)): -1,
@@ -251,10 +453,6 @@ def test_fermi_hubbard_2d_periodic():
         (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,
@@ -275,10 +473,6 @@ def test_fermi_hubbard_2d_periodic():
         (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,
@@ -299,10 +493,6 @@ def test_fermi_hubbard_2d_periodic():
         (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,
@@ -350,10 +540,6 @@ def test_fermi_hubbard_2d_periodic():
         (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,
@@ -374,10 +560,6 @@ def test_fermi_hubbard_2d_periodic():
         (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,
@@ -398,6 +580,165 @@ def test_fermi_hubbard_2d_periodic():
         (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,
+    }
+
+
+def test_fermi_hubbard_2d_y_periodic():
+    """Test 2-D Fermi-Hubbard model, periodic boundary conditions."""
+    assert dict(
+        fermi_hubbard_2d(
+            norb_x=3,
+            norb_y=3,
+            tunneling=1,
+            interaction=2,
+            chemical_potential=3,
+            nearest_neighbor_interaction=4,
+            periodic_y=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(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(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(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(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(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(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,