2014-10-04 09:55:53 +08:00
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
from artiq import *
|
|
|
|
|
|
|
|
|
2014-12-03 18:20:30 +08:00
|
|
|
# data is usually precomputed offline
|
|
|
|
transport_data = dict(
|
|
|
|
t=np.linspace(0, 10, 101), # waveform time
|
|
|
|
u=np.random.randn(101, 4*3*3), # waveform data,
|
|
|
|
# 4 devices, 3 board each, 3 dacs each
|
|
|
|
)
|
|
|
|
|
2015-07-14 04:08:20 +08:00
|
|
|
class Transport(EnvExperiment):
|
2015-03-08 22:43:04 +08:00
|
|
|
"""Transport"""
|
2015-02-21 05:01:34 +08:00
|
|
|
|
2015-07-14 04:08:20 +08:00
|
|
|
def build(self):
|
|
|
|
self.attr_device("core")
|
|
|
|
self.attr_device("bd")
|
|
|
|
self.attr_device("bdd")
|
|
|
|
self.attr_device("pmt")
|
|
|
|
self.attr_device("electrodes")
|
2014-12-03 18:20:30 +08:00
|
|
|
|
2015-07-14 04:08:20 +08:00
|
|
|
self.attr_argument("wait_at_stop", FreeValue(100*us))
|
|
|
|
self.attr_argument("speed", FreeValue(1.5))
|
|
|
|
self.attr_argument("repeats", FreeValue(100))
|
|
|
|
self.attr_argument("nbins", FreeValue(100))
|
2014-10-19 13:09:10 +08:00
|
|
|
|
2015-07-14 04:08:20 +08:00
|
|
|
def calc_waveforms(self, stop):
|
2014-12-03 18:20:30 +08:00
|
|
|
t = transport_data["t"][:stop]*self.speed
|
|
|
|
u = transport_data["u"][:stop]
|
2015-03-23 05:31:59 +08:00
|
|
|
|
|
|
|
self.electrodes.disarm()
|
2014-10-17 00:04:30 +08:00
|
|
|
self.tf = self.electrodes.create_frame()
|
2015-03-23 05:31:59 +08:00
|
|
|
self.tf.create_segment(t, u, name="to_stop")
|
2014-10-04 09:55:53 +08:00
|
|
|
# append the reverse transport (from stop to 0)
|
|
|
|
# both durations are the same in this case
|
2015-03-23 05:31:59 +08:00
|
|
|
self.tf.create_segment(t[-1] - t[::-1], u[::-1], name="from_stop")
|
2014-10-19 13:09:10 +08:00
|
|
|
# distributes frames to the sub-devices in CompoundPDQ2
|
|
|
|
# and uploads them
|
2015-03-23 05:31:59 +08:00
|
|
|
self.electrodes.arm()
|
2014-10-04 09:55:53 +08:00
|
|
|
|
|
|
|
@kernel
|
|
|
|
def cool(self):
|
|
|
|
with parallel:
|
|
|
|
self.bd.pulse(200*MHz, 1*ms)
|
|
|
|
self.bdd.pulse(300*MHz, 1*ms)
|
|
|
|
self.bd.pulse(210*MHz, 100*us)
|
|
|
|
|
|
|
|
@kernel
|
|
|
|
def transport(self):
|
2015-03-23 05:31:59 +08:00
|
|
|
# selects transport frame
|
2014-10-04 09:55:53 +08:00
|
|
|
# triggers pdqs to start transport frame segment
|
|
|
|
# plays the transport waveform from 0 to stop
|
|
|
|
# delay()s the core by the duration of the waveform segment
|
2014-10-17 00:04:30 +08:00
|
|
|
self.tf.to_stop.advance()
|
2014-10-04 09:55:53 +08:00
|
|
|
# leaves the ion in the dark at the transport endpoint
|
|
|
|
delay(self.wait_at_stop)
|
|
|
|
# transport back (again: trigger, delay())
|
2014-10-17 00:04:30 +08:00
|
|
|
# segments can only be advance()ed in order
|
2015-03-23 05:31:59 +08:00
|
|
|
# since this is the last segment, pdq will go back to jump table
|
2014-10-17 00:04:30 +08:00
|
|
|
self.tf.from_stop.advance()
|
2014-10-04 09:55:53 +08:00
|
|
|
|
|
|
|
@kernel
|
|
|
|
def detect(self):
|
|
|
|
with parallel:
|
|
|
|
self.bd.pulse(220*MHz, 100*us)
|
|
|
|
self.pmt.gate_rising(100*us)
|
|
|
|
self.bd.on(200*MHz)
|
|
|
|
self.bdd.on(300*MHz)
|
|
|
|
return self.pmt.count()
|
|
|
|
|
|
|
|
@kernel
|
|
|
|
def one(self):
|
|
|
|
self.cool()
|
|
|
|
self.transport()
|
|
|
|
return self.detect()
|
|
|
|
|
|
|
|
@kernel
|
2015-01-10 15:41:35 +08:00
|
|
|
def repeat(self):
|
|
|
|
self.histogram = [0 for _ in range(self.nbins)]
|
2014-10-04 09:55:53 +08:00
|
|
|
|
2015-01-10 15:41:35 +08:00
|
|
|
for i in range(self.repeats):
|
2014-10-04 09:55:53 +08:00
|
|
|
n = self.one()
|
2015-01-10 15:41:35 +08:00
|
|
|
if n >= self.nbins:
|
|
|
|
n = self.nbins - 1
|
2014-12-19 15:20:19 +08:00
|
|
|
self.histogram[n] += 1
|
2014-10-04 09:55:53 +08:00
|
|
|
|
2015-01-10 15:41:35 +08:00
|
|
|
def scan(self, stops):
|
2014-10-04 09:55:53 +08:00
|
|
|
for s in stops:
|
2014-10-17 00:04:30 +08:00
|
|
|
self.histogram = []
|
2015-07-14 04:08:20 +08:00
|
|
|
# non-kernel, build frames
|
2014-10-04 09:55:53 +08:00
|
|
|
# could also be rpc'ed from repeat()
|
2015-07-14 04:08:20 +08:00
|
|
|
self.calc_waveforms(s)
|
2014-10-04 09:55:53 +08:00
|
|
|
# kernel part
|
2015-01-10 15:41:35 +08:00
|
|
|
self.repeat()
|
2014-10-05 08:25:36 +08:00
|
|
|
# live update 2d plot with current self.histogram
|
|
|
|
# broadcast(s, self.histogram)
|
2014-10-04 09:55:53 +08:00
|
|
|
|
2015-01-10 15:41:35 +08:00
|
|
|
def run(self):
|
2014-10-04 09:55:53 +08:00
|
|
|
# scan transport endpoint
|
2014-12-03 18:20:30 +08:00
|
|
|
stops = range(10, len(transport_data["t"]), 10)
|
2015-01-10 15:41:35 +08:00
|
|
|
self.scan(stops)
|