Mutable arguments exampleΒΆ
Experiment
from artiq.experiment import delay, kernel
from atomiq import AtomiqExperiment
class MutableArgumentsExample(AtomiqExperiment):
"""Mutable Arguments Example.
Arguments marked ``"mutable": True`` are not fixed for the whole run. Their value is read once per chunk, so it
is constant within a chunk and may differ between chunks. This example has one scanned argument, ``pulse_time``,
and a mutable bool, enumeration, int and float argument. Ints are ``np.int64`` in kernels. The kernel reads the
values from the point (``point.NAME``), the chunk phases read them from the chunk (``points.NAME``). Inside a
kernel ``self.NAME`` is the value at compile time and does not follow a change.
``prechunk`` and ``postchunk`` may assign ``points.NAME`` of a mutable argument. The new value persists for the
following chunks, until a phase or a ``update_mutable_arguments`` call changes it again. A ``prechunk`` edit also
applies to the chunk being processed. Here ``prechunk`` limits a chunk to 4 pulses and switches to slow mode, and
``postchunk`` disables the pulses after a slow chunk. The edit persists, so a later ``update_mutable_arguments``
call is needed to enable them again. An enumeration accepts only a string literal or an element of a host list
such as ``_options_NAME[i]``.
"""
components = ["ttl_test"]
arguments = {
"pulse_time": {"default": 10e-6, "unit": "us"},
"enable_pulse": {"default": True, "mutable": True},
"mode": {"options": ["fast", "slow"], "default": "fast", "mutable": True},
"n_pulses": {"default": 2, "type": "int", "mutable": True},
"pause_time": {"default": 5e-6, "unit": "us", "scannable": False, "mutable": True},
}
@kernel
def step(self, point):
if point.enable_pulse:
for _ in range(point.n_pulses):
self.ttl_test.pulse(point.pulse_time)
delay(point.pause_time)
if point.mode == "slow":
delay(point.n_pulses * point.pause_time)
@kernel
def prechunk(self, points):
# mutable arguments are attributes of the chunk, scanned arguments are read per point
if points.mode == "slow":
delay(points.pause_time)
if points.n_pulses > 4:
points.n_pulses = 4
points.mode = "slow"
@kernel
def postchunk(self, points):
if points.mode == "slow":
points.enable_pulse = False
Components
components = {"type": None}
# Add core stuff
components.update(
{
"log": {"classname": "atomiq.components.basics.log.KernelLogger"},
"herosink": {"classname": "atomiq.components.basics.datasink.HEROSink"},
}
)
# Add locks
components.update({"lock_cooler": {"classname": "atomiq.components.lock.ULELock", "arguments": {"lock_offset": 34e6}}})
# Add calibrations
components.update(
{
"cal_pd_cooler": {
"classname": "atomiq.components.basics.calibration.LinearCalibration",
"arguments": {"input_unit": "mV", "output_unit": "mW", "a": 0.342, "b": 0.002},
},
"cal_aom_cooler": {
"classname": "atomiq.components.basics.calibration.InvSigmoidCalibration",
"arguments": {
"input_unit": "amp",
"output_unit": "amp",
"A": 5.0,
"k": 1.0,
"x_offset": 10.0,
"y_offset": 0.3,
},
},
}
)
# Add low level Sinara hardware
components.update(
{
"kasli0": {"classname": "atomiq.components.sinara.Kasli", "arguments": {}},
"sampler0": {
"classname": "atomiq.components.sinara.Sampler",
"arguments": {"sampler_device": "@sampler0", "sampler_default_gain": [1, 0, 0, 0, 0, 0, 0, 0]},
},
"urukul0": {"classname": "atomiq.components.sinara.Urukul", "arguments": {"cpld": "@urukul0_cpld"}},
}
)
# Add low Sinara DIOs
components.update(
{
"ttl_test": {
"classname": "atomiq.components.sinara.DioOutput",
"arguments": {"kasli": "&kasli0", "ttl": "@led0"},
},
"ttl_cool": {
"classname": "atomiq.components.sinara.DioOutput",
"arguments": {"kasli": "&kasli0", "ttl": "@ttl4"},
},
"ttl_repump": {
"classname": "atomiq.components.sinara.DioOutput",
"arguments": {"kasli": "&kasli0", "ttl": "@ttl6"},
},
"ttl_ids_camera": {
"classname": "atomiq.components.sinara.DioOutput",
"arguments": {"kasli": "&kasli0", "ttl": "@ttl5"},
},
}
)
# Add DDS channels
components.update(
{
"dds_cooler": {
"classname": "atomiq.components.sinara.UrukulChannel",
"arguments": {"urukul": "&urukul0", "device": "@urukul0_ch0", "ttl": "@ttl_urukul0_sw0"},
},
"dds_repumper": {
"classname": "atomiq.components.sinara.UrukulChannel",
"arguments": {"urukul": "&urukul0", "device": "@urukul0_ch1", "ttl": "@ttl_urukul0_sw1"},
},
}
)
# Add AOMs
components.update(
{
"aom_cooler": {
"classname": "atomiq.components.optoelectronics.lightmodulator.AOM",
"arguments": {
"rfsource": "&dds_cooler",
"switch": "&dds_cooler",
"center_freq": 80e6,
"switching_delay": 30e-9,
"bandwidth": 5e6,
},
},
"aom_repumper": {
"classname": "atomiq.components.optoelectronics.lightmodulator.AOM",
"arguments": {
"rfsource": "&dds_repumper",
"switch": "&ttl_repump",
"center_freq": 110e6,
"switching_delay": 45e-9,
"bandwidth": 5e6,
},
},
}
)
# Add analog inputs
components.update(
{
"input_cooler_pd": {
"classname": "atomiq.components.sinara.SamplerChannel",
"arguments": {"adc_device": "&sampler0", "channel": 0, "default_gain": 0},
},
"input_dummy": {
"classname": "atomiq.components.electronics.adc.ADCChannel",
"arguments": {
"adc_device": "&adc_dummy0",
"channel": 0,
},
},
}
)
# Add photodiodes
components.update(
{
"pd_cooler": {
"classname": "atomiq.components.optoelectronics.photodiode.CalibratedPhotodiode",
"arguments": {"adc_channel": "&input_cooler_pd", "calibration": "&cal_pd_cooler"},
}
}
)
# Add lasers
components.update(
{
"laser_cooler": {
"classname": "atomiq.components.sinara.BisectionAOMLaser",
"arguments": {"lock": "&lock_cooler", "monitor_pd": "&pd_cooler", "aom": "&aom_cooler"},
}
}
)