Why the expect value of Hamiltonian is different from qiskit?
YangD5014 opened this issue · comments
When I have a tequila circuit transformed from openqasm, I do try the circuit(no uncertain parameters) as ansatz,and I get the expectation value of Hamiltonian,but get far different value compared to qiskit.
Please correct me if I do misuse the tequila API.
Hi, can you post a small example on what exactly you're doing, that might help.
https://github.com/YangD5014/Tequlia_issue/blob/main/tequila_issue.ipynb
Really thank you for instantly reply!
thanks for the example. Next reply will take a bit longer ;-)
I think I found the problem: it is not the qasm import, this works fine.
Qiskit is using the following oder in the second quantized Hamiltonian: first N/2 qubits are the spin-up orbitals, second N/2 qubits are the spin-down orbitals.
So for the H2 we have:
qubit 0: orbital0 spin-up
qubit 1: orbital1 spin-up
qubit 2: orbital0 spin-down
quits 3: orbital1 spin-down
Tequila is using the same ordering as openfermion: Even qubits are spin-up, odd qubits are spin-down.
So for the H2 we have:
qubit 0: orbital0 spin-up
qubit 1: orbital0 spin-down
qubit 2: orbital1 spin-up
quits 3: orbital1 spin-down
Good news is: You can use the ordering that qiskit uses also in Tequila
mol = tq.Molecule(geometry=..., basis_set=..., transformation="ReorderedJordanWigner")
same goes with "ReorderedBravyiKitaev" etc (the upper-cases are just for readability)
It is so clear! And it is indeed working,thank you!