6

I'm a beginner with Qiskit and the Python language at all.

Here is my question: One of the VQE function arguments is qubit operator (qubitOp). I saw some examples where the qubitOp object was produced by some already existing Qiskit module.

For example, in the following fragment:

qubitOp, offset = max_cut.get_max_cut_qubitops(w)

qubitOp is an Ising Hamiltonian produced from the connection weights matrix.

But how can I define the qubitOp entirely by myself, from the very beginning? (My actual goal is to enrich the Ising Hamiltonian with spin's interactions with the external magnetic field). Thanks!

Sanchayan Dutta
  • 17,497
  • 7
  • 48
  • 110
  • can you include a minimal working example? (here that would be including the imports needed to have that line of code working). A link to the example page you are referring to would also be nice – glS Jun 03 '19 at 10:59
  • you can get an idea of how you can define a qubitOp by yourself by having a look at the source code for get_max_cut_qubitops, which you can find here. But a minimal working example would help me get a quick example working more quickly – glS Jun 03 '19 at 11:07

1 Answers1

5

The question refers to the VQE, so let's start with this and Max_Cut; they can be built on the VQE. There used to be a vqe.ipynp but I can't find, look for an example.

The VQE algorithm doesn't need much input. You can fill it with the paulis_dict. This could be a simple Z gate for finding the eigenvalues= -1.

pauli_dict = {
    'paulis': [{"coeff": {"imag": 0.0, "real": 1}, "label": "Z"}]
}

qubitOp = Operator.load_from_dict(pauli_dict)
print(qubitOp)

I will publish my VQE test on github soon. I want to compare Rigetti and IBM VQE.

Sanchayan Dutta
  • 17,497
  • 7
  • 48
  • 110
Bram
  • 544
  • 3
  • 9