Beispiel #1
0
    def test_PiRabi(self):
        controlQ = QubitFactory('q1')
        targetQ = QubitFactory('q2')
        controlQR = QRegister('q1')
        targetQR = QRegister('q2')
        qr = QRegister('q1', 'q2')
        edge = EdgeFactory(controlQ, targetQ)
        lengths = np.linspace(0, 4e-6, 11)
        riseFall = 40e-9
        amp = 1
        phase = 0
        calRepeats = 2

        expected_seq = []
        # Seq1
        for l in lengths:
            expected_seq += [
                qwait(channels=(controlQ, targetQ)),
                Id(controlQ),
                flat_top_gaussian(edge,
                                  riseFall,
                                  length=l,
                                  amp=amp,
                                  phase=phase),
                Barrier(controlQ, targetQ),
                MEAS(controlQ),
                MEAS(targetQ)
            ]
        # Seq2
        for l in lengths:
            expected_seq += [
                qwait(channels=(controlQ, targetQ)),
                X(controlQ),
                flat_top_gaussian(edge,
                                  riseFall,
                                  length=l,
                                  amp=amp,
                                  phase=phase),
                X(controlQ),
                Barrier(controlQ, targetQ),
                MEAS(controlQ),
                MEAS(targetQ)
            ]

        # Add calibration
        calseq = get_cal_seqs_2qubits(controlQ, targetQ, calRepeats)
        expected_seq += calseq
        expected_seq = testable_sequence(expected_seq)

        resFunction = compile_function(
            "src/python/qgl2/basic_sequences/CR.py", "PiRabi",
            (controlQR, targetQR, lengths, riseFall, amp, phase, calRepeats))
        seqs = resFunction()
        seqs = testable_sequence(seqs)

        self.maxDiff = None
        assertPulseSequenceEqual(self, seqs, expected_seq)
Beispiel #2
0
    def test_84_1(self):
        q1 = QubitFactory('q1')
        resFunction = compile_function('test/code/bugs/84.py', 't1')
        seqs = resFunction()
        seqs = testable_sequence(seqs)

        expected_seq = [ X(q1) ]

        # print('\n'.join([str(x) for x in seqs]))
        assertPulseSequenceEqual(self, seqs, expected_seq)
Beispiel #3
0
    def test_classical_break(self):
        resFunction = compile_function("test/code/loops.py", "classical_break")
        seqs = resFunction()

        q1 = QubitFactory('q1')

        expectedseq = [
            X(q1),  # start of ct == 0
            Y90(q1),
            X(q1),  # start of ct == 1
            X90(q1)  # then break
        ]

        assertPulseSequenceEqual(self, seqs, expectedseq)
Beispiel #4
0
    def test_RabiAmp(self):
        q1 = QubitFactory('q1')
        qr = QRegister('q1')
        amps = np.linspace(0, 1, 11)
        phase = 0

        expectedseq = []
        for amp in amps:
            expectedseq += [
                qwait(channels=(q1, )),
                Utheta(q1, amp=amp, phase=phase),
                MEAS(q1)
            ]

        resFunction = compile_function(
            "src/python/qgl2/basic_sequences/RabiMin.py", "doRabiAmp",
            (qr, amps, phase))
        seqs = resFunction()
        seqs = testable_sequence(seqs)
        assertPulseSequenceEqual(self, seqs, expectedseq)
Beispiel #5
0
    def test_RabiWidth(self):
        from qgl2.basic_sequences.pulses import local_tanh
        q1 = QubitFactory('q1')
        qr = QRegister('q1')
        widths = np.linspace(0, 5e-6, 11)

        resFunction = compile_function(
            "src/python/qgl2/basic_sequences/RabiMin.py", "doRabiWidth",
            (qr, widths))
        seqs = resFunction()
        seqs = testable_sequence(seqs)

        expectedseq = []
        for l in widths:
            expectedseq += [
                qwait(channels=(q1, )),
                Utheta(q1, length=l, amp=1, phase=0, shapeFun=local_tanh),
                MEAS(q1)
            ]

        assertPulseSequenceEqual(self, seqs, expectedseq)
Beispiel #6
0
    def test_qft(self):
        q1 = QubitFactory('q1')
        q2 = QubitFactory('q2')
        qr = QRegister('q1', 'q2')

        resFunction = compile_function('test/code/qft.py', 'qft', (qr, ))
        seqs = resFunction()
        seqs = testable_sequence(seqs)

        # expected_seq = [H(q1), CZ_k(q1, q2, pi), H(q2), MEAS(q1), MEAS(q2)]
        expected_seq = [
            H(q1),
            Ztheta(q2, pi / 2),
            CNOT(q1, q2),
            Ztheta(q2, -pi / 2),
            CNOT(q1, q2),
            H(q2),
            MEAS(q1),
            MEAS(q2)
        ]
        expected_seq = testable_sequence(expected_seq)

        assertPulseSequenceEqual(self, seqs, expected_seq)