deuteron_3qbit_exp_openfermion.py 645 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Run this from the command line like this
#
# python3 exp_fermion.py -shots 100

from qcor import *
from openfermion.ops import FermionOperator as FOp

@qjit
def ansatz(q: qreg, x: List[float], exp_args: List[Operator]):
    X(q[0])
    for i, exp_arg in enumerate(exp_args):
        exp_i_theta(q, x[i], exp_args[i])

# Create OpenFermion operators for our quantum kernel...
15
exp_args_openfermion = [FOp('0^ 2') - FOp('2^ 0')]
16
17
18
19
20

# We need to translate OpenFermion ops into qcor Operators to use with kernels...
exp_args_qcor = [createOperator('fermion', fop) for fop in exp_args_openfermion]

ansatz.print_kernel(qalloc(3), [1.0], exp_args_qcor)