Beispiel #1
0
def GeneratePulseSeq(shor7a, shor7b, shor11, a):

    NOP = sim.Delay(params, 0.1)
    if a == 7:
        a2modN = shor7b
        amodN = shor7a
    elif a == 11:
        a2modN = sim.Delay(params, 0.1)
        amodN = shor11

    pulseseq_group = Kit.GeneratePulseSeq(params, NOP, a2modN, amodN)
    return pulseseq_group
def test_heating_detailed(figNum):
    NumberOfIons = 1
    NumberofPhonons = 10
    hspace = sim.hspace(NumberOfIons, 2, NumberofPhonons, 0)
    params = sim.parameters(hspace)
    dec = sim.decoherence(params)

    # since data.RhoPNAll doesn't save phonons, we'll have to simulate sequentially
    numRuns = 5
    phonons = np.zeros(numRuns)

    dec.doRandNtimes = 1
    dec.dict['heating'] = True
    dec.progbar = False
    params.progbar = False
    params.heatingrate = 250
    maxDelay = 1000

    pulseseq = sim.PulseSequence( [ \
        sim.Delay(params, maxDelay), \
        ] )
    widgets = [progbar.Percentage(), ' ', progbar.Bar(), ' ', progbar.ETA()]
    pbar = progbar.ProgressBar(widgets=widgets).start()

    for i in range(numRuns):
        data = qc.simulateevolution(pulseseq, params, dec)
        phonons[i] = qc.indexToState(np.nonzero(data.Yend)[0][0], hspace)[0]
        pbar.update(int(1. * (i + 1) * 100 / numRuns))

    epsilon = np.abs(maxDelay / params.heatingrate - np.mean(phonons))

    return epsilon < 2 * np.std(phonons)  # allow 2 sigma deviation
Beispiel #3
0
    def GeneratePulseSeq(a):
    
        NOP = sim.PulseSequence([sim.Delay(params, 0.1)])

        if a in (2,7,8,13): # hard cases
            if firstMultMap:
                a2modN = cnot24
            else:
                a2modN = times4
        else:               # easy cases
            a2modN = NOP
        
        if   a == 2:
            amodN = times2
        elif a == 7:
            amodN = times7
        elif a == 8:
            amodN = times8
        elif a == 13:
            amodN = times13
        elif a == 4:
            amodN = cnot24
        elif a == 11:
            amodN = cnot13
        elif a == 14:
            amodN = cnot1234

        pulseseq_group = Kit.GeneratePulseSeq(params, [NOP, a2modN, amodN])
        return pulseseq_group
Beispiel #4
0
def doRamseyRun(hspace, params, dec):
    tdelay = np.linspace(0,5000,500)
    YR = np.zeros([len(tdelay),hspace.dimensions], np.complex64)
    pop = np.zeros([len(tdelay),hspace.dimensions], np.complex64)

    widgets = [progbar.Percentage(), ' ', progbar.Bar(),' ', progbar.ETA()]
    pbar = progbar.ProgressBar(widgets=widgets).start()

    for i in range(len(tdelay)):
        pulseseq = sim.PulseSequence( [ \
            sim.Rcar(params, pi/2, 0), \
            sim.Delay(params, tdelay[i]), \
            sim.Rcar(params, pi/2, pi/2) \
            ] )

        data = qc.simulateevolution(pulseseq, params, dec)

        YR[i,:] = data.YR[-1,:]

        pbar.update(int(1.*(i+1)*100/(len(tdelay))))

    data1 = sim.database(tdelay, YR, hspace, pulseseq=None, statesvalid = False)
    data1.tracedpopulation(0)

    [fitfun, par] = doRamseyFit(data1)

    return data1, fitfun, par
