Hi!

I am trying to compare VQE when used in PennyLane and Qiskit with the H2 molecule, but I’m finding trouble in obtaining the same qubit Hamiltonian with both libraries.

What I am doing in PennyLane is this:

from pennylane import numpy as np

import pennylane as qml

symbols = [“H”, “H”]

coordinates = np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.735])

H, qubits = qml.qchem.molecular_hamiltonian(symbols, coordinates)

print("Number of qubits = ", qubits)

print("The Hamiltonian is ", H)

which gives me this Hamiltonian:

Number of qubits = 4

The Hamiltonian is (-0.4636962339610332) [Z2]

+ (-0.4636962339610332) [Z3]

+ (0.2377881241080374) [Z1]

+ (0.23778812410803746) [Z0]

+ (0.7905416330599709) [I0]

+ (0.1407985649568116) [Z0 Z2]

+ (0.1407985649568116) [Z1 Z3]

+ (0.18181634392642693) [Z0 Z3]

+ (0.18181634392642693) [Z1 Z2]

+ (0.18466765822807416) [Z0 Z1]

+ (0.19192132833854414) [Z2 Z3]

+ (-0.041017778969615365) [Y0 Y1 X2 X3]

+ (-0.041017778969615365) [X0 X1 Y2 Y3]

+ (0.041017778969615365) [Y0 X1 X2 Y3]

+ (0.041017778969615365) [X0 Y1 Y2 X3]

In Qiskit, I am doing this:

from qiskit_nature.drivers import Molecule

from qiskit_nature.drivers.second_quantization import ElectronicStructureMoleculeDriver, ElectronicStructureDriverType

from qiskit_nature.problems.second_quantization import ElectronicStructureProblem

from qiskit_nature.converters.second_quantization import QubitConverter

from qiskit_nature.mappers.second_quantization import JordanWignerMapper

molecule = Molecule(geometry=[[‘H’, [0., 0., 0.]],

[‘H’, [0., 0., 0.735]]],

charge=0, multiplicity=1)

driver = ElectronicStructureMoleculeDriver(molecule, basis=‘sto3g’, driver_type=ElectronicStructureDriverType.PYSCF)

es_problem = ElectronicStructureProblem(driver)

qubit_converter = QubitConverter(JordanWignerMapper())

second_q_op = es_problem.second_q_ops()

qubit_op = qubit_converter.convert(second_q_op[0])

print(“Qubit Hamiltonian”)

print(qubit_op)

This gives me the following Hamiltonian:

Qubit Hamiltonian

-0.8105479805373279 * IIII

+ 0.1721839326191554 * IIIZ

- 0.22575349222402372 * IIZI

+ 0.17218393261915543 * IZII

- 0.2257534922240237 * ZIII

+ 0.12091263261776627 * IIZZ

+ 0.16892753870087907 * IZIZ

+ 0.045232799946057826 * YYYY

+ 0.045232799946057826 * XXYY

+ 0.045232799946057826 * YYXX

+ 0.045232799946057826 * XXXX

+ 0.1661454325638241 * ZIIZ

+ 0.1661454325638241 * IZZI

+ 0.17464343068300453 * ZIZI

+ 0.12091263261776627 * ZZII

As you can see, they are very different, and so are the ground state energies that I obtain when running VQE on them.

I would really appreciate it if you could shed some light here. What am I doing wrong?

Thanks in advance!