Example #1
0
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
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
Example #3
0
def test_ProcTomo_detailed():
    NumberOfIons = 1
    PhononOverhead = 7

    hspace = sim.hspace(NumberOfIons, 2, NumberOfIons + PhononOverhead, 0)
    params = sim.parameters(hspace)
    dec = sim.decoherence(params)

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

    pulseseq = sim.PulseSequence( [ \
        sim.Rcar(params, pi/2,0),
        ] )

    ScanObj = IPS.ScanParameter_in_Sequence(pulseseq,
                                            params,
                                            dec,
                                            np.arange(12**NumberOfIons),
                                            type='ProcTomo')

    ScanObj.runScan()
    data_proctom = ScanObj.output_dict['qstates_camera']
    chi = proctom.proctomo(data_proctom, 100)
    #if np.real(chi[0,0]) > 0.99:
    #    print 'proctomo passed'

    chiId = qproc.Unitary2Chi(pulseseq[0].Uidtr.conjugate())
    return np.max(abs(chi - chiId)) < 0.001
Example #4
0
def test_StateTomo_detailed():
    NumberOfIons = 2
    PhononOverhead = 1

    hspace = sim.hspace(NumberOfIons, 2, NumberOfIons + PhononOverhead, 0)
    params = sim.parameters(hspace)
    dec = sim.decoherence(params)

    params.y0[qc.stateToIndex('SS,0', hspace)] = 1

    pulseseq = sim.PulseSequence( [ \
        sim.Rcar(params, 2*pi, 0, 0), \
        ] )

    ScanObj = IPS.ScanParameter_in_Sequence(pulseseq,
                                            params,
                                            dec,
                                            np.arange(3**NumberOfIons),
                                            type='StateTomo')

    ScanObj.runScan()
    data_dmr = ScanObj.output_dict['qstates_camera']
    rho = dmr.IterML.iterfun(data_dmr, 100)
    #if np.real(rho[3,3]) > 0.99:
    #    print 'statetomo passed'

    return np.real(rho[3, 3]) > 0.99
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
def test_ACStark_detailed(figNum):
    NumberOfIons = 1
    hspace = sim.hspace(NumberOfIons,2,0,0)
    params = sim.parameters(hspace)
    dec = sim.decoherence(params)

    params.progbar = False

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

    ACtime = np.linspace(0,10*pi,100)
    realtime = np.zeros_like(ACtime)

    YR = np.zeros([len(ACtime), hspace.dimensions], dtype='complex')

    for i in range(len(ACtime)):
        pulseseq[1] = sim.Rac(params, ACtime[i], 0, 0)
        realtime[i] = pulseseq[1].duration
        data = qc.simulateevolution(pulseseq, params, dec)
        YR[i,:] = data.YR[-1,:]


    data1 = sim.database(realtime, YR, hspace, statesvalid = False)
    data1.tracedpopulation(figNum)

    # start with fit here
    x = data1.T
    y = data1.YtrN.transpose()[0] # this is the s-state population

    # p[0] ... amplitude, should be 1
    # p[1] ... freq, should be params.omc
    # p[2] ... phase, should be 0
    # p[3] ... offset, should be 0

    startparams = np.array([1, params.omac, 0, 0])

    # 1-data ... to get the D-state population
    fitfun = lambda p, x: 1-p[0]*np.sin(p[1]*x/2+p[2])**2 + p[3]
    errfun = lambda p, x, y: y-fitfun(p,x)

    par, covmat, infodict, mesg, ier = leastsq(errfun, startparams, args=(x,y), full_output = True)

    epsilon = 10**-3
    if par[0] - startparams[0] > epsilon:
        print("amplitude of AC oscillations wrong")
    if par[1] - startparams[1] > epsilon:
        print("frequency of AC oscillations wrong")
    if par[2] - startparams[2] > epsilon:
        print("phase of AC oscillations wrong")
    if par[3] - startparams[3] > epsilon:
        print("offset of AC oscillations wrong")

    return np.all(par-startparams < epsilon), data1, fitfun, par, startparams