def test_dephasing_detailed(figNum):
    NumberOfIons = 1
    NumberofPhonons = 0
    hspace = sim.hspace(NumberOfIons, 2, NumberofPhonons, 0)
    params = sim.parameters(hspace)
    dec = sim.decoherence(params)

    params.coherenceTime = 1000
    params.correlationTime = 0.1
    dec.doRandNtimes = 20
    dec.dict['dephase'] = True
    dec.progbar = False

    params.stepsize = 10
    params.ODEtimestep = 1
    params.detuning = 2 * pi * 0.01  #kHz
    params.progbar = False
    #dec.doPP = True
    #params.use_servers(['local'])
    #dec.doPPprintstats = False

    tdelay = np.linspace(0, 1000, 100)
    YR = np.zeros([len(tdelay), hspace.dimensions], np.complex64)
    pop = np.zeros([len(tdelay), hspace.dimensions], np.complex64)

    widgets = [progbar.Percentage(), ' ', progbar.Bar(), ' ', progbar.ETA()]
    pbar = progbar.ProgressBar(widgets=widgets).start()

    for i in range(len(tdelay)):
        pulseseq = sim.PulseSequence( [ \
            sim.Rcar(params, pi/2, 0), \
            sim.Delay(params, tdelay[i]), \
            sim.Rcar(params, pi/2, pi/2) \
            ] )

        data = qc.simulateevolution(pulseseq, params, dec)
        YR[i, :] = data.YR[-1, :]

        pbar.update(int(1. * (i + 1) * 100 / (len(tdelay))))

    data1 = sim.database(tdelay, YR, hspace, pulseseq=None, statesvalid=False)
    data1.tracedpopulation(figNum)

    # fitting part
    p0 = [0.5, params.detuning, pi / 2, 0.5, params.coherenceTime]
    fitfun = lambda p, x: p[0] * np.cos(p[1] * x + p[2]) * np.exp(-np.log(
        2) * (x / p[4])**2) + p[3]
    errfun = lambda p, x, y: y - fitfun(p, x)
    x = data1.T
    y = data1.YR[:, 0]
    par, covmat, infodict, mesg, ier = leastsq(errfun,
                                               p0,
                                               args=(x, y),
                                               full_output=True)

    epsilon = 100  # with 20 iterations allow 100us offset in coherence time
    #print(par)
    return data1
Beispiel #6
0
def SelectPermutation(select_order, doKitaev):
    if select_order == 0:
        Perm = sim.Delay(params, 0.1)
        Perm2 = sim.Delay(params, 0.1)
        Perm4 = sim.Delay(params, 0.1)
    elif select_order == 1:
        Perm = order1
        Perm2 = sim.Delay(params, 0.1)
        Perm4 = sim.Delay(params, 0.1)
    elif select_order == 2:
        Perm = order2
        Perm2 = sim.Delay(params, 0.1)
        Perm4 = sim.Delay(params, 0.1)
    elif select_order == 3:
        Perm = order31
        if not doKitaev:
            Perm2 = sim.PulseSequence([ \
                sim.Hide(params, 1, False),
                sim.Hide(params, 2, True),
                order32 ])
            Perm4 = sim.PulseSequence([ \
                sim.Hide(params, 2, True),
                sim.Hide(params, 1, True),
                sim.Hide(params, 0, False),
                order34, ])
