3
$\begingroup$

As part of a project I'm working on, I want to use VQE algorithm to calculate the minimal eigenvalue for given Hamiltonian. I use Qiskit on IBM UI online.

The Hamiltonian is given as a sum of tensor products

$H = Z\otimes Z + Z \otimes X + ...$

I don't understand two main points:

  1. How should I pass the Hamiltonian to the VQE? should I pass it as a list? i.e. $ H = [Z\^Z, X\^Z]$?
  2. I understand that I need to create N circuits, where N is the number of tensor products which constitute the Hamiltonian, so that each circuit will handle another part of the Hamiltonian. Do I understand this correctly?

Thank you.

$\endgroup$

2 Answers 2

3
$\begingroup$

In the latest version of qiskit (package aqua has been deprecated and had a massive refactoring) it is enough to import the base Pauli matrices X, Y, Z from qiskit opflow and perform the tensor product in the way you want, i.e.,

from qiskit.opflow import X,Y,Z,I   
operator = Z ^ Z + X ^ X

Afterwards, you initialize VQE

from qiskit.algorithms import VQE
vqe = VQE(ansatz=your_ansatz, quantum_instance=your_quantum_instance, optimizer=your_optimizer)

And execute it (note that in the latest version VQE belongs to qiskit.algorithms package and the paramter var_form has been renamed in ansatz):

vqe.compute_minimum_eigenvalue(matrix_op).eigenvalue

Clearly, I am assuming that you are interested in the eigenvalue, but there are other return values that you can retrieve. For a full reference:

https://qiskit.org/documentation/stubs/qiskit.algorithms.VQE.html

$\endgroup$
0
$\begingroup$

Try this:

from qiskit.aqua.operators import WeightedPauliOperator
dict = {
    'paulis': [{"coeff": {"imag": 0.00, "real": 1 }, "label": "ZZ" },
              {"coeff": {"imag": 0.00, "real": 1 }, "label": "XX" }
              ]
}
Operator = WeightedPauliOperator.from_dict(dict)

Now you can pass this operator to your VQE call:

VQE(operator= Operator, var_form= ... )
$\endgroup$
1
  • $\begingroup$ Thank you for your comment. After few trials it appears that the expression doesn't need to be modified but needs to be passed as it is $\endgroup$ Oct 15, 2020 at 4:48

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.