Example #7
0
def test_ACStark_detailed(figNum):
    NumberOfIons = 1
    hspace = sim.hspace(NumberOfIons,2,0,0)
    params = sim.parameters(hspace)
    dec = sim.decoherence(params)

    params.progbar = False

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

    ACtime = np.linspace(0,10*pi,100)
    realtime = np.zeros_like(ACtime)

    YR = np.zeros([len(ACtime), hspace.dimensions], dtype='complex')

    for i in range(len(ACtime)):
        pulseseq[1] = sim.Rac(params, ACtime[i], 0, 0)
        realtime[i] = pulseseq[1].duration
        data = qc.simulateevolution(pulseseq, params, dec)
        YR[i,:] = data.YR[-1,:]


    data1 = sim.database(realtime, YR, hspace, statesvalid = False)
    data1.tracedpopulation(figNum)

    # start with fit here
    x = data1.T
    y = data1.YtrN.transpose()[0] # this is the s-state population

    # p[0] ... amplitude, should be 1
    # p[1] ... freq, should be params.omc
    # p[2] ... phase, should be 0
    # p[3] ... offset, should be 0

    startparams = np.array([1, params.omac, 0, 0])

    # 1-data ... to get the D-state population
    fitfun = lambda p, x: 1-p[0]*np.sin(p[1]*x/2+p[2])**2 + p[3]
    errfun = lambda p, x, y: y-fitfun(p,x)

    par, covmat, infodict, mesg, ier = leastsq(errfun, startparams, args=(x,y), full_output = True)

    epsilon = 10**-3
    if par[0] - startparams[0] > epsilon:
        print "amplitude of AC oscillations wrong"
    if par[1] - startparams[1] > epsilon:
        print "frequency of AC oscillations wrong"
    if par[2] - startparams[2] > epsilon:
        print "phase of AC oscillations wrong"
    if par[3] - startparams[3] > epsilon:
        print "offset of AC oscillations wrong"

    return np.all(par-startparams < epsilon), data1, fitfun, par, startparams
def test_Rabi_carrier_detailed(figNum):
    #print(TestUserFUnction.figNum, TestUserFunction.figNum_start, "<<<<")
    NumberOfIons = 1
    PhononOverhead = 2

    hspace = sim.hspace(NumberOfIons,2,NumberOfIons+PhononOverhead,0)
    params = sim.parameters(hspace)
    params.stepsize = 1
    dec = sim.decoherence(params)

    params.y0[qc.stateToIndex('S,0', hspace)] = 1
    params.printpulse = False # don't print pulse details

    pulseseq = sim.PulseSequence( [
        sim.Rcar(params, 10*pi, 0, -1)
        ] )

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

    data.tracedpopulation(figNum)

    # start with fit here
    x = data.T
    y = data.YtrN.transpose()[0] # this is the s-state population

    # p[0] ... amplitude, should be 1
    # p[1] ... freq, should be params.omc
    # p[2] ... phase, should be 0
    # p[3] ... offset, should be 0

    startparams = np.array([1, params.omc, 0, 0])

    # 1-data ... to get the D-state population
    fitfun = lambda p, x: 1-p[0]*np.sin(p[1]*x/2+p[2])**2 + p[3]
    errfun = lambda p, x, y: y-fitfun(p,x)

    par, covmat, infodict, mesg, ier = leastsq(errfun, startparams, args=(x,y), full_output = True)

    #print(startparams)
    #print(par)

    #print(startparams-par)

    epsilon = 10**-5
    if par[0] - startparams[0] > epsilon:
        print("amplitude of Rabi oscillations wrong")
    if par[1] - startparams[1] > epsilon:
        print("frequency of Rabi oscillations wrong")
    if par[2] - startparams[2] > epsilon:
        print("phase of Rabi oscillations wrong")
    if par[3] - startparams[3] > epsilon:
        print("offset of Rabi oscillations wrong")


    return np.all(par-startparams < epsilon)
