1
$\begingroup$

I'm trying to compare the graphs of the time evolution of a state under the action of a given hamiltonian (Heisenberg, Ising). I have the graphs of the classical simulation using the ~ and @ functionality in Qiskit. The problem is I do not know how to graph the time evolution when I run a trotterized circuit on real backend (say manila). I calculated the fidelity when the simulation runs for time $t = \pi$ but that's about it. Thanks in advanced to anyone who provides help.

$\endgroup$
1
  • $\begingroup$ Could you please share a source code you have written so far? It can help to resolve your issue. $\endgroup$ Sep 17, 2022 at 6:31

1 Answer 1

1
$\begingroup$

Perhaps the Statevector class from qiskit.quantum_info can help you. It contains many attributes, such as Statevector.inner(), which allows to calculate inner products and much more. You may try to convert the state you get after the simulation using your backend to this class. Something like this:

from qiskit import BasicAer, transpile
from qiskit.quantum_info import Statevector

# Function that returns the state vector of a circuit as Statevector class with the BasicAer statevector_simulator

backend = BasicAer.get_backend("statevector_simulator")

def Simulate_statevector(q_circuit):
    tqc = transpile(q_circuit, backend)
    job = backend.run(tqc)
    result = job.result()
    psi_qc = result.get_statevector(tqc, 4)
    return Statevector(psi_qc)

# Example

from qiskit import QuantumCircuit

qc = QuantumCircuit(2)

qc.h(0)
qc.cx(0, 1)

Psi = Simulate_statevector(qc)

# Checking the probability density

Psi.inner(Psi)

In my YouTube channel I've made some tutorials on this topic. Maybe you can find them useful. To know more about qiskit.quantum_info you can also check the Qiskit documentation and the Qiskit pocket guide, which are in my opinion very concise and useful references.

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