class_docstr: Integration tests for Rydberg system Hamiltonians.
docstr: Test that the results of PennyLane simulation match (within reason) the exact solution
docstr_tok: ["Test","that","the","results","of","PennyLane","simulation","match","(","within","reason",")","the","exact","solution"]
code: def test_pennylane_and_exact_solution_correspond(self):
      """Test that the results of PennyLane simulation match (within reason) the exact solution"""
      import jax
      import jax.numpy as jnp
  
      def exact(H, H_obj, t):
          psi0 = jnp.eye(2 ** len(H.wires))[0]
          U_exact = jax.scipy.linalg.expm(
              -1j * t * qml.matrix(H([], 1))
          )
          return (
              psi0
              @ U_exact.conj().T
              @ qml.matrix(H_obj, wire_order=[0, 1, 2])
              @ U_exact
              @ psi0
          )
  
      default_qubit = qml.device("default.qubit", wires=3)
  
      coordinates = [[0, 0], [0, 5], [5, 0]]
  
      H_i = qml.pulse.rydberg_interaction(coordinates)
  
      H = H_i + qml.pulse.rydberg_drive(3, 2, 4, [0, 1, 2])
  
      H_obj = qml.PauliZ(0)
  
      @jax.jit
      @qml.qnode(default_qubit, interface="jax")
      def circuit(t):
          qml.evolve(H)([], t)
          return qml.expval(H_obj)
  
      t = jnp.linspace(0.05, 1.55, 151)
  
      circuit_results = np.array([circuit(_t) for _t in t])
      exact_results = np.array([exact(H, H_obj, _t) for _t in t])
  
      # all results are approximately the same
      np.allclose(circuit_results, exact_results, atol=0.07)
  
imports: import numpy
  import pytest
  import pennylane
  from pennylane.pulse import rydberg_interaction, rydberg_drive
  from pennylane.pulse.hardware_hamiltonian import HardwareHamiltonian, HardwarePulse, AmplitudeAndPhase
  from pennylane.wires import Wires
  from pennylane.pulse.rydberg import RydbergSettings
label_desc: Use image node_id 4 for calling the TestIntegration obj's underlying member method code with example usage: obj.test_pennylane_and_exact_solution_correspond() and returns: unknown, qml