Beispiel #7
0
    def GeneratePulseSeq(self, params, Perms, perm2=None, perm3=None):

        #Legacy support for old-style calls:
        if perm2 and perm3:
            Perms = [Perms, perm2, perm3]
        ''' generate pulse sequences given all permutations '''\

        self.nOps = len(Perms)
        controlRots = [ \
             [sim.Delay(params, sim.Rac(params, pi/2**(i+1), 0, 0).duration),
              sim.Rac(params, pi/2**(i+1), 0, 0)]
                    for i in range(self.nOps)]

        Hadamard0 = sim.PulseSequence( [ \
                sim.Rcar(params, pi/4, pi),
                sim.Rac(params, pi, 0),
                sim.Rcar(params, pi/4, 0) ])

        def PulseSeqWithControls(ctl):
            # 'ctl' is a bit array of control qubits
            ctlstr = np.binary_repr(ctl).zfill(self.nOps - 1)
            pulseseq = sim.PulseSequence([])

            for k in range(self.nOps):
                pulseseq.append(Hadamard0)
                pulseseq.append(Perms[k])
                pulseseq += [copy.deepcopy(controlRots[i] \
                              [int(ctlstr[self.nOps-i-k-1])]) for i in range(k)]
                pulseseq.append(Hadamard0)

                if k == self.nOps - 1:
                    pulseseq += [ \
                      sim.Hide(params, 1, True),
                      sim.Hide(params, 2, True),
                      sim.MeasInit(params, 0, incl_hidingerr=False) ]
                else:
                    pulseseq += [ \
                      sim.Hide(params, 1, True),
                      sim.Hide(params, 2, True),
                      sim.MeasInit(params, 0),
                      sim.Hide(params, 1, False),
                      sim.Hide(params, 2, False) ]
            return pulseseq

        pulseseq_group = []
        for ctl in range(2**(self.nOps - 1)):
            pulseseq_group.append(PulseSeqWithControls(ctl))

        return pulseseq_group
Beispiel #8
0
    def GeneratePulseSeq(a):

        NOP = sim.PulseSequence([sim.Delay(params, 0.1)])

        if a in (2, 5, 16, 19):  # a^2=4 cases
            if firstMultMap:
                a16modN = cnot15
            else:
                a16modN = times16
            a8modN = times4
            a4modN = times16
            a2modN = times4
            if a == 16:
                a1modN = times16
            else:
                a1modN = cnot24  # only cheating method implimented...

        elif a in (4, 10, 11, 17):  # a^2=16 cases
            if firstMultMap:
                a16modN = cnot13
            else:
                a16modN = times4
            a8modN = times16
            a4modN = times4
            a2modN = times16
            if a == 4:
                a1modN = times4
            else:
                a1modN = cnot24  # only cheating method implimented...

        elif a in (8, 13):
            a16modN = NOP
            a8modN = NOP
            a4modN = NOP
            a2modN = NOP
            if a == 8:
                a1modN = cnot25
            elif a == 13:
                a1modN = cnot23

        oplist = [a16modN, a8modN, a4modN, a2modN, a1modN]

        pulseseq_group = Kit.GeneratePulseSeq(params, oplist)
        return pulseseq_group
def test_spontdecay_detailed(figNum):
    NumberOfIons = 1
    NumberofPhonons = 1
    hspace = sim.hspace(NumberOfIons, 2, NumberofPhonons, 0)
    params = sim.parameters(hspace)
    dec = sim.decoherence(params)

    dec.doRandNtimes = 100
    dec.dict['spontdecay'] = True
    dec.doPP = True
    dec.doPPprintstats = False
    dec.progbar = False
    # for the test we set it to 300 mus, instead of 1.168 s
    params.lifetime = 300

    params.y0[qc.stateToIndex(NumberOfIons * 'D' + ',0', hspace)] = 1
    params.y0[qc.stateToIndex(NumberOfIons * 'S' + ',0', hspace)] = 0

    pulseseq = sim.PulseSequence( [ \
        sim.Delay(params, 1000), \
        ] )

    data = qc.simulateevolution(pulseseq, params, dec)
    data.tracedpopulation(figNum)

    # fitting part
    p0 = [1, params.lifetime]
    fitfun = lambda p, x: p[0] * np.exp(-x / float(p[1]))
    errfun = lambda p, x, y: y - fitfun(p, x)
    x = data.T
    y = data.YtrN[:, 0]
    par, covmat, infodict, mesg, ier = leastsq(errfun,
                                               p0,
                                               args=(x, y),
                                               full_output=True)

    epsilon = 50  # with 100 iterations allow 50us offset in decay time

    #    print(np.abs(par[-1] - params.lifetime))
    return np.abs(par[-1] - params.lifetime) < epsilon