Example #9
0
def test_Rabi_carrier_detailed(figNum):
    #print TestUserFUnction.figNum, TestUserFunction.figNum_start, "<<<<"
    NumberOfIons = 1
    PhononOverhead = 2

    hspace = sim.hspace(NumberOfIons,2,NumberOfIons+PhononOverhead,0)
    params = sim.parameters(hspace)
    params.stepsize = 1
    dec = sim.decoherence(params)

    params.y0[qc.stateToIndex('S,0', hspace)] = 1
    params.printpulse = False # don't print pulse details

    pulseseq = sim.PulseSequence( [
        sim.Rcar(params, 10*pi, 0, -1)
        ] )

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

    data.tracedpopulation(figNum)

    # start with fit here
    x = data.T
    y = data.YtrN.transpose()[0] # this is the s-state population

    # p[0] ... amplitude, should be 1
    # p[1] ... freq, should be params.omc
    # p[2] ... phase, should be 0
    # p[3] ... offset, should be 0

    startparams = np.array([1, params.omc, 0, 0])

    # 1-data ... to get the D-state population
    fitfun = lambda p, x: 1-p[0]*np.sin(p[1]*x/2+p[2])**2 + p[3]
    errfun = lambda p, x, y: y-fitfun(p,x)

    par, covmat, infodict, mesg, ier = leastsq(errfun, startparams, args=(x,y), full_output = True)

    #print startparams
    #print par

    #print startparams-par

    epsilon = 10**-5
    if par[0] - startparams[0] > epsilon:
        print "amplitude of Rabi oscillations wrong"
    if par[1] - startparams[1] > epsilon:
        print "frequency of Rabi oscillations wrong"
    if par[2] - startparams[2] > epsilon:
        print "phase of Rabi oscillations wrong"
    if par[3] - startparams[3] > epsilon:
        print "offset of Rabi oscillations wrong"


    return np.all(par-startparams < epsilon)
Example #10
0
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
def test_state_initialisation_detailed(figNum):
    NumberOfIons = 1
    NumberOfPhonons = 1

    hspace = sim.hspace(NumberOfIons, 2, NumberOfPhonons, 0)
    params = sim.parameters(hspace)
    params.stateiniterr = 0.2

    dec = sim.decoherence(params)

    dec.doPP = False
    dec.progbar = False
    dec.doRandNtimes = 10
    dec.dict['initerr'] = True

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

    pulseseq = sim.PulseSequence( [ \
        sim.Rcar(params, 5*pi, 0),
        ] )

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

    # start with fit here
    x = data.T
    y = data.YtrN.transpose()[-1]  # this is the d-state population

    # p[0] ... amplitude, should be 0.8
    # p[1] ... freq, should be params.omc
    # p[2] ... phase, should be 0
    # p[3] ... offset, should be 0

    startparams = np.array([0.8, params.omc, 0, 0])

    # 1-data ... to get the D-state population
    fitfun = lambda p, x: p[0] * np.sin(p[1] * x / 2 + p[2])**2 + p[3]
    errfun = lambda p, x, y: y - fitfun(p, x)

    par, covmat, infodict, mesg, ier = leastsq(errfun,
                                               startparams,
                                               args=(x, y),
                                               full_output=True)
    #    print(par)

    # even for the 1000 realisations, allow for a 3% error
    epsilon = 0.03
    return abs(abs(par[0]) - startparams[0]) < epsilon
Example #12
0
def test_state_initialisation_detailed(figNum):
    NumberOfIons = 1
    NumberOfPhonons = 1

    hspace = sim.hspace(NumberOfIons,2,NumberOfPhonons,0)
    params = sim.parameters(hspace)
    params.stateiniterr = 0.2

    dec = sim.decoherence(params)

    dec.doRandNtimes = 1000
    dec.dict['initerr'] = True

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

    pulseseq = sim.PulseSequence( [ \
        sim.Rcar(params, 5*pi, 0),
        ] )

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

    # start with fit here
    x = data.T
    y = data.YtrN.transpose()[-1] # this is the d-state population

    # p[0] ... amplitude, should be 0.8
    # p[1] ... freq, should be params.omc
    # p[2] ... phase, should be 0
    # p[3] ... offset, should be 0

    startparams = np.array([0.8, params.omc, 0, 0])

    # 1-data ... to get the D-state population
    fitfun = lambda p, x: p[0]*np.sin(p[1]*x/2+p[2])**2 + p[3]
    errfun = lambda p, x, y: y-fitfun(p,x)

    par, covmat, infodict, mesg, ier = leastsq(errfun, startparams, args=(x,y), full_output = True)
#    print par

    # even for the 1000 realisations, allow for a 3% error
    epsilon = 0.03
    return abs(abs(par[0])-startparams[0]) < epsilon
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
Example #14
0
def test_StateTomo_detailed():
    NumberOfIons = 2
    PhononOverhead = 1

    hspace = sim.hspace(NumberOfIons,2,NumberOfIons+PhononOverhead,0)
    params = sim.parameters(hspace)
    dec = sim.decoherence(params)

    params.y0[qc.stateToIndex('SS,0', hspace)] = 1

    pulseseq = sim.PulseSequence( [ \
        sim.Rcar(params, 2*pi, 0, 0), \
        ] )

    ScanObj = IPS.ScanParameter_in_Sequence(pulseseq, params, dec, np.arange(3**NumberOfIons), type = 'StateTomo')

    ScanObj.runScan()
    data_dmr = ScanObj.output_dict['qstates_camera']
    rho = dmr.IterML.iterfun(data_dmr, 100)
    #if np.real(rho[3,3]) > 0.99:
    #    print 'statetomo passed'

    return np.real(rho[3,3]) > 0.99
