In [4]:
from __future__ import division, print_function, absolute_import, unicode_literals
import numpy as np

import pygsti
from pygsti.extras import circuit
from pygsti.extras import newrb
In [11]:
# A list of standard hard-coded gate labels
gllist = ['I', 'H','P','CPHASE']

# The number of qubits
n = 4

ds = circuit.DeviceSpec(n, gllist, verbosity=0)

# Add a purestate model where the gates are perfect.
operators = {}
for gate in ds.allgates:
    operators[gate] = ds.gateset.unitaries[gate.label]
    
ds.models['Target'] = circuit.GateSetModel(operators,n,mtype='purestate')
In [14]:
c = newrb.construct_grb_circuit(ds,10)
#print(c)
In [15]:
c.simulate(ds.models['Target'])
Out[15]:
{(0, 0, 0, 0): 0.99999999999999112,
 (0, 0, 0, 1): 1.9259299443872303e-34,
 (0, 0, 1, 0): 4.4840195202822085e-34,
 (0, 0, 1, 1): 7.896312771987656e-33,
 (0, 1, 0, 0): 7.9995435634473978e-34,
 (0, 1, 0, 1): 2.5037089277034028e-33,
 (0, 1, 1, 0): 7.8028509789777114e-33,
 (0, 1, 1, 1): 1.9259299443872316e-34,
 (1, 0, 0, 0): 9.4758364535671886e-34,
 (1, 0, 0, 1): 1.7333369499485099e-33,
 (1, 0, 1, 0): 6.5264568939446835e-33,
 (1, 0, 1, 1): 1.9259299443872303e-34,
 (1, 1, 0, 0): 2.2450284656454971e-32,
 (1, 1, 0, 1): 1.9259299443872337e-34,
 (1, 1, 1, 0): 3.9953736408505064e-33,
 (1, 1, 1, 1): 1.2518544638517008e-32}
In [24]:
pm, aux1, aux2 = newrb.simulator.simulate_full_grb_experiment(ds,'Target',[0,10,20,30,40],[1,1,1,1,1],verbosity=0)
print(pm)
[0.99999999999998823, 0.9999999999999869, 0.99999999999998979, 0.99999999999998868, 0.99999999999998557]
In [25]:
pm, aux1, aux2 = newrb.simulator.simulate_full_cliffordrb_experiment(ds,'Target',[0,10,20,30,40],[1,1,1,1,1],verbosity=0)
print(pm)
[1.0, 0.9999999999999174, 0.99999999999984945, 0.99999999999978262, 0.99999999999969114]
In [27]:
# Add a purestate model where the gates are not perfect.
operators = {}
for gate in ds.allgates:
    operators[gate] = ds.gateset.unitaries[gate.label]
    
ds.models['Over-rotations'] = circuit.GateSetModel(operators,n,mtype='purestate')