0
$\begingroup$

I'm new to Qiskit. I am trying to construct a gate from HamiltonianGate(), available on Qiskit. The Hamiltonian in question is: $$H = - \pi\delta(Z_1 - Z_2) + 2\pi J ~ \mathbf{I}_1 \cdot \mathbf{I}_2$$ where $\mathbf{I}_1$ and $\mathbf{I}_2$ are Pauli vectors, each for system 1 and system 2, respectively.

Although I was able to do so by using HamiltonianGate(), when I try to see my circuit, I end up getting something like this:

enter image description here

I was hoping to find explicit gate decomposition of my unitary from HamiltonianGate(), but I'm unable to find a way to do so.

Please do let me know how I can proceed from here and obtain the explicit gate decompositions. If this is, for some reason, not possible, then please do let me know why it is so. Also, if given this scenario, any help in simulating the unitary associated with the above Hamiltonian via elementary gates would be very much appreciated!

$\endgroup$
3
  • 1
    $\begingroup$ Hi. It could be worth trying QuantumCircuit.decompose(). You can repeatedly decompose your circuit to lower and lower levels of abstraction if need be. $\endgroup$
    – Callum
    Oct 2, 2023 at 19:32
  • $\begingroup$ Unfortunately, it did not change anything, at least visually. $\endgroup$ Oct 2, 2023 at 19:49
  • 1
    $\begingroup$ If you define a new varible with new_qc = qc.decompose(reps=2) you should be able to see the difference with new_qc.draw('mpl'). Here qc is a QuantumCircuit object. $\endgroup$
    – Callum
    Oct 2, 2023 at 20:16

1 Answer 1

2
$\begingroup$

As @Callum mentioned in the comments, you can use QuantumCircuit.decompose() to achieve this. However, you should be aware of the following two points:

  • It does not affect your circuit. Instead, it returns the decomposed circuit.
  • By default, it decomposes one level only (shallow decompose). For further decomposition you can use the parameter reps to set number of times the circuit should be decomposed.

As an example, this code snippet should draw the circuit circ after applying the decomposition pass two times:  

circ.decompose(reps=2).draw('mpl')
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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