Example #15
0
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
Example #16
0
def test_ProcTomo_detailed():
    NumberOfIons = 1
    PhononOverhead = 7

    hspace = sim.hspace(NumberOfIons,2,NumberOfIons+PhononOverhead,0)
    params = sim.parameters(hspace)
    dec = sim.decoherence(params)

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

    pulseseq = sim.PulseSequence( [ \
        sim.Rcar(params, pi/2,0),
        ] )

    ScanObj = IPS.ScanParameter_in_Sequence(pulseseq, params, dec, np.arange(12**NumberOfIons), type = 'ProcTomo')

    ScanObj.runScan()
    data_proctom = ScanObj.output_dict['qstates_camera']
    chi = proctom.proctomo(data_proctom, 100)
    #if np.real(chi[0,0]) > 0.99:
    #    print 'proctomo passed'

    chiId = qproc.Unitary2Chi(pulseseq[0].Uidtr.conjugate())
    return np.max(abs(chi - chiId)) < 0.001
Example #17
0
def test_Ramsey_carrier_detailed(figNum):
    NumberOfIons = 1
    PhononOverhead = 2

    hspace = sim.hspace(NumberOfIons,2,NumberOfIons+PhononOverhead,0)
    params = sim.parameters(hspace)
    dec = sim.decoherence(params)

    params.y0[qc.stateToIndex('S,0', hspace)] = 1
    params.stepsize = 1
    params.printpulse = False # don't print pulse details

    numberofpoints = 20
    phi = np.linspace(0, 2*pi, numberofpoints)
    ex = np.zeros(numberofpoints)

    for i in range(numberofpoints):
        pulseseq = sim.PulseSequence( [
            sim.Rcar(params, pi/2, 0, -1),
#            sim.Delay(params, tdelay[i]),
            sim.Rcar(params, pi/2, phi[i], -1)
            ])

        data = qc.simulateevolution(pulseseq, params, dec)
        data.tracedpopulation(figNum)
        ex[i] = data.YtrN[-1,0]

    # fig1 = pl.figure(1)
    # ax1 = fig1.add_subplot(111)
    # ax1.plot(phi, ex)
    # fig1.show()


    # p[0] ... amplitude, should be 1
    # p[1] ... because phase is in units of pi -> 1
    # p[2] ... phase, should be 0
    # p[3] ... offset, should be 0.5

    startparams = np.array([1, 1, 0, 0.5])

    # 1-data ... to get the D-state population
    fitfun = lambda p, x: p[0]/2*np.cos(p[1]*x+p[2]) + p[3]
    errfun = lambda p, x, y: y-fitfun(p,x)

    par, covmat, infodict, mesg, ier = leastsq(errfun, startparams, args=(phi,ex), full_output = True)

    #print(startparams)
    #print(par)

    #print(startparams-par)

    epsilon = 10**-5

    if par[0] - startparams[0] > epsilon:
        print("amplitude of Ramsey experiment wrong")
    if par[1] - startparams[1] > epsilon:
        print("frequency of Ramsey experiment wrong")
    if par[2] - startparams[2] > epsilon:
        print("phase of Ramsey experiment wrong")
    if par[3] - startparams[3] > epsilon:
        print("offset of Ramsey experiment wrong")


    return np.all(par-startparams < epsilon)
    import PyTIQC.core.simtools as sim
    import PyTIQC.core.qctools as qc

    pi = np.pi

    runStateTomo = False
    runStateTomoPP = False
    runProcTomo = False
    runProcTomoPP = True

    if runStateTomo or runStateTomoPP:
        NumberOfIons = 2
        PhononOverhead = 1

        hspace = sim.hspace(NumberOfIons,2,NumberOfIons+PhononOverhead,0)
        params = sim.parameters(hspace)
        dec = sim.decoherence(params)
        params.use_servers(['lindhard'])

        pulseseq = sim.PulseSequence( [ \
          sim.Rcar(params, 2*pi, 0, 0),
        ] )

        if runStateTomo:
            ScanObj = ScanParameter_in_Sequence(pulseseq, params, dec, np.arange(3**NumberOfIons), type='StateTomo', verbose=True)
        elif runStateTomoPP:
            ScanObj = ScanParameter_in_Sequence(pulseseq, params, dec, np.arange(3**NumberOfIons), type='StateTomo', verbose=True, doPP=True, use_ideal=True)

        ScanObj.runScan()

        data_dmr = ScanObj.output_dict['qstates_camera']
