diff --git a/pennylane/spin/__init__.py b/pennylane/spin/__init__.py index b73de4100ef..a3bf071889e 100644 --- a/pennylane/spin/__init__.py +++ b/pennylane/spin/__init__.py @@ -20,6 +20,6 @@ fermi_hubbard, heisenberg, kitaev, + spin_hamiltonian, transverse_ising, - custom_hamiltonian_from_lattice, ) diff --git a/tests/spin/test_spin_hamiltonian.py b/tests/spin/test_spin_hamiltonian.py index 13b316668ff..3b74d4dc10b 100644 --- a/tests/spin/test_spin_hamiltonian.py +++ b/tests/spin/test_spin_hamiltonian.py @@ -23,11 +23,11 @@ from pennylane import I, X, Y, Z from pennylane.spin import ( Lattice, - custom_hamiltonian_from_lattice, fermi_hubbard, heisenberg, kitaev, transverse_ising, + spin_hamiltonian ) pytestmark = pytest.mark.usefixtures("new_opmath_only") @@ -907,10 +907,32 @@ def test_kitaev_hamiltonian(n_cells, j, boundary_condition, expected_ham): ), ), ], + ("lattice", "expected_ham"), + [ + ( + Lattice( + n_cells=[2, 2], + vectors=[[1, 0], [0, 1]], + positions=[[0, 0], [1, 5]], + boundary_condition=False, + custom_edges=[[(0, 1), ("XX", 0.5)], [(1, 2), ("YY", 0.6)], [(1, 4), ("ZZ", 0.7)]], + ), + ( + 0.5 * (X(0) @ X(1)) + + 0.5 * (X(2) @ X(3)) + + 0.5 * (X(4) @ X(5)) + + 0.5 * (X(6) @ X(7)) + + 0.6 * (Y(1) @ Y(2)) + + 0.6 * (Y(5) @ Y(6)) + + 0.7 * (Z(1) @ Z(4)) + + 0.7 * (Z(3) @ Z(6)) + ), + ), + ], ) def test_custom_hamiltonian(lattice, expected_ham): r"""Test that the correct Hamiltonian is generated""" - custom_ham = custom_hamiltonian_from_lattice(lattice=lattice) + custom_ham = spin_hamiltonian(lattice=lattice) qml.assert_equal(custom_ham, expected_ham)