interop
eigenkit.chemistry.interop
OpenFermion interop (the optional chemistry extra).
OpenFermion's FermionOperator and QubitOperator share our term structure
exactly — a FermionOperator term is a tuple of (mode, action) with
action 1=creation / 0=annihilation, and a QubitOperator term is a tuple
of (qubit, 'X'|'Y'|'Z') — so the conversions are direct. These adapters let
you (a) bring an OpenFermion-built Hamiltonian onto the spine, and (b) reach
mappings OpenFermion provides (e.g. Bravyi-Kitaev) via our Observable.
The -> conversions read only the .terms mapping (no OpenFermion import
needed); the to_openfermion direction imports OpenFermion lazily.
fermion_operator_from_openfermion(operator)
Convert an openfermion.FermionOperator to an eigenkit FermionOperator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operator
|
FermionOperator
|
The fermionic operator to convert. |
required |
Returns:
| Type | Description |
|---|---|
FermionOperator
|
The same operator, as an eigenkit |
observable_from_openfermion(qubit_operator, *, atol=1e-10)
Convert an openfermion.QubitOperator to an (Observable, offset) pair.
The identity term becomes the real offset. The coefficients must be real,
because the operator must be Hermitian, and a ValueError is raised otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qubit_operator
|
QubitOperator
|
The operator to convert. |
required |
atol
|
float
|
Terms whose coefficient is smaller than this value in magnitude are dropped. |
1e-10
|
Returns:
| Name | Type | Description |
|---|---|---|
observable |
Observable
|
The operator, without its identity term. |
offset |
float
|
The coefficient of the identity term. |
to_openfermion_fermion_operator(operator)
Convert an eigenkit FermionOperator to an openfermion.FermionOperator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operator
|
FermionOperator
|
The fermionic operator to convert. |
required |
Returns:
| Type | Description |
|---|---|
FermionOperator
|
The same operator, in OpenFermion. |