Schema tiers exampleΒΆ

Experiment

from artiq.experiment import delay, kernel

from atomiq import AtomiqExperiment


class SchemaTiersExample(AtomiqExperiment):
    """Schema Tiers Example.

    Mixed point schema: a scanned float next to constant bool, enumeration and int arguments. Only ``pulse_time`` varies
    per point. The other arguments are fixed for the run, so the kernel reads them from the point as run constants.
    Ints are ``np.int64`` in kernels. The chunk phase reads the constants from ``points`` and iterates the points with
    ``to_list()``.
    """

    components = ["ttl_test"]

    arguments = {
        "pulse_time": {"default": 10e-6, "unit": "us"},
        "invert_pulse": {"default": False},
        "mode": {"options": ["fast", "slow"], "default": "fast"},
        "n": {"default": 2, "type": "int"},
    }

    @kernel
    def step(self, point):
        if point.invert_pulse:
            delay(point.pulse_time)
        if point.mode == "slow":
            delay(point.pulse_time)
        for _ in range(point.n):
            self.ttl_test.pulse(point.pulse_time)
            delay(point.pulse_time)

    @kernel
    def prechunk(self, points):
        # run constants are attributes of the chunk, scanned arguments are read per point
        if points.invert_pulse:
            for point in points.to_list():
                delay(point.pulse_time)
        # ints have the same type (numpy.int64) as chunk attribute and as point attribute, so they share a variable
        n_max = points.n
        for point in points.to_list():
            n_max = max(n_max, point.n)
        delay(n_max * 1e-6)

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"},
        }
    }
)