Example #19
0
''' Cirac-Zoller CNOT '''

import numpy as np
import PyTIQC.core.simtools as sim
import PyTIQC.core.qctools as qc

pi = np.pi

hspace = sim.hspace(2,2,2,0)
params = sim.parameters(hspace)
dec = sim.decoherence(params)

params.y0[qc.stateToIndex('SS,0', hspace)] = 1
params.stepsize = 10
params.ignorelightshift = 1
#params.addressing = np.array([[1,0.1],[0.1,1]])

ang = np.arccos(-np.real(np.exp(pi/2*1j*np.sqrt(2))));
pulseseq = sim.PulseSequence( [ \
    sim.Rblue(params, pi, 0, 0), \
    sim.Rcar(params, pi/2, 0, 1), \
    sim.Rblue(params, pi/2, 0, 1), \
    sim.Rblue(params, np.sqrt(2)*pi, pi/2, 1), \
    sim.Rblue(params, pi/2, pi, 1), \
    sim.Rcar(params, pi/2, pi + ang, 1), \
    sim.Rblue(params, pi, 0, 0) \
    ] )

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

data.displaypopulation(1)
Example #20
0
def main():
    ### run params ##################################
    pulseseqfileShor = 'experiments/Shorseq.py'
   
    firstMultMap = True # Do first multiplication with CNOT 
                        # mapping instead of Multiplier 
                        # (does nothing in easy cases)
    select_a = 7 # Factoring base: 2, 4, 7, 8, 13, 11, or 14

    doRun = True
    doIdeal = True
    printpulse = False
    saveKitaev = False
    doPPKitaev = True

    print 'a =',select_a
    
    NumberOfIons = 5
    NumberOfPhonons = 0 if doIdeal else 7 
    hspace = sim.hspace(NumberOfIons,2,NumberOfPhonons,0)
    hspace.initial_state("quantum", qstate='DSSSS')
    params = sim.parameters(hspace)
    
    params.use_servers( ['all'] )
    params.ppcpus = 16
    params.shortestMS = 16
    params.calcPulseParams()
    params.progbar = True
    params.saveallpoints = False
    params.coherenceTime = 15000
    params.hidingerr = 1
    
    params.printpulse = printpulse
    params.progbar = printpulse
    params.pplog = False
    
    dec = sim.decoherence(params)
    dec.doRandNtimes = 16
    dec.doPP = True
    dec.dict['all'] = True
