qrisp.operators.fermionic.FermionicOperator.from_openfermion#

classmethod FermionicOperator.from_openfermion(of_fermionic_hamiltonian)[source]#

Imports a FermionicOperator from OpenFermion.

Parameters:
of_fermionic_operatoropenfermion.FermionOperator

The OpenFermion operator.

Returns:
FermionicOperator

The equivlanet Qrisp operator.

Examples

We load the \(H_2\) molecule from PySCF via OpenFermion and import it into Qrisp:

import openfermion as of
import openfermionpyscf as ofpyscf
# Set molecule parameters
geometry = [("H", (0.0, 0.0, 0.0)), ("H", (0.0, 0.0, 0.8))]
basis = "sto-3g"
multiplicity = 1
charge = 0

# Perform electronic structure calculations and
# obtain Hamiltonian as an InteractionOperator
hamiltonian = ofpyscf.generate_molecular_hamiltonian(
    geometry, basis, multiplicity, charge
)
# Convert to a FermionOperator
hamiltonian_ferm_op = of.get_fermion_operator(hamiltonian)

from qrisp.operators import FermionicOperator
H = FermionicOperator.from_openfermion(hamiltonian_ferm_op)