2
$\begingroup$

I am working with a Tight Binding Hamiltonian with N sites and one orbital at each site in a closed chain. I have converted the fermionic expression to a spin expression using Jordan Wigner Transformation. I want to apply this as a gate in qiskit without using the built-in lattice model functions.
This is the Hamiltonian in terms of fermionic operators : $$ H_{\text{sys}} = \sum_{i} \epsilon_i c_{i }^{\dagger} c_{i } + t \sum_{i } (c_{i}^\dagger c_{i+1 } + c_{i+1}^\dagger c_{i } ) $$

This is the expression of the transformed Hamiltonian :
$$ H_{\text{sys}} = \sum _{k=1}^{N} \textbf{I}^{\otimes (k-1)} \otimes \epsilon _k \big( \sigma ^- . \sigma ^+ \big)_k \otimes \textbf{I}^{\otimes(N-k)} + \sum _{k=1}^{N} \textbf{I}^{\otimes (k-1)} \otimes \big( \sigma ^- \big) _k \otimes \big( \sigma^+\big)_{k+1} \otimes \textbf{I}^{\otimes (N-k-1)} \\ - \sum _{k=1}^{N} \textbf{I}^{\otimes (k-1)} \otimes \big( \sigma ^+ \big) _k \otimes \big( \sigma^-\big)_{k+1} \otimes \textbf{I}^{\otimes (N-k-1)} $$

$ \sigma _{\pm} = \frac{X \pm i Y}{2}$

I want to know how I can implement this as a gate in qiskit without creating the matrix first, and by simply tensoring the Pauli operators and summing them up using PauliSumOp.

What is the best way to implement it in general?

$\endgroup$

2 Answers 2

1
$\begingroup$

The simplest way to do that is to use HamiltonianGate

from qiskit import QuantumCircuit
from qiskit.opflow import I, X, Y, Z

# This just a sample hamiltonian:
H = I^I^X^Y + I^Z^X^I

# Create the circuit:
time = 0.1
N = H.num_qubits

circ = QuantumCircuit(N)
circ.hamiltonian(H, time, list(range(N)))

# Print the circuit:
circ.decompose(reps=2).draw('mpl')
$\endgroup$
3
  • $\begingroup$ I see. I tried it. I can implement the Hamiltonian, I see a bunch of gates implemented in the circuit, but i dont know how i can verify it. Also, I don't want to evolve the hamiltonian, in fact it is time independent. Is there a way I can create this matrix and get its eigenvalues and eigenstates? $\endgroup$ Jul 7, 2023 at 13:14
  • 1
    $\begingroup$ According to Schrodinger's equation, for time-independent Hamiltonian $H$, if the initail state of the qusntum system is $|\psi(0)\rangle$, then state at time $t$ will satisfy $|\psi(t)\rangle = e^{-iHt}|\psi(0)\rangle$. In Hamiltonian simulation problem we are asked to get the quantum circuit that implements the unitary $U(t) = e^{-iHt}$. If, however, you want to get the eigenvalues and eigenstates of H, you can easily use numpy.linalg.eig function: eigenvalues, eigenstates = np.linalg.eig(H.to_matrix()) $\endgroup$ Jul 9, 2023 at 9:04
  • $\begingroup$ Thanks! I got it. I can't really implement the Hamiltonian as its not unitary. I wanted to implement it to use VQE on it to get the eigenvalues. It would work if I use VQE on the time evolution operator as well. $\endgroup$ Jul 13, 2023 at 9:57
0
$\begingroup$

I used the SparsePauliOp to write the Hamiltonian. And then I used circ.hamiltonian(H,time,list(range(N))) to implement the time evolution operator.

$\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.