I recently saw a piece of code that computes molecular bond energy with respect to bond length. I am trying to update the code to the newer qiskit framework (I'm running qiskit 0.45.1 and qiskit-nature instead of the depricated qiskit.chemistry). The complete original code is available as a video, but I have extracted the relevant parts below.

In order to generate a qubit operator associated with the Hamiltonian in the process of finding the eigen energy, the older version of qiskit uses the class qiskit.chemistry.core.Hamiltonian, which does not exist anymore in qiskit_nature.

I'm wondering if there is an alternative way to generate the qubitOp such that I can use NumPyMinimumEigensolver().run() to find the exact bond energy? In other words, how can I make the following piece of code run correctly using qiskit-nature?

driver = PySCFDriver(atom=moleculeRepr.format(dist/2), basis="sto3g")
molecule = driver.run()
operator = Hamiltonian(qubit_mapping=QubitMappingtype.PARITY, two_qubit_reduction=True, freeze_core=True,orbital_reduction=[-3, -2])
qubitOp, aux_ops = operator.run(molecule)

#classical result
exactResult = NumPyMinimumEigensolver(qubitOp, aux_operators=aux_ops).run()
exactResult = operator.process_algorithm_result(exactResult)

Any help or insights into this question would be greatly appreciated.



Your Answer

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

Browse other questions tagged or ask your own question.