qiskit-nature icon indicating copy to clipboard operation
qiskit-nature copied to clipboard

find_index_order return an incorrect ERI "IndexType"

Open emamars95 opened this issue 7 months ago • 0 comments

Environment

  • Qiskit Nature version: 0.7.2
  • Python version: 3.9.19
  • Operating system: Linux

What is happening?

From the module qiskit_nature.second_q.operators.tensor_ordering, the function find_index_order returns the wrong IndexType once the ERI is converted to PHYSICIST notation.

The problem arises from the following statement in the find_index_order function:

if isinstance(two_body_tensor, SymmetricTwoBodyIntegrals):
        return IndexType.CHEMIST

which checks if the two_body_tensor object is an instance of the SymmetricTwoBodyIntegrals class. If the ERI is converted from CHEMIST to PHYSICIST notation (using to_physicist_ordering function) the returned object belong to the SymmetricTwoBodyIntegrals class and the statement returns the wrong IndexType .

How can we reproduce the issue?

Generate an ERI that respect the permutation symmetry in CHEMIST notation

from qiskit_nature.second_q.drivers import PySCFDriver
from qiskit_nature.second_q.operators import tensor_ordering, symmetric_two_body

driver = PySCFDriver()
problem = driver.run()

mo_hamiltonian = problem.hamiltonian
eri = symmetric_two_body.unfold(mo_hamiltonian.electronic_integrals.alpha["++--"])
print(tensor_ordering.find_index_order(eri))

It returns the CORRECT chemist index: IndexType.CHEMIST

Convert to PHYSICIST notation

eri_physicist = tensor_ordering.to_physicist_ordering(eri)
print(tensor_ordering.find_index_order(eri_physicist))

It returns the WRONG index: IndexType.CHEMIST

What should happen?

The correct result should be return: IndexType.PHYSICIST

Any suggestions?

Remove the following lines from find_index_order function:

 from .symmetric_two_body import SymmetricTwoBodyIntegrals

    if isinstance(two_body_tensor, SymmetricTwoBodyIntegrals):
        return IndexType.CHEMIST

Alternatevely convert the output of _phys_to_chem and _chem_to_phys function as np.array(permuted_tensor)

emamars95 avatar Jul 17 '24 12:07 emamars95