Beispiel #10
0
def GeneratePulseSeq(a):

    NOP = lambda: sim.PulseSequence([sim.Delay(params, 0.1)])

    if a in (2, 7, 8, 13):  # hard cases
        if firstMultMap:
            a2modN = cnotij(2, 4)
        else:
            a2modN = sim.PulseSequence([ \
                sim.Hide(params, 1, True),
                sim.Hide(params, 3, True), #vis: 2,4
                Fredij(2,4),
                sim.Hide(params, 1, False),
                sim.Hide(params, 3, False),
                sim.Hide(params, 2, True),
                sim.Hide(params, 4, True), #vis: 1,3
                Fredij(1,3),
                sim.Hide(params, 2, False),
                sim.Hide(params, 4, False)
                ])
    else:  # easy cases
        a2modN = NOP()

    if a == 4:
        amodN = cnotij(2, 4)
    elif a == 11:
        amodN = cnotij(1, 3)
    elif a == 14:
        amodN = cnot1234()
    elif a in (8, 13):
        amodN = sim.PulseSequence([ \
            sim.Hide(params, 1, True),
            sim.Hide(params, 2, True), #vis: 3,4
            Fredij(3,4),
            sim.Hide(params, 2, False),
            sim.Hide(params, 4, True), #vis: 2,3
            Fredij(2,3),
            sim.Hide(params, 1, False),
            sim.Hide(params, 3, True), #vis: 1,2
            Fredij(1,2),
            sim.Hide(params, 3, False),
            sim.Hide(params, 4, False)
            ])
    elif a in (2, 7):
        amodN = sim.PulseSequence([ \
            sim.Hide(params, 3, True),
            sim.Hide(params, 4, True), #vis: 1,2
            Fredij(1,2),
            sim.Hide(params, 3, False),
            sim.Hide(params, 1, True), #vis: 2,3
            Fredij(2,3),
            sim.Hide(params, 4, False),
            sim.Hide(params, 2, True), #vis: 3,4
            Fredij(3,4),
            sim.Hide(params, 1, False),
            sim.Hide(params, 2, False) #vis: 1,2,3,4
            ])

    if a in (7, 13):
        amodN.append(cnot1234())

    # if   a == 2:
    #     amodN = times2
    # elif a == 7:
    #     # amodN = times7
    #     amodN = copy.deepcopy(times2)
    #     amodN.append(cnot1234)
    # elif a == 8:
    #     amodN = times8
    # elif a == 13:
    #     # amodN = times13
    #     amodN = copy.deepcopy(times8)
    #     amodN.append(cnot1234)
    # elif a == 4:
    #     amodN = cnot24
    # elif a == 11:
    #     amodN = cnot13
    # elif a == 14:
    #     amodN = cnot1234

    pulseseq_group = Kit.GeneratePulseSeq(params, [NOP(), a2modN, amodN])
    return pulseseq_group
Beispiel #11
0
                sim.Hide(params, 1, True),
                sim.Hide(params, 0, False),
                order34, ])
        else:
            Perm2 = order32
            Perm4 = order34
    elif select_order == 4:
        Perm = order4
        if not doKitaev:
            Perm2 = sim.PulseSequence([ \
                sim.Hide(params, 1, False),
                sim.Hide(params, 2, True),
                order42 ])
        else:
            Perm2 = order42
        Perm4 = sim.Delay(params, 0.1)

    return Perm, Perm2, Perm4

### general pulse sequence
def GeneratePulseSeq(Perm, Perm2, Perm4, QFTseq, doKitaev):
    if not doKitaev:
        pulseseq = sim.PulseSequence([ \
            sim.Hide(params, 3, True),
            sim.Hide(params, 4, True),
            sim.Rcar(params, pi/2, -pi/2),
            sim.Hide(params, 3, False),
            sim.Hide(params, 4, False),
            sim.Hide(params, 0, True),
            sim.Hide(params, 1, True,),
            Perm,