2
$\begingroup$

qiskit.chemistry.FermionicOperator here is very useful for converting fermionic operators to qubits operators. qiskit.chemistry has been deprecated. I went through the migration guide they have but I can't seem to find the replacement of FermiOpetator in qiskit_nature. Anyone know this? Thanks a lot.

$\endgroup$
2
$\begingroup$

This is now under QubitConverter within qiskit_nature.

This link here might be helpful. You might have to look into how to define the fermionic operators in this new released version, but the example below, which is really just taking from the above linked, might provide some guidance.

from qiskit import Aer
from qiskit_nature.drivers import PySCFDriver, UnitsType, Molecule
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 = PySCFDriver(molecule = molecule, unit=UnitsType.ANGSTROM, basis='sto3g')

The electronic Hamiltonian written in term of fermionic operators is:

es_problem = ElectronicStructureProblem(driver)
second_q_op = es_problem.second_q_ops()
print(second_q_op[0])

+-+- * (0.18093119978423158+0j)
+ +--+ * (-0.18093119978423156+0j)
+ -++- * (-0.18093119978423156+0j)
+ -+-+ * (0.18093119978423156+0j)
+ IIIN * (-0.47189600728114073+0j)
+ IINI * (-1.2563390730032507+0j)
+ IINN * (0.48365053047106565+0j)
+ INII * (-0.47189600728114073+0j)
+ ININ * (0.6985737227320187+0j)
+ INNI * (0.6645817302552972+0j)
+ NIII * (-1.2563390730032507+0j)
+ NIIN * (0.6645817302552972+0j)
+ NINI * (0.675710154803517+0j)
+ NNII * (0.48365053047106565+0j)

Which can be converted to qubitOp as:

qubit_converter = QubitConverter(JordanWignerMapper())
qubit_op = qubit_converter.convert(second_q_op[0])
print(qubit_op)

-0.8535040737275406 * IIII
- 0.03329093140262394 * ZIII
+ 0.09539931515219398 * IZII
+ 0.08254659792513139 * ZZII
- 0.03329093140262387 * IIZI
+ 0.1460749494329415 * ZIZI
+ 0.13998427822128043 * IZZI
+ 0.09539931515219396 * IIIZ
+ 0.13998427822128043 * ZIIZ
+ 0.1381506045026359 * IZIZ
+ 0.08254659792513139 * IIZZ
+ 0.05743768029614903 * XXXX
+ 0.05743768029614903 * YYXX
+ 0.05743768029614903 * XXYY
+ 0.05743768029614903 * YYYY
$\endgroup$
1
  • 1
    $\begingroup$ Thanks a lot for the answer! Even though this cannot be used interchangeably with FermionicOperator, it seems to be indeed the closest thing to it. $\endgroup$ – A. Jahin May 12 at 22:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.