Exemple #1
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.0 * (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
Exemple #2
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
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
Exemple #5
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_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
Exemple #7
0
    def loadsimdata(self, data, print_fidelities=False):
        ''' load simulation data directly from variables '''
        try: # data is a database object
            self.data = data
            self.data.RhoPNAll = np.array(self.data.RhoPNAll)
            self.rhosim = self.data.RhoPN
        except AttributeError: # or it's just the densmats
            # make a dummy data object
            self.data = sim.database(np.zeros(1), np.zeros(1), sim.hspace(1,2,0,0))
            self.data.RhoPNAll = data

        self.simloaded = True
        if print_fidelities:
            for i in range(np.min([len(self.rhosim), len(self.rho)])):
                print i, ": ", U.jozsafid(self.rho[i], self.rhosim[i])
Exemple #8
0
dec = sim.decoherence(params)

params.stepsize = 600

detuning = np.arange(-1.2 * params.omz, 1.2 * params.omz, params.omz / 300)
# dets1 = np.arange(-1.1*params.omz, -0.9*params.omz, 2*pi*0.001)
# detc = np.arange(-2*pi*0.1, 2*pi*0.1, 2*pi*0.001)
# dets2 = np.arange(0.9*params.omz, 1.1*params.omz, 2*pi*0.001)
# detuning = np.hstack([ dets1, detc, dets2 ])
YR = np.zeros([len(detuning), hspace.dimensions], np.complex128)

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

for i in range(len(detuning)):
    params.detuning = detuning[i]
    pulseseq = sim.PulseSequence([sim.Rcar(params, pi / params.eta[0], 0)])

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

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

data1 = sim.database(detuning, YR, hspace, pulseseq=None, statesvalid=False)
# data1.displaypopulation(1)
data1.tracedpopulation(0)
pl.plot(detuning / 2 / pi, 1 - data1.YtrI)
pl.xlabel("relative frequency (2$\pi$ MHz)")
pl.ylabel("D state population")
pl.show()
Exemple #9
0
params.stepsize = 600

detuning = np.arange(-1.2*params.omz, 1.2*params.omz, params.omz/300)
#dets1 = np.arange(-1.1*params.omz, -0.9*params.omz, 2*pi*0.001)
#detc = np.arange(-2*pi*0.1, 2*pi*0.1, 2*pi*0.001)
#dets2 = np.arange(0.9*params.omz, 1.1*params.omz, 2*pi*0.001)
#detuning = np.hstack([ dets1, detc, dets2 ])
YR = np.zeros([len(detuning),hspace.dimensions], np.complex128)

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

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

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

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

data1 = sim.database(detuning, YR, hspace, pulseseq=None, statesvalid = False)
#data1.displaypopulation(1)
data1.tracedpopulation(0)
pl.plot(detuning/2/pi, 1-data1.YtrI)
pl.xlabel('relative frequency (2$\pi$ MHz)')
pl.ylabel('D state population')
pl.show()