#    if doPPKitaev: params.ppcpus = 2
    
    Kit = Kitaev.Kitaev()
    
    ##########################################
    # load the pulse sequences
    # change ion order and define permutations
    ##########################################
    execfile(pulseseqfileShor,locals(),globals())

    Fred12 = copy.deepcopy(Fredkin)
    Fred23 = copy.deepcopy(Fredkin)
    Fred34 = copy.deepcopy(Fredkin)
    Fred24 = copy.deepcopy(Fredkin)
    Fred13 = copy.deepcopy(Fredkin)
    Fred12.changeions(params, (1,2,0))
    Fred23.changeions(params, (2,3,0))
    Fred34.changeions(params, (3,4,0))
    Fred24.changeions(params, (2,4,0))
    Fred13.changeions(params, (1,3,0))
   
    cnot13 = copy.deepcopy(cnot12)
    cnot24 = copy.deepcopy(cnot12)
    cnot13.changeions(params,(0,1,3))
    cnot24.changeions(params,(0,2,4))

    times2 = sim.PulseSequence([ \
        sim.Hide(params, 3, True),
        sim.Hide(params, 4, True), #vis: 1,2
        Fred12,
        sim.Hide(params, 3, False),
        sim.Hide(params, 1, True), #vis: 2,3
        Fred23,
        sim.Hide(params, 4, False),
        sim.Hide(params, 2, True), #vis: 3,4
        Fred34,
        sim.Hide(params, 1, False),
        sim.Hide(params, 2, False) #vis: 1,2,3,4
        ])

    times4 = sim.PulseSequence([ \
        sim.Hide(params, 1, True),
        sim.Hide(params, 3, True), #vis: 2,4
        Fred24,
        sim.Hide(params, 1, False),
        sim.Hide(params, 3, False),
        sim.Hide(params, 2, True),
        sim.Hide(params, 4, True), #vis: 1,3
        Fred13,
        sim.Hide(params, 2, False),
        sim.Hide(params, 4, False)
        ])

    times8 = sim.PulseSequence([ \
        sim.Hide(params, 1, True),
        sim.Hide(params, 2, True), #vis: 3,4
        Fred34,
        sim.Hide(params, 2, False),
        sim.Hide(params, 4, True), #vis: 2,3
        Fred23,
        sim.Hide(params, 1, False),
        sim.Hide(params, 3, True), #vis: 1,2
        Fred12,
        sim.Hide(params, 3, False),
        sim.Hide(params, 4, False)
        ])

    times13 = copy.deepcopy(times8)
    times13.append(cnot1234)

    times7 = copy.deepcopy(times2)
    times7.append(cnot1234)


    ### general pulse sequence
    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
    
    #######################################################
    
    pulseseq = GeneratePulseSeq(select_a)
    
    if doIdeal:
        for ps in pulseseq:
            for pulse in ps:
                pulse.use_ideal = True
    
    ### run it
    if doRun:
        tic = time.time()
        result = Kit.simulateevolution(pulseseq, params, dec, doPP=doPPKitaev)
        if not doIdeal: print "runtime: ", time.time()-tic, "sec"
        print np.around(result,6)
    
    if saveKitaev:
        timestr = datetime.datetime.now().strftime('%Y%m%d-%H%M%S-%f')
        fnameappend = ''
        Kit.getQFTall()
        Kit.datagroupsave('Shor'+str(select_a)+'-data-'+fnameappend+timestr+'.pk', 
                          RhoOnly=True)
        Kit.resultSave('Shor'+str(select_a)+'-res-'+fnameappend+timestr+'.npy')
        f = open('Shor'+str(select_a)+'-params-'+fnameappend+timestr+'.pk', 'wb')
        pickle.dump(dec.dict_params_static, f)
        f.close()

    return True#dataobj
Example #21
0
def test_Ramsey_carrier_detailed(figNum):
    NumberOfIons = 1
    PhononOverhead = 2

    hspace = sim.hspace(NumberOfIons,2,NumberOfIons+PhononOverhead,0)
    params = sim.parameters(hspace)
    dec = sim.decoherence(params)

    params.y0[qc.stateToIndex('S,0', hspace)] = 1
    params.stepsize = 1
    params.printpulse = False # don't print pulse details

    numberofpoints = 20
    phi = np.linspace(0, 2*pi, numberofpoints)
    ex = np.zeros(numberofpoints)

    for i in range(numberofpoints):
        pulseseq = sim.PulseSequence( [
            sim.Rcar(params, pi/2, 0, -1),
#            sim.Delay(params, tdelay[i]),
            sim.Rcar(params, pi/2, phi[i], -1)
            ])

        data = qc.simulateevolution(pulseseq, params, dec)
        data.tracedpopulation(figNum)
        ex[i] = data.YtrN[-1,0]

    # fig1 = pl.figure(1)
    # ax1 = fig1.add_subplot(111)
    # ax1.plot(phi, ex)
    # fig1.show()


    # p[0] ... amplitude, should be 1
    # p[1] ... because phase is in units of pi -> 1
    # p[2] ... phase, should be 0
    # p[3] ... offset, should be 0.5

    startparams = np.array([1, 1, 0, 0.5])

    # 1-data ... to get the D-state population
    fitfun = lambda p, x: p[0]/2*np.cos(p[1]*x+p[2]) + p[3]
    errfun = lambda p, x, y: y-fitfun(p,x)

    par, covmat, infodict, mesg, ier = leastsq(errfun, startparams, args=(phi,ex), full_output = True)

    #print startparams
    #print par

    #print startparams-par

    epsilon = 10**-5

    if par[0] - startparams[0] > epsilon:
        print "amplitude of Ramsey experiment wrong"
    if par[1] - startparams[1] > epsilon:
        print "frequency of Ramsey experiment wrong"
    if par[2] - startparams[2] > epsilon:
        print "phase of Ramsey experiment wrong"
    if par[3] - startparams[3] > epsilon:
        print "offset of Ramsey experiment wrong"


    return np.all(par-startparams < epsilon)
Example #22
0
def main():
    ### run params ##################################
    pulseseqfileShor = 'experiments/Shorseq_6qubit.py'
   
    firstMultMap = True # Do first multiplication with CNOT 
                        # mapping instead of Multiplier 
                        # (does nothing in easy cases)

    select_a = 4 # Factoring base: 2,4,5,8,10,11,13,16,17,19

    doRun = True
    doIdeal = True
    printpulse = False
    saveKitaev = False
    doPPKitaev = True

    print 'N = 21, a =',select_a
    
    NumberOfIons = 6
    NumberOfPhonons = 0 if doIdeal else 7 
    hspace = sim.hspace(NumberOfIons,2,NumberOfPhonons,0)
    hspace.initial_state("quantum", qstate='DSSSSS')
    params = sim.parameters(hspace)
    
    params.use_servers( ['all'] )
    params.ppcpus = 16
    params.shortestMS = 16
    params.calcPulseParams()
    params.progbar = True
    params.saveallpoints = False
    params.coherenceTime = 15000
    params.hidingerr = 1
    
    params.printpulse = printpulse
    params.progbar = printpulse
    params.pplog = False
    
    dec = sim.decoherence(params)
    dec.doRandNtimes = 1 #16
    dec.doPP = True
    dec.dict['all'] = False
#    if doPPKitaev: params.ppcpus = 2
    
    Kit = Kitaev.Kitaev()
    
    ##########################################
    # load the pulse sequences
    # change ion order and define permutations
    ##########################################
    execfile(pulseseqfileShor,locals(),globals())

    cnot12_6 = sim.PulseSequence([ cnot12 ])

    Fred35 = copy.deepcopy(Fredkin)
    Fred13 = copy.deepcopy(Fredkin)
    Fred35.changeions(params, (3,5,0))
    Fred13.changeions(params, (1,3,0))
   
    cnot15 = copy.deepcopy(cnot12_6)
    cnot23 = copy.deepcopy(cnot12_6)
    cnot24 = copy.deepcopy(cnot12_6)
    cnot25 = copy.deepcopy(cnot12_6)
    cnot35 = copy.deepcopy(cnot12_6)
    cnot15.changeions(params,(0,1,5))
    cnot23.changeions(params,(0,2,3))
    cnot24.changeions(params,(0,2,4))
    cnot25.changeions(params,(0,2,5))
    cnot35.changeions(params,(0,3,5))


    times4 = sim.PulseSequence([ \
        sim.Hide(params, 1, True),
        sim.Hide(params, 2, True),
        sim.Hide(params, 4, True), #vis: 3,5
        Fred35,
        sim.Hide(params, 1, False),
        sim.Hide(params, 5, True), #vis: 1,3
        Fred13,
        sim.Hide(params, 2, False),
        sim.Hide(params, 4, False),
        sim.Hide(params, 5, False)
        ])

    times16 = sim.PulseSequence([ \
        sim.Hide(params, 2, True),
        sim.Hide(params, 4, True),
        sim.Hide(params, 5, True), #vis: 1,3
        Fred35,
        sim.Hide(params, 5, False),
        sim.Hide(params, 1, True), #vis: 3,5
        Fred13,
        sim.Hide(params, 1, False),
        sim.Hide(params, 2, False),
        sim.Hide(params, 4, False)
        ])

    ### general pulse sequence
    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
    
    #######################################################
    
    pulseseq = GeneratePulseSeq(select_a)
    
    if doIdeal:
        for ps in pulseseq:
            for pulse in ps:
                pulse.use_ideal = True
    
    ### run it
    if doRun:
        tic = time.time()
        result = Kit.simulateevolution(pulseseq, params, dec, doPP=doPPKitaev)
        if not doIdeal: print "runtime: ", time.time()-tic, "sec"
        print np.around(result,6)
    
    if saveKitaev:
        timestr = datetime.datetime.now().strftime('%Y%m%d-%H%M%S-%f')
        fnameappend = ''
        Kit.getQFTall()
        Kit.datagroupsave('Shor'+str(select_a)+'-data-'+fnameappend+timestr+'.pk', 
                          RhoOnly=True)
        Kit.resultSave('Shor'+str(select_a)+'-res-'+fnameappend+timestr+'.npy')
        f = open('Shor'+str(select_a)+'-params-'+fnameappend+timestr+'.pk', 'wb')
        pickle.dump(dec.dict_params_static, f)
        f.close()

    return True#dataobj
