From 8c9b17f25c6fa83f4a29903b6144589f43f3f9e5 Mon Sep 17 00:00:00 2001 From: ddhawan11 Date: Mon, 16 Sep 2024 12:58:17 -0400 Subject: [PATCH] Changed test --- pennylane/spin/spin_hamiltonian.py | 10 +- tests/spin/test_spin_hamiltonian.py | 171 ++++------------------------ 2 files changed, 23 insertions(+), 158 deletions(-) diff --git a/pennylane/spin/spin_hamiltonian.py b/pennylane/spin/spin_hamiltonian.py index c9dc59f9b8b..3f154bded1d 100644 --- a/pennylane/spin/spin_hamiltonian.py +++ b/pennylane/spin/spin_hamiltonian.py @@ -321,10 +321,9 @@ def emery( neighbour_order=1, mapping="jordan_wigner", ): - r"""Generates the Hamiltonian for the `Emery model ` - _ on a lattice. + r"""Generates the Hamiltonian for the Emery model on a lattice. - The Hamiltonian is represented as: + The `Emery `_ model Hamiltonian is represented as: .. math:: \begin{align*} @@ -484,10 +483,9 @@ def haldane( boundary_condition=False, mapping="jordan_wigner", ): - r"""Generates the `Haldane model `_ - Hamiltonian on a lattice. + r"""Generates the Hamiltonian for the the Haldane model on a lattice. - The Hamiltonian is represented as: + The `Haldane `_ model Hamiltonian is represented as: .. math:: diff --git a/tests/spin/test_spin_hamiltonian.py b/tests/spin/test_spin_hamiltonian.py index 3e6d1073fcb..ff6532c2eb5 100644 --- a/tests/spin/test_spin_hamiltonian.py +++ b/tests/spin/test_spin_hamiltonian.py @@ -879,8 +879,8 @@ def test_mapping_error_emery(): + (0.355 + 0j) * (Z(5) @ Z(7)), ), ( - "Square", - [3, 3], + "Chain", + [4], -1.23, 2.34, 1.42, @@ -889,180 +889,47 @@ def test_mapping_error_emery(): + (0.615 + 0j) * (X(0) @ Z(1) @ X(2)) + (0.615 + 0j) * (Y(1) @ Z(2) @ Y(3)) + (0.615 + 0j) * (X(1) @ Z(2) @ X(3)) - + (0.615 + 0j) * (Y(0) @ Z(1) @ Z(2) @ Z(3) @ Y(4)) - + (0.615 + 0j) * (X(0) @ Z(1) @ Z(2) @ Z(3) @ X(4)) - + (0.615 + 0j) * (Y(1) @ Z(2) @ Z(3) @ Z(4) @ Y(5)) - + (0.615 + 0j) * (X(1) @ Z(2) @ Z(3) @ Z(4) @ X(5)) + (0.615 + 0j) * (Y(0) @ Z(1) @ Z(2) @ Z(3) @ Z(4) @ Z(5) @ Y(6)) + (0.615 + 0j) * (X(0) @ Z(1) @ Z(2) @ Z(3) @ Z(4) @ Z(5) @ X(6)) + (0.615 + 0j) * (Y(1) @ Z(2) @ Z(3) @ Z(4) @ Z(5) @ Z(6) @ Y(7)) + (0.615 + 0j) * (X(1) @ Z(2) @ Z(3) @ Z(4) @ Z(5) @ Z(6) @ X(7)) - # fmt: off - + (0.615 + 0j) * (Y(0) @ Z(1) @ Z(2) @ Z(3) @ Z(4) @ Z(5) @ Z(6) @ Z(7) @ Z(8) @ Z(9) @ Z(10) @ Z(11) @ Y(12)) - + (0.615 + 0j) * (X(0) @ Z(1) @ Z(2) @ Z(3) @ Z(4) @ Z(5) @ Z(6) @ Z(7) @ Z(8) @ Z(9) @ Z(10) @ Z(11) @ X(12)) - + (0.615 + 0j) * (Y(1) @ Z(2) @ Z(3) @ Z(4) @ Z(5) @ Z(6) @ Z(7) @ Z(8) @ Z(9) @ Z(10) @ Z(11) @ Z(12) @ Y(13)) - + (0.615 + 0j) * (X(1) @ Z(2) @ Z(3) @ Z(4) @ Z(5) @ Z(6) @ Z(7) @ Z(8) @ Z(9) @ Z(10) @ Z(11) @ Z(12) @ X(13)) - # fmt: on + (0.615 + 0j) * (Y(2) @ Z(3) @ Y(4)) + (0.615 + 0j) * (X(2) @ Z(3) @ X(4)) + (0.615 + 0j) * (Y(3) @ Z(4) @ Y(5)) + (0.615 + 0j) * (X(3) @ Z(4) @ X(5)) - + (0.615 + 0j) * (Y(2) @ Z(3) @ Z(4) @ Z(5) @ Z(6) @ Z(7) @ Y(8)) - + (0.615 + 0j) * (X(2) @ Z(3) @ Z(4) @ Z(5) @ Z(6) @ Z(7) @ X(8)) - + (0.615 + 0j) * (Y(3) @ Z(4) @ Z(5) @ Z(6) @ Z(7) @ Z(8) @ Y(9)) - + (0.615 + 0j) * (X(3) @ Z(4) @ Z(5) @ Z(6) @ Z(7) @ Z(8) @ X(9)) - # fmt: off - + (0.615 + 0j) * (Y(2) @ Z(3) @ Z(4) @ Z(5) @ Z(6) @ Z(7) @ Z(8) @ Z(9) @ Z(10) @ Z(11) @ Z(12) @ Z(13) @ Y(14)) - + (0.615 + 0j) * (X(2) @ Z(3) @ Z(4) @ Z(5) @ Z(6) @ Z(7) @ Z(8) @ Z(9) @ Z(10) @ Z(11) @ Z(12) @ Z(13) @ X(14)) - + (0.615 + 0j) * (Y(3) @ Z(4) @ Z(5) @ Z(6) @ Z(7) @ Z(8) @ Z(9) @ Z(10) @ Z(11) @ Z(12) @ Z(13) @ Z(14) @ Y(15)) - + (0.615 + 0j) * (X(3) @ Z(4) @ Z(5) @ Z(6) @ Z(7) @ Z(8) @ Z(9) @ Z(10) @ Z(11) @ Z(12) @ Z(13) @ Z(14) @ X(15)) - # fmt: on - + (0.615 + 0j) * (Y(4) @ Z(5) @ Z(6) @ Z(7) @ Z(8) @ Z(9) @ Y(10)) - + (0.615 + 0j) * (X(4) @ Z(5) @ Z(6) @ Z(7) @ Z(8) @ Z(9) @ X(10)) - + (0.615 + 0j) * (Y(5) @ Z(6) @ Z(7) @ Z(8) @ Z(9) @ Z(10) @ Y(11)) - + (0.615 + 0j) * (X(5) @ Z(6) @ Z(7) @ Z(8) @ Z(9) @ Z(10) @ X(11)) - # fmt: off - + (0.615 + 0j) * (Y(4) @ Z(5) @ Z(6) @ Z(7) @ Z(8) @ Z(9) @ Z(10) @ Z(11) @ Z(12) @ Z(13) @ Z(14) @ Z(15) @ Y(16)) - + (0.615 + 0j) * (X(4) @ Z(5) @ Z(6) @ Z(7) @ Z(8) @ Z(9) @ Z(10) @ Z(11) @ Z(12) @ Z(13) @ Z(14) @ Z(15)@ X(16)) - + (0.615 + 0j) * (Y(5) @ Z(6) @ Z(7) @ Z(8) @ Z(9) @ Z(10) @ Z(11) @ Z(12) @ Z(13) @ Z(14) @ Z(15) @ Z(16) @ Y(17)) - + (0.615 + 0j) * (X(5) @ Z(6) @ Z(7) @ Z(8) @ Z(9) @ Z(10) @ Z(11) @ Z(12) @ Z(13) @ Z(14) @ Z(15) @ Z(16) @ X(17)) - # fmt: on - + (0.615 + 0j) * (Y(6) @ Z(7) @ Y(8)) - + (0.615 + 0j) * (X(6) @ Z(7) @ X(8)) - + (0.615 + 0j) * (Y(7) @ Z(8) @ Y(9)) - + (0.615 + 0j) * (X(7) @ Z(8) @ X(9)) - + (0.615 + 0j) * (Y(6) @ Z(7) @ Z(8) @ Z(9) @ Y(10)) - + (0.615 + 0j) * (X(6) @ Z(7) @ Z(8) @ Z(9) @ X(10)) - + (0.615 + 0j) * (Y(7) @ Z(8) @ Z(9) @ Z(10) @ Y(11)) - + (0.615 + 0j) * (X(7) @ Z(8) @ Z(9) @ Z(10) @ X(11)) - + (0.615 + 0j) * (Y(6) @ Z(7) @ Z(8) @ Z(9) @ Z(10) @ Z(11) @ Y(12)) - + (0.615 + 0j) * (X(6) @ Z(7) @ Z(8) @ Z(9) @ Z(10) @ Z(11) @ X(12)) - + (0.615 + 0j) * (Y(7) @ Z(8) @ Z(9) @ Z(10) @ Z(11) @ Z(12) @ Y(13)) - + (0.615 + 0j) * (X(7) @ Z(8) @ Z(9) @ Z(10) @ Z(11) @ Z(12) @ X(13)) - + (0.615 + 0j) * (Y(8) @ Z(9) @ Y(10)) - + (0.615 + 0j) * (X(8) @ Z(9) @ X(10)) - + (0.615 + 0j) * (Y(9) @ Z(10) @ Y(11)) - + (0.615 + 0j) * (X(9) @ Z(10) @ X(11)) - + (0.615 + 0j) * (Y(8) @ Z(9) @ Z(10) @ Z(11) @ Z(12) @ Z(13) @ Y(14)) - + (0.615 + 0j) * (X(8) @ Z(9) @ Z(10) @ Z(11) @ Z(12) @ Z(13) @ X(14)) - + (0.615 + 0j) * (Y(9) @ Z(10) @ Z(11) @ Z(12) @ Z(13) @ Z(14) @ Y(15)) - + (0.615 + 0j) * (X(9) @ Z(10) @ Z(11) @ Z(12) @ Z(13) @ Z(14) @ X(15)) - + (0.615 + 0j) * (Y(10) @ Z(11) @ Z(12) @ Z(13) @ Z(14) @ Z(15) @ Y(16)) - + (0.615 + 0j) * (X(10) @ Z(11) @ Z(12) @ Z(13) @ Z(14) @ Z(15) @ X(16)) - + (0.615 + 0j) * (Y(11) @ Z(12) @ Z(13) @ Z(14) @ Z(15) @ Z(16) @ Y(17)) - + (0.615 + 0j) * (X(11) @ Z(12) @ Z(13) @ Z(14) @ Z(15) @ Z(16) @ X(17)) - + (0.615 + 0j) * (Y(12) @ Z(13) @ Y(14)) - + (0.615 + 0j) * (X(12) @ Z(13) @ X(14)) - + (0.615 + 0j) * (Y(13) @ Z(14) @ Y(15)) - + (0.615 + 0j) * (X(13) @ Z(14) @ X(15)) - + (0.615 + 0j) * (Y(12) @ Z(13) @ Z(14) @ Z(15) @ Y(16)) - + (0.615 + 0j) * (X(12) @ Z(13) @ Z(14) @ Z(15) @ X(16)) - + (0.615 + 0j) * (Y(13) @ Z(14) @ Z(15) @ Z(16) @ Y(17)) - + (0.615 + 0j) * (X(13) @ Z(14) @ Z(15) @ Z(16) @ X(17)) - + (0.615 + 0j) * (Y(14) @ Z(15) @ Y(16)) - + (0.615 + 0j) * (X(14) @ Z(15) @ X(16)) - + (0.615 + 0j) * (Y(15) @ Z(16) @ Y(17)) - + (0.615 + 0j) * (X(15) @ Z(16) @ X(17)) - + (30.825000000000028 + 0j) * I(0) - + (-3.425 + 0j) * Z(1) - + (-3.425 + 0j) * Z(0) + + (0.615 + 0j) * (Y(4) @ Z(5) @ Y(6)) + + (0.615 + 0j) * (X(4) @ Z(5) @ X(6)) + + (0.615 + 0j) * (Y(5) @ Z(6) @ Y(7)) + + (0.615 + 0j) * (X(5) @ Z(6) @ X(7)) + + (8.020000000000005 + 0j) * I(0) + + (-2.005 + 0j) * Z(1) + + (-2.005 + 0j) * Z(0) + (0.585 + 0j) * (Z(0) @ Z(1)) - + (-3.425 + 0j) * Z(3) - + (-3.425 + 0j) * Z(2) + + (-2.005 + 0j) * Z(3) + + (-2.005 + 0j) * Z(2) + (0.585 + 0j) * (Z(2) @ Z(3)) - + (-3.425 + 0j) * Z(5) - + (-3.425 + 0j) * Z(4) + + (-2.005 + 0j) * Z(5) + + (-2.005 + 0j) * Z(4) + (0.585 + 0j) * (Z(4) @ Z(5)) - + (-3.425 + 0j) * Z(7) - + (-3.425 + 0j) * Z(6) + + (-2.005 + 0j) * Z(7) + + (-2.005 + 0j) * Z(6) + (0.585 + 0j) * (Z(6) @ Z(7)) - + (-3.425 + 0j) * Z(9) - + (-3.425 + 0j) * Z(8) - + (0.585 + 0j) * (Z(8) @ Z(9)) - + (-3.425 + 0j) * Z(11) - + (-3.425 + 0j) * Z(10) - + (0.585 + 0j) * (Z(10) @ Z(11)) - + (-3.425 + 0j) * Z(13) - + (-3.425 + 0j) * Z(12) - + (0.585 + 0j) * (Z(12) @ Z(13)) - + (-3.425 + 0j) * Z(15) - + (-3.425 + 0j) * Z(14) - + (0.585 + 0j) * (Z(14) @ Z(15)) - + (-3.425 + 0j) * Z(17) - + (-3.425 + 0j) * Z(16) - + (0.585 + 0j) * (Z(16) @ Z(17)) + (0.355 + 0j) * (Z(0) @ Z(2)) + (0.355 + 0j) * (Z(0) @ Z(3)) + (0.355 + 0j) * (Z(1) @ Z(2)) + (0.355 + 0j) * (Z(1) @ Z(3)) - + (0.355 + 0j) * (Z(0) @ Z(4)) - + (0.355 + 0j) * (Z(0) @ Z(5)) - + (0.355 + 0j) * (Z(1) @ Z(4)) - + (0.355 + 0j) * (Z(1) @ Z(5)) + (0.355 + 0j) * (Z(0) @ Z(6)) + (0.355 + 0j) * (Z(0) @ Z(7)) + (0.355 + 0j) * (Z(1) @ Z(6)) + (0.355 + 0j) * (Z(1) @ Z(7)) - + (0.355 + 0j) * (Z(0) @ Z(12)) - + (0.355 + 0j) * (Z(0) @ Z(13)) - + (0.355 + 0j) * (Z(1) @ Z(12)) - + (0.355 + 0j) * (Z(1) @ Z(13)) + (0.355 + 0j) * (Z(2) @ Z(4)) + (0.355 + 0j) * (Z(2) @ Z(5)) + (0.355 + 0j) * (Z(3) @ Z(4)) + (0.355 + 0j) * (Z(3) @ Z(5)) - + (0.355 + 0j) * (Z(2) @ Z(8)) - + (0.355 + 0j) * (Z(2) @ Z(9)) - + (0.355 + 0j) * (Z(3) @ Z(8)) - + (0.355 + 0j) * (Z(3) @ Z(9)) - + (0.355 + 0j) * (Z(2) @ Z(14)) - + (0.355 + 0j) * (Z(2) @ Z(15)) - + (0.355 + 0j) * (Z(3) @ Z(14)) - + (0.355 + 0j) * (Z(3) @ Z(15)) - + (0.355 + 0j) * (Z(4) @ Z(10)) - + (0.355 + 0j) * (Z(4) @ Z(11)) - + (0.355 + 0j) * (Z(5) @ Z(10)) - + (0.355 + 0j) * (Z(5) @ Z(11)) - + (0.355 + 0j) * (Z(4) @ Z(16)) - + (0.355 + 0j) * (Z(4) @ Z(17)) - + (0.355 + 0j) * (Z(5) @ Z(16)) - + (0.355 + 0j) * (Z(5) @ Z(17)) - + (0.355 + 0j) * (Z(6) @ Z(8)) - + (0.355 + 0j) * (Z(6) @ Z(9)) - + (0.355 + 0j) * (Z(7) @ Z(8)) - + (0.355 + 0j) * (Z(7) @ Z(9)) - + (0.355 + 0j) * (Z(6) @ Z(10)) - + (0.355 + 0j) * (Z(6) @ Z(11)) - + (0.355 + 0j) * (Z(7) @ Z(10)) - + (0.355 + 0j) * (Z(7) @ Z(11)) - + (0.355 + 0j) * (Z(6) @ Z(12)) - + (0.355 + 0j) * (Z(6) @ Z(13)) - + (0.355 + 0j) * (Z(7) @ Z(12)) - + (0.355 + 0j) * (Z(7) @ Z(13)) - + (0.355 + 0j) * (Z(8) @ Z(10)) - + (0.355 + 0j) * (Z(8) @ Z(11)) - + (0.355 + 0j) * (Z(9) @ Z(10)) - + (0.355 + 0j) * (Z(9) @ Z(11)) - + (0.355 + 0j) * (Z(8) @ Z(14)) - + (0.355 + 0j) * (Z(8) @ Z(15)) - + (0.355 + 0j) * (Z(9) @ Z(14)) - + (0.355 + 0j) * (Z(9) @ Z(15)) - + (0.355 + 0j) * (Z(10) @ Z(16)) - + (0.355 + 0j) * (Z(10) @ Z(17)) - + (0.355 + 0j) * (Z(11) @ Z(16)) - + (0.355 + 0j) * (Z(11) @ Z(17)) - + (0.355 + 0j) * (Z(12) @ Z(14)) - + (0.355 + 0j) * (Z(12) @ Z(15)) - + (0.355 + 0j) * (Z(13) @ Z(14)) - + (0.355 + 0j) * (Z(13) @ Z(15)) - + (0.355 + 0j) * (Z(12) @ Z(16)) - + (0.355 + 0j) * (Z(12) @ Z(17)) - + (0.355 + 0j) * (Z(13) @ Z(16)) - + (0.355 + 0j) * (Z(13) @ Z(17)) - + (0.355 + 0j) * (Z(14) @ Z(16)) - + (0.355 + 0j) * (Z(14) @ Z(17)) - + (0.355 + 0j) * (Z(15) @ Z(16)) - + (0.355 + 0j) * (Z(15) @ Z(17)), + + (0.355 + 0j) * (Z(4) @ Z(6)) + + (0.355 + 0j) * (Z(4) @ Z(7)) + + (0.355 + 0j) * (Z(5) @ Z(6)) + + (0.355 + 0j) * (Z(5) @ Z(7)), ), ], )