3
$\begingroup$

I've been trying to implement the 1D Heisenberg chain (i.e. the XXZ model) on Qiskit but have been having trouble. To recap, the Heisenberg hamiltonian is as follows: $$H_{XXZ} = \sum^{N}_{i = 1} [J(S^{x}_{i}S^{x}_{i+1} + S^{y}_{i}S^{y}_{i+1} + \Delta S^{z}_{i}S^{z}_{i+1})] $$ and we can take the XY hamiltonian to be $$H_{XY} = \sum^{N}_{i = 1} [J(S^{x}_{i}S^{x}_{i+1} + S^{y}_{i}S^{y}_{i+1})]$$ as I understand. I know that the matrix representation of this hamiltonian's time evolution takes the form $$XY(\theta) = \begin{pmatrix} 1 & 0 & 0 & 0\\ 0 & \cos[{\theta}/2] & i\sin[{\theta}/2] & 0\\ 0 & i\sin[{\theta}/2] & \cos[{\theta}/2] & 0\\ 0 & 0 & 0 & 1 \end{pmatrix}$$ however, I'm not exactly sure how to implement it on Qiskit with the available Quantum logic gates. I do know that a special case to this problem is the iSwapGate, where it is equal to $XY(\theta = \pi)$, but is there a way to implement $XY(\theta)$ for arbitrary angles?

$\endgroup$
  • $\begingroup$ Are you wanting to implement the evolution of $H_{XY}$ over just two qubits, or over many qubits? $\endgroup$ – DaftWullie Dec 21 '20 at 7:26
  • $\begingroup$ The two qubits case is the more important case for what I'm doing. However, the code I'm working on does generalize it to whatever number of sites/qubits I want. I had done so for the transverse Ising model before, so I think what I've done for this hamiltonian is correct as well. $\endgroup$ – Norhan Mahmoud Dec 21 '20 at 12:56
3
$\begingroup$

Here is an implementation

from qiskit.circuit import QuantumCircuit, Parameter

theta = Parameter('θ')

qc = QuantumCircuit(2)
qc.cx(0, 1)
qc.crx(-1 * theta, 1, 0)
qc.cx(0, 1)

print(qc)
---
          ┌────────┐     
q_0: ──■──┤ RX(-θ) ├──■──
     ┌─┴─┐└───┬────┘┌─┴─┐
q_1: ┤ X ├────■─────┤ X ├
     └───┘          └───┘

and to evaluate that it works:

from qiskit.quantum_info import Operator

def XY(theta):
    c = np.cos(theta / 2)
    s = 1j * np.sin(theta / 2)
    
    return np.array([[1, 0, 0, 0], 
                     [0, c, s, 0], 
                     [0, s, c, 0], 
                     [0, 0, 0, 1]])

val = pi / 14
circ = qc.bind_parameters({theta: val})
np.allclose(Operator(circ).data, 
            XY(val))
---
True
$\endgroup$
  • $\begingroup$ Yes, thank you for your help. I guess I need to look into the Qiskit library a bit more to get familiar with all of the available gates. $\endgroup$ – Norhan Mahmoud Dec 20 '20 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.