Example #23
0
def main():
    ### run params ##################################
    pulseseqfileShor = 'experiments/Shorseq_6qubit.py'

    firstMultMap = True  # Do first multiplication with CNOT
    # mapping instead of Multiplier
    # (does nothing in easy cases)

    select_a = 4  # Factoring base: 2,4,5,8,10,11,13,16,17,19

    doRun = True
    doIdeal = True
    printpulse = False
    saveKitaev = False
    doPPKitaev = True

    print('N = 21, a =', select_a)

    NumberOfIons = 6
    NumberOfPhonons = 0 if doIdeal else 7
    hspace = sim.hspace(NumberOfIons, 2, NumberOfPhonons, 0)
    hspace.initial_state("quantum", qstate='DSSSSS')
    params = sim.parameters(hspace)

    params.use_servers(['all'])
    params.ppcpus = 16
    params.shortestMS = 16
    params.calcPulseParams()
    params.progbar = True
    params.saveallpoints = False
    params.coherenceTime = 15000
    params.hidingerr = 1

    params.printpulse = printpulse
    params.progbar = printpulse
    params.pplog = False

    dec = sim.decoherence(params)
    dec.doRandNtimes = 1  #16
    dec.doPP = True
    dec.dict['all'] = False
    #    if doPPKitaev: params.ppcpus = 2

    Kit = Kitaev.Kitaev()

    ##########################################
    # load the pulse sequences
    # change ion order and define permutations
    ##########################################
    # execfile(pulseseqfileShor,locals(),globals())
    def makeexec(f):
        f = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', f))
        c = compile(open(f, 'rb').read(), f, 'exec')
        return c

    exec(makeexec(pulseseqfileShor))

    cnot12_6 = sim.PulseSequence([cnot12])

    Fred35 = copy.deepcopy(Fredkin)
    Fred13 = copy.deepcopy(Fredkin)
    Fred35.changeions(params, (3, 5, 0))
    Fred13.changeions(params, (1, 3, 0))

    cnot15 = copy.deepcopy(cnot12_6)
    cnot23 = copy.deepcopy(cnot12_6)
    cnot24 = copy.deepcopy(cnot12_6)
    cnot25 = copy.deepcopy(cnot12_6)
    cnot35 = copy.deepcopy(cnot12_6)
    cnot15.changeions(params, (0, 1, 5))
    cnot23.changeions(params, (0, 2, 3))
    cnot24.changeions(params, (0, 2, 4))
    cnot25.changeions(params, (0, 2, 5))
    cnot35.changeions(params, (0, 3, 5))


    times4 = sim.PulseSequence([ \
        sim.Hide(params, 1, True),
        sim.Hide(params, 2, True),
        sim.Hide(params, 4, True), #vis: 3,5
        Fred35,
        sim.Hide(params, 1, False),
        sim.Hide(params, 5, True), #vis: 1,3
        Fred13,
        sim.Hide(params, 2, False),
        sim.Hide(params, 4, False),
        sim.Hide(params, 5, False)
        ])

    times16 = sim.PulseSequence([ \
        sim.Hide(params, 2, True),
        sim.Hide(params, 4, True),
        sim.Hide(params, 5, True), #vis: 1,3
        Fred35,
        sim.Hide(params, 5, False),
        sim.Hide(params, 1, True), #vis: 3,5
        Fred13,
        sim.Hide(params, 1, False),
        sim.Hide(params, 2, False),
        sim.Hide(params, 4, False)
        ])

    ### general pulse sequence
    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

    #######################################################

    pulseseq = GeneratePulseSeq(select_a)

    if doIdeal:
        for ps in pulseseq:
            for pulse in ps:
                pulse.use_ideal = True

    ### run it
    if doRun:
        tic = time.time()
        result = Kit.simulateevolution(pulseseq, params, dec, doPP=doPPKitaev)
        if not doIdeal: print("runtime: ", time.time() - tic, "sec")
        print(np.around(result, 6))

    if saveKitaev:
        timestr = datetime.datetime.now().strftime('%Y%m%d-%H%M%S-%f')
        fnameappend = ''
        Kit.getQFTall()
        Kit.datagroupsave('Shor' + str(select_a) + '-data-' + fnameappend +
                          timestr + '.pk',
                          RhoOnly=True)
        Kit.resultSave('Shor' + str(select_a) + '-res-' + fnameappend +
                       timestr + '.npy')
        f = open(
            'Shor' + str(select_a) + '-params-' + fnameappend + timestr +
            '.pk', 'wb')
        pickle.dump(dec.dict_params_static, f)
        f.close()

    return True  #dataobj