Using FermionicOperators¶
Fulqrum uses FermionicOperator to describe operators derived from fermionic systems comprised primarily of ladder operators. In reality, the FermionicOperator class shares the same data structures as QubitOperator, and the only real difference comes in the ability to use repeated indices and several different methods attached to the operator. As such, all of the building routines are the same as those for QubitOperator but using the ladder operators + and -
[1]:
import fulqrum as fq
Constructing fermionic operators¶
A simple single-term fermionic operator, here with a width of 14 from an LiH example, can be expressed as:
[2]:
fq.FermionicOperator(14, [("++--", [0, 0, 1, 5], -0.018)])
[2]:
<FermionicOperator[('+:0 +:0 -:1 -:5', (-0.018+0j))], width=14>
If we take the same operator, but reverse the indices, then we get:
[3]:
fq.FermionicOperator(14, [("++--", [5, 1, 0, 0], -0.018)])
[3]:
<FermionicOperator[('-:0 -:0 +:1 +:5', (0.018-0j))], width=14>
Notice that the coefficient has changed sign. This is because the `FermionicOperator`` automatically index sorts the operators from low to high index, and commutation relations will modify signs.
Note that things like creating multi-term operators and combining operators follow in the same manner as QubitOperator
Deflating repeated operator indices¶
In order to convert fermionic systems to qubit representations, we need to “deflate” repeated indices so there is only a single operator associated with each index. As an user you do not need to handle this directly, but here we illustrate this:
[4]:
fop1 = fq.FermionicOperator(14, [("++--", [5, 1, 0, 0], -0.018)])
fop2 = fq.FermionicOperator(14, [("+--+", [0, 0, 8, 13], -0.007)])
fop = fop1 + fop2
A defalted operator is generated using the method:
[5]:
fop.deflate_repeated_indices()
[5]:
<FermionicOperator[('1:0 -:8 +:13', (-0.007+0j))], width=14>
The first term fop1 vanishes because repeated raising or lowering operators yield a zero term, and the second has the zeroth index term collapsed down to a single 1 projection operator.
Fermionic to qubit system transformations¶
Fulqrum solves every system in the qubit representation. Therefore, FermionicOperator Hamiltonians need to be mapped to QubitOperator Hamiltionians. This is done using a Jordan-Wigner transformation over an extended alphabet:
[6]:
fop.extended_jw_transformation()
[6]:
<QubitOperator[('1:0 -:8 Z:9 Z:10 Z:11 Z:12 +:13', (0.007-0j))], width=14, extended=1, group=-1>
We see that the resulting transformation has one term, as expected given fop1 is a zero operator, and that the ladder and projector operators remain, with additional Z operators to maintain the proper commutation relations. No additional Z terms are applied below index 8 because Z*Z=I. Note that there is a sign change in the coefficient.
[ ]: