예제 #1
0
def make5014pulsar(awg):
    awg = awg.name
    pulsar = Pulsar(name='PuLsAr', default_AWG=awg, master_AWG=awg)
    #    pulsar = ps.Pulsar()
    #    pulsar.AWG = AWG
    marker1highs = [2, 2, 2.7, 2, 2, 2, 2.7, 2]
    for i in range(8):
        pulsar.define_channel(id='ch{}'.format(i % 4 + 1),
                              name='ch{}'.format(i + 1),
                              type='analog',
                              high=.7,
                              low=-.7,
                              offset=0.0,
                              delay=0,
                              active=True,
                              AWG=awg)
        pulsar.define_channel(id='ch{}_marker1'.format(i % 4 + 1),
                              name='ch{}_marker1'.format(i + 1),
                              type='marker',
                              high=marker1highs[i],
                              low=0,
                              offset=0.,
                              delay=0,
                              active=True,
                              AWG=awg)
        pulsar.define_channel(id='ch{}_marker2'.format(i % 4 + 1),
                              name='ch{}_marker2'.format(i + 1),
                              type='marker',
                              high=2,
                              low=0,
                              offset=0.,
                              delay=0,
                              active=True,
                              AWG=awg)
    return pulsar
def set_5014pulsar(awg, awg2):
    
    awg = awg.name
    awg2 = awg2.name
    pulsar = Pulsar(name = 'PuLsAr', default_AWG = awg, master_AWG = awg)

    marker1highs = [2, 2, 2, 2, 2, 2, 2, 2]
    for i in range(8):
        pulsar.define_channel(id='ch{}'.format(i%4 + 1),
                              name='ch{}'.format(i + 1), type='analog',
                              high=2, low=-2,
                              offset=0.0, delay=0, active=True, AWG = awg if i<4 else awg2)
        pulsar.define_channel(id='ch{}_marker1'.format(i%4 + 1),
                              name='ch{}_marker1'.format(i + 1),
                              type='marker',
                              high=marker1highs[i], low=0, offset=0.,
                              delay=0, active=True, AWG = awg if i<4 else awg2)
        pulsar.define_channel(id='ch{}_marker2'.format(i%4 + 1),
                              name='ch{}_marker2'.format(i + 1),
                              type='marker',
                              high=2, low=0, offset=0.,
                              delay=0, active=True, AWG = awg if i<4 else awg2)
    return pulsar
def set_5014pulsar():

    pulsar = Pulsar(name='PuLsAr', )

    marker1highs = [2, 2, 2, 2, 2, 2, 2, 2]
    for i in range(8):
        pulsar.define_channel(
            id='ch{}'.format(i + 1),
            name='ch{}'.format(i + 1),
            type='analog',
            high=2,
            low=-2,
            offset=0.0,
            delay=0,
            active=True,
        )
        pulsar.define_channel(
            id='ch{}_marker1'.format(i + 1),
            name='ch{}_marker1'.format(i + 1),
            type='marker',
            high=marker1highs[i],
            low=0,
            offset=0.,
            delay=0,
            active=True,
        )
        pulsar.define_channel(
            id='ch{}_marker2'.format(i + 1),
            name='ch{}_marker2'.format(i + 1),
            type='marker',
            high=2,
            low=0,
            offset=0.,
            delay=0,
            active=True,
        )
    return pulsar
class Test_SingleQubitTek(unittest.TestCase):

    def setUp(self):
        # set up a pulsar with some mock settings for the element
        self.pulsar = Pulsar()
        for i in range(4):
            self.pulsar.define_channel(id='ch{}'.format(i+1),
                                          name='ch{}'.format(i+1),
                                          type='analog',
                                          # max safe IQ voltage
                                          high=.7, low=-.7,
                                          offset=0.0, delay=0, active=True)
            self.pulsar.define_channel(id='ch{}_marker1'.format(i+1),
                                          name='ch{}_marker1'.format(i+1),
                                          type='marker',
                                          high=2.0, low=0, offset=0.,
                                          delay=0, active=True)
            self.pulsar.define_channel(id='ch{}_marker2'.format(i+1),
                                          name='ch{}_marker2'.format(i+1),
                                          type='marker',
                                          high=2.0, low=0, offset=0.,
                                          delay=0, active=True)

        self.pulse_pars = {
            'I_channel': 'ch1',
            'Q_channel': 'ch2',
            'amplitude': .5,
            'amp90_scale': .5,
            'sigma': 10e-9,
            'nr_sigma': 4,
            'motzoi': .8,
            'mod_frequency': 100e-6,
            'pulse_delay': 0,
            'phi_skew': 0,
            'alpha': 1,
            'phase': 0,
            'pulse_type': 'SSB_DRAG_pulse'}

        self.RO_pars = {
            'I_channel': 'ch3',
            'Q_channel': 'ch4',
            'RO_pulse_marker_channel': 'ch3_marker1',
            'amplitude': '.5',
            'length': 300e-9,
            'pulse_delay': 0,
            'mod_frequency': 50e6,
            'fixed_point_frequency': -50e6,
            'acq_marker_delay': 0,
            'acq_marker_channel': 'ch1_marker1',
            'phase': 0,
            'pulse_type': 'MW_IQmod_pulse_tek'}

        station = Bunch(pulsar=self.pulsar)
        sqs.station = station

    def test_ramsey_no_detuning(self):
        times = np.linspace(0, 5e-6, 41)
        f_fix_pt = self.RO_pars['fixed_point_frequency']

        # Sequence with no artificial detuning
        seq, el_list = sqs.Ramsey_seq(times, self.pulse_pars, self.RO_pars,
                                      artificial_detuning=None,
                                      cal_points=True,
                                      verbose=False,
                                      upload=False,
                                      return_seq=True)
        self.assertEqual(len(times), len(seq.elements))
        self.assertEqual(len(times), len(el_list))
        for i, el in enumerate(el_list):
            t_RO = el.effective_pulse_start_time('RO_tone-0', 'ch1')
            t_ROm = el.effective_pulse_start_time('Acq-trigger-0', 'ch1')
            self.assertAlmostEqual(t_RO, t_ROm, places=10)
            # test if fix point put pulses at the right spot.
            self.assertTrue(element.is_divisible_by_clock(t_RO, abs(f_fix_pt)))
            # Check pulse delay
            if i < (len(times)-4):
                t0 = el.effective_pulse_start_time('pulse_0-0', 'ch1')
                t1 = el.effective_pulse_start_time('pulse_1-0', 'ch1')
                self.assertAlmostEqual(t1-t0, times[i], places=10)
                p0 = el.pulses['pulse_0-0']
                self.assertEqual(p0.phase, 0)
                p1 = el.pulses['pulse_1-0']
                self.assertEqual(p1.phase, 0)
            else:
                # Calibration points do not have two pulses
                with self.assertRaises(KeyError):
                    t1 = el.effective_pulse_start_time('pulse_1-0', 'ch1')

    def test_ramsey_freq_detuning(self):
        times = np.linspace(0, 5e-6, 41)
        for f_fix_pt in [50e-6, -50e-6]:
            self.RO_pars['fixed_point_frequency'] = f_fix_pt
            for RO_pulse_type in ['Gated_MW_RO_pulse', 'MW_IQmod_pulse_tek']:
                self.RO_pars['pulse_type'] = RO_pulse_type
                f_detuning = 300e3  # 300 kHz detuning
                # Sequence with artificial detuning specified in Hz
                seq, el_list = sqs.Ramsey_seq(times, self.pulse_pars,
                                              self.RO_pars,
                                              artificial_detuning=f_detuning,
                                              cal_points=True,
                                              verbose=False,
                                              upload=False,
                                              return_seq=True)
                self.assertEqual(len(times), len(seq.elements))
                self.assertEqual(len(times), len(el_list))
                for i, el in enumerate(el_list):
                    if RO_pulse_type == 'MW_IQmod_pulse_tek':
                        t_RO = el.effective_pulse_start_time(
                            'RO_tone-0', 'ch1')
                    else:
                        t_RO = el.effective_pulse_start_time(
                            'RO_marker-0', 'ch1')
                    t_ROm = el.effective_pulse_start_time(
                        'Acq-trigger-0', 'ch1')
                    self.assertAlmostEqual(t_RO, t_ROm, places=10)

                    # test if fix point put pulses at the right spot.
                    self.assertTrue(
                        element.is_divisible_by_clock(t_RO, f_fix_pt))

                    # Check Ramsey pulse spacing
                    if i < (len(times)-4):
                        t0 = el.effective_pulse_start_time(
                            'pulse_0-0', 'ch1')
                        t1 = el.effective_pulse_start_time(
                            'pulse_1-0', 'ch1')
                        self.assertAlmostEqual(t1-t0, times[i], places=10)
                        p0 = el.pulses['pulse_0-0']
                        self.assertEqual(p0.phase, 0)
                        p1 = el.pulses['pulse_1-0']
                        exp_phase = (360*f_detuning*(t1-t0)) % 360
                        if exp_phase == 360:
                            exp_phase = 0
                        self.assertAlmostEqual(p1.phase, exp_phase, places=3)
                    else:
                        # Calibration points do not have two pulses
                        with self.assertRaises(KeyError):
                            t1 = el.effective_pulse_start_time(
                                'pulse_1-0', 'ch1')
예제 #5
0
class Test_SingleQubitTek(unittest.TestCase):
    def setUp(self):
        # set up a pulsar with some mock settings for the element
        self.AWG = VirtualAWG5014('AWG' + str(time.time()))
        self.AWG.clock_freq(1e9)
        self.pulsar = Pulsar('Pulsar' + str(time.time()), self.AWG.name)
        for i in range(4):
            self.pulsar.define_channel(
                id='ch{}'.format(i + 1),
                name='ch{}'.format(i + 1),
                type='analog',
                # max safe IQ voltage
                high=.7,
                low=-.7,
                offset=0.0,
                delay=0,
                active=True)
            self.pulsar.define_channel(id='ch{}_marker1'.format(i + 1),
                                       name='ch{}_marker1'.format(i + 1),
                                       type='marker',
                                       high=2.0,
                                       low=0,
                                       offset=0.,
                                       delay=0,
                                       active=True)
            self.pulsar.define_channel(id='ch{}_marker2'.format(i + 1),
                                       name='ch{}_marker2'.format(i + 1),
                                       type='marker',
                                       high=2.0,
                                       low=0,
                                       offset=0.,
                                       delay=0,
                                       active=True)

        self.pulse_pars = {
            'I_channel': 'ch1',
            'Q_channel': 'ch2',
            'amplitude': .5,
            'amp90_scale': .5,
            'sigma': 10e-9,
            'nr_sigma': 4,
            'motzoi': .8,
            'mod_frequency': 100e-6,
            'pulse_delay': 0,
            'phi_skew': 0,
            'alpha': 1,
            'phase': 0,
            'pulse_type': 'SSB_DRAG_pulse'
        }

        self.RO_pars = {
            'I_channel': 'ch3',
            'Q_channel': 'ch4',
            'operation_type': 'RO',
            'RO_pulse_marker_channel': 'ch3_marker1',
            'amplitude': '.5',
            'length': 300e-9,
            'pulse_delay': 0,
            'mod_frequency': 50e6,
            'acq_marker_delay': 0,
            'acq_marker_channel': 'ch1_marker1',
            'phase': 0,
            'pulse_type': 'MW_IQmod_pulse_tek'
        }

        station = Bunch(pulsar=self.pulsar)
        sqs.station = station

    def test_ramsey_no_detuning(self):
        times = np.linspace(0, 5e-6, 41)

        # Sequence with no artificial detuning
        seq, el_list = sqs.Ramsey_seq(times,
                                      self.pulse_pars,
                                      self.RO_pars,
                                      artificial_detuning=None,
                                      cal_points=True,
                                      verbose=False,
                                      upload=False,
                                      return_seq=True)
        self.assertEqual(len(times), len(seq.elements))
        self.assertEqual(len(times), len(el_list))
        for i, el in enumerate(el_list):
            t_RO = el.effective_pulse_start_time('RO_tone-0', 'ch1')
            t_ROm = el.effective_pulse_start_time('Acq-trigger-0', 'ch1')
            self.assertAlmostEqual(t_RO, t_ROm, places=10)
            # test if fix point put pulses at the right spot.
            self.assertAlmostEqual(t_RO, np.round(t_RO / 1e-6) * 1e-6)
            # Check pulse delay
            if i < (len(times) - 4):
                t0 = el.effective_pulse_start_time('SSB_DRAG_pulse_0-0', 'ch1')
                t1 = el.effective_pulse_start_time('SSB_DRAG_pulse_1-0', 'ch1')
                self.assertAlmostEqual(t1 - t0, times[i], places=10)
                p0 = el.pulses['SSB_DRAG_pulse_0-0']
                self.assertEqual(p0.phase, 0)
                p1 = el.pulses['SSB_DRAG_pulse_1-0']
                self.assertEqual(p1.phase, 0)
            else:
                # Calibration points do not have two pulses
                with self.assertRaises(KeyError):
                    t1 = el.effective_pulse_start_time('pulse_1-0', 'ch1')

    def test_ramsey_freq_detuning(self):
        times = np.linspace(0, 5e-6, 41)
        for f_fix_pt in [50e-6, -50e-6]:
            for RO_pulse_type in ['Gated_MW_RO_pulse', 'MW_IQmod_pulse_tek']:
                self.RO_pars['pulse_type'] = RO_pulse_type
                f_detuning = 300e3  # 300 kHz detuning
                # Sequence with artificial detuning specified in Hz
                seq, el_list = sqs.Ramsey_seq(times,
                                              self.pulse_pars,
                                              self.RO_pars,
                                              artificial_detuning=f_detuning,
                                              cal_points=True,
                                              verbose=False,
                                              upload=False,
                                              return_seq=True)
                self.assertEqual(len(times), len(seq.elements))
                self.assertEqual(len(times), len(el_list))
                for i, el in enumerate(el_list):
                    if RO_pulse_type == 'MW_IQmod_pulse_tek':
                        t_RO = el.effective_pulse_start_time(
                            'RO_tone-0', 'ch1')
                    else:
                        t_RO = el.effective_pulse_start_time(
                            'RO_marker-0', 'ch1')
                    t_ROm = el.effective_pulse_start_time(
                        'Acq-trigger-0', 'ch1')
                    self.assertAlmostEqual(t_RO, t_ROm, places=10)

                    # test if fix point put pulses at the right spot.
                    self.assertAlmostEqual(t_RO, np.round(t_RO / 1e-6) * 1e-6)

                    # Check Ramsey pulse spacing
                    if i < (len(times) - 4):
                        t0 = el.effective_pulse_start_time(
                            'SSB_DRAG_pulse_0-0', 'ch1')
                        t1 = el.effective_pulse_start_time(
                            'SSB_DRAG_pulse_1-0', 'ch1')
                        self.assertAlmostEqual(t1 - t0, times[i], places=10)
                        p0 = el.pulses['SSB_DRAG_pulse_0-0']
                        self.assertEqual(p0.phase, 0)
                        p1 = el.pulses['SSB_DRAG_pulse_1-0']
                        exp_phase = (360 * f_detuning * (t1 - t0)) % 360
                        if exp_phase == 360:
                            exp_phase = 0
                        self.assertAlmostEqual(p1.phase, exp_phase, places=3)
                    else:
                        # Calibration points do not have two pulses
                        with self.assertRaises(KeyError):
                            t1 = el.effective_pulse_start_time(
                                'pulse_1-0', 'ch1')
class Test_Element(unittest.TestCase):

    def setUp(self):
        # set up a pulsar with some mock settings for the element
        self.pulsar = Pulsar()
        for i in range(4):
            self.pulsar.define_channel(id='ch{}'.format(i+1),
                                          name='ch{}'.format(i+1),
                                          type='analog',
                                          # max safe IQ voltage
                                          high=.7, low=-.7,
                                          offset=0.0, delay=0, active=True)
            self.pulsar.define_channel(id='ch{}_marker1'.format(i+1),
                                          name='ch{}_marker1'.format(i+1),
                                          type='marker',
                                          high=2.0, low=0, offset=0.,
                                          delay=0, active=True)
            self.pulsar.define_channel(id='ch{}_marker2'.format(i+1),
                                          name='ch{}_marker2'.format(i+1),
                                          type='marker',
                                          high=2.0, low=0, offset=0.,
                                          delay=0, active=True)

    def test_basic_element(self):
        test_elt = element.Element('test_elt', pulsar=self.pulsar)
        test_elt.add(SquarePulse(name='dummy_square',
                                 channel='ch1',
                                 amplitude=.3, length=20e-9))
        min_samples = 960
        ch1_wf = test_elt.waveforms()[1]['ch1']
        self.assertEqual(len(ch1_wf), min_samples)

        expected_wf = np.zeros(960)
        expected_wf[:20] = .3
        np.testing.assert_array_almost_equal(ch1_wf, expected_wf)

    def test_timing(self):
        test_elt = element.Element('test_elt', pulsar=self.pulsar)
        refpulse = SquarePulse(name='dummy_square',
                               channel='ch1',
                               amplitude=0, length=20e-9)
        test_elt.add(refpulse, start=100e-9, name='dummy_square')

        test_elt.add(SquarePulse(name='dummy_square',
                                 channel='ch1',
                                 amplitude=.3, length=20e-9),
                     refpulse='dummy_square', start=100e-9, refpoint='start')
        min_samples = 960
        ch1_wf = test_elt.waveforms()[1]['ch1']
        self.assertEqual(len(ch1_wf), min_samples)

        expected_wf = np.zeros(960)
        expected_wf[100:120] = .3
        np.testing.assert_array_almost_equal(ch1_wf, expected_wf)

    def test_fixpoint(self):
        # Fixed point should shift both elements by 2 ns
        test_elt = element.Element('test_elt', pulsar=self.pulsar)
        refpulse = SquarePulse(name='dummy_square',
                               channel='ch1',
                               amplitude=.5, length=20e-9)
        test_elt.add(refpulse,  name='dummy_square')

        test_elt.add(SquarePulse(name='dummy_square',
                                 channel='ch1',
                                 amplitude=.3, length=20e-9),
                     fixed_point_freq=-200e6,
                     refpulse='dummy_square', start=98e-9, refpoint='start')
        min_samples = 960
        ch1_wf = test_elt.waveforms()[1]['ch1']
        self.assertEqual(len(ch1_wf), min_samples)

        expected_wf = np.zeros(960)
        expected_wf[2:22] = .5
        expected_wf[100:120] = .3
        np.testing.assert_array_almost_equal(ch1_wf, expected_wf)
예제 #7
0
class Test_Element(unittest.TestCase):

    def setUp(self):
        # set up a pulsar with some mock settings for the element
        self.station = qc.Station()
        self.AWG = VirtualAWG5014('AWG'+str(time.time()))
        self.AWG.clock_freq(1e9)
        self.pulsar = Pulsar('Pulsar' + str(time.time()), self.AWG.name)
        self.station.pulsar = self.pulsar
        for i in range(4):
            self.pulsar.define_channel(id='ch{}'.format(i+1),
                                          name='ch{}'.format(i+1),
                                          type='analog',
                                          # max safe IQ voltage
                                          high=.7, low=-.7,
                                          offset=0.0, delay=0, active=True)
            self.pulsar.define_channel(id='ch{}_marker1'.format(i+1),
                                          name='ch{}_marker1'.format(i+1),
                                          type='marker',
                                          high=2.0, low=0, offset=0.,
                                          delay=0, active=True)
            self.pulsar.define_channel(id='ch{}_marker2'.format(i+1),
                                          name='ch{}_marker2'.format(i+1),
                                          type='marker',
                                          high=2.0, low=0, offset=0.,
                                          delay=0, active=True)

    def test_basic_element(self):
        test_elt = element.Element('test_elt', pulsar=self.pulsar)
        test_elt.add(SquarePulse(name='dummy_square',
                                 channel='ch1',
                                 amplitude=.3, length=20e-9))
        min_samples = 960
        ch1_wf = test_elt.waveforms()[1]['ch1']
        self.assertEqual(len(ch1_wf), min_samples)

        expected_wf = np.zeros(960)
        expected_wf[:20] = .3
        np.testing.assert_array_almost_equal(ch1_wf, expected_wf)

    def test_timing(self):
        test_elt = element.Element('test_elt', pulsar=self.pulsar)
        refpulse = SquarePulse(name='dummy_square',
                               channel='ch1',
                               amplitude=0, length=20e-9)
        test_elt.add(refpulse, start=100e-9, name='dummy_square')

        test_elt.add(SquarePulse(name='dummy_square',
                                 channel='ch1',
                                 amplitude=.3, length=20e-9),
                     refpulse='dummy_square', start=100e-9, refpoint='start')
        min_samples = 960
        ch1_wf = test_elt.waveforms()[1]['ch1']
        self.assertEqual(len(ch1_wf), min_samples)

        expected_wf = np.zeros(960)
        expected_wf[100:120] = .3
        np.testing.assert_array_almost_equal(ch1_wf, expected_wf)

    def test_fixpoint(self):
        # Fixed point should shift both elements by 2 ns
        test_elt = element.Element('test_elt', pulsar=self.pulsar)
        refpulse = SquarePulse(name='dummy_square',
                               channel='ch1',
                               amplitude=.5, length=20e-9)
        test_elt.add(refpulse,  name='dummy_square')

        test_elt.add(SquarePulse(name='dummy_square',
                                 channel='ch1',
                                 amplitude=.3, length=20e-9),
                     operation_type='RO',
                     refpulse='dummy_square', start=98e-9, refpoint='start')
        min_samples = 1020
        ch1_wf = test_elt.waveforms()[1]['ch1']
        self.assertEqual(len(ch1_wf), min_samples)

        expected_wf = np.zeros(1020)
        expected_wf[902:922] = .5
        expected_wf[1000:1020] = .3
        np.testing.assert_array_almost_equal(ch1_wf, expected_wf)

    def test_operation_dependent_buffers_and_compensation(self):
        # Fixed point should shift both elements by 2 ns

        RO_amp = 0.1
        MW_amp = 0.3
        Flux_amp = 0.5
        operation_dict = {'RO q0': {'amplitude': RO_amp,
                                    'length': 300e-9,
                                    'operation_type': 'RO',
                                    'channel': 'ch1',
                                    'pulse_delay': 0,
                                    'pulse_type': 'SquarePulse'},
                          'MW q0': {'amplitude': MW_amp,
                                    'length': 20e-9,
                                    'operation_type': 'MW',
                                    'channel': 'ch1',
                                    'pulse_delay': 0,
                                    'pulse_type': 'SquarePulse'},
                          'Flux q0': {'amplitude': Flux_amp,
                                      'length': 40e-9,
                                      'operation_type': 'Flux',
                                      'channel': 'ch1',
                                      'pulse_delay': 0,
                                      'pulse_type': 'SquarePulse'},

                          'sequencer_config': {'Buffer_Flux_Flux': 1e-9,
                                               'Buffer_Flux_MW': 2e-9,
                                               'Buffer_Flux_RO': 3e-9,
                                               'Buffer_MW_Flux': 4e-9,
                                               'Buffer_MW_MW': 5e-9,
                                               'Buffer_MW_RO': 6e-9,
                                               'Buffer_RO_Flux': 7e-9,
                                               'Buffer_RO_MW': 8e-9,
                                               'Buffer_RO_RO': 10e-9,
                                               'RO_fixed_point': 1e-06,
                                               'Flux_comp_dead_time': 3e-6}}
        sequencer_config = operation_dict['sequencer_config']

        fake_seq = ['MW q0', 'MW q0', 'Flux q0', 'MW q0', 'RO q0']
        pulses = []
        for p in fake_seq:
            pulses += [operation_dict[p]]
        test_elt = multi_pulse_elt(0, self.station, pulses, sequencer_config)

        min_samples = 1800+3040  # 1us fixpoint, 300ns RO pulse and 4ns zeros
        ch1_wf = test_elt.waveforms()[1]['ch1']
        self.assertEqual(len(ch1_wf), min_samples)

        expected_wf = np.zeros(min_samples)
        expected_wf[1000:1300] = RO_amp
        expected_wf[974:994] = MW_amp
        expected_wf[932:972] = Flux_amp
        expected_wf[908:928] = MW_amp
        expected_wf[883:903] = MW_amp
        expected_wf[4300:4340] = -Flux_amp

        np.testing.assert_array_almost_equal(ch1_wf, expected_wf)