Esempio n. 1
0
def repratescan(treplist, pool, savefigs=None, **kargs):


    # # mnames, v, laser_det, delta, pulsefunc, pulseshape, pulsearea, pulsetotaltime, pulsepoints, trep, npulse = args

    TASKS = [(kargs['mnames'], kargs['v'], bloch.laser_detd2,
              kargs['detu'], kargs['gausspulse'], kargs['gausssigma'],
              kargs['gausstheta'], kargs['gausstau'], 30, trep, kargs['npulse']) for trep in treplist]
    try:
        out = pool.map_async(pulsescalc, TASKS).get(999999)
    except KeyboardInterrupt:
        pool.terminate()
        sys.exit(0)
    nelems = len(kargs['v'])
    results = zeros((len(treplist), nelems+1))
    for i, res in enumerate(out):
            results[i, 0] = treplist[i]
            for k in xrange(nelems):
                results[i, k+1] = res[k][-1]

    d01 = abs(bloch.laser_detd2(0)[21,6])
    timescale = d01/2/np.pi
    pl.figure()
    for i in xrange(2,6):
        pl.plot(results[:, 0]*timescale, results[:, i+1], '.-', label="|%d>"%i)
    pl.plot(results[:, 0]*timescale, results[:, 3]+results[:, 4]+results[:, 5]+results[:, 6], 'k--', label='total')
    pl.legend(loc='best')
    pl.title('Upper state populations')
    pl.xlim([results[0,0]*timescale, results[-1,0]*timescale])
    pl.xlabel('Repetition rate divider')
    pl.ylabel('Population')
    if savefigs:
        figname = "%s_pop.png" %savefigs
        pl.savefig(figname)
        # catchimgup("Population", "%s" %figname)

    pl.figure()
    for i in [6]:
        pl.plot(results[:,0]*timescale, results[:, i+1], '--', label='Real')
    for i in [21]:
        pl.plot(results[:,0]*timescale, results[:, i+1], ':', label='Imag')
    pl.legend(loc='best')
    pl.title('Ground state coherence')
    pl.xlim([results[0,0]*timescale, results[-1,0]*timescale])
    pl.xlabel('Repetition rate divider')
    pl.ylabel('Coherence')
    if savefigs:
        figname = "%s_coh.png" %savefigs
        pl.savefig(figname)
Esempio n. 2
0
def main():

    try:
        import multiprocessing as processing
    except:
        import processing
    NUMBER_OF_PROCESSES = processing.cpu_count()
    pool = processing.Pool(processes=NUMBER_OF_PROCESSES)  

    # bloch.laser_detd2(0)
    # sys.exit(0)

    matrices = bloch.blochd2()
    mnames = ['bloch_atomic', 'laser_pow']
    for i in range(len(mnames)):
        matrices[i].export_mtx(mnames[i])

    v = matrix(zeros((36, 1)))
    # v[0] = 0.5
    # v[1] = 0.5
    v[2] = 1

    
    # TASKS = [(mnames, t, bloch.laser_det) for t in range(10,1000)]
    # out = pool.map(timedomain, TASKS)
    # print out[0]
    # print bloch.laser_det(255)

    # omega = np.pi
    # delta = -1756
    # maxt = 10
    # params = [mnames, v, maxt, omega, bloch.laser_detd2, delta]
    # res = timedomain(params)
    # t = linspace(0, maxt, 1001)
    # # print res[2, :]
    # # markers = ['k-', 'b--', 'r-.', 'g:']
    # # for i in range(3, -1, -1):
    # #     pl.plot(t, res[i, :], markers[i], label='|%d>' % (i), linewidth=2)
    # [pl.plot(t, res[i, :]) for i in range(6)]
    # # pl.legend(loc='best')
    # pl.show()
    # sys.exit(0)



    # #### D2 line frequency comb - time dependent
    # G = 32.889e6
    # timescale = 1/G
    # # pulse length = 1ps
    # tauP = 1e-12 / timescale
    # gausssigma = tauP * sqrt(pi/(2*log(2)))
    # gausstheta = 1/50
    # gausstau = 4 * gausssigma

    # v = matrix(zeros((36, 1)))
    # v[0] = 0.5
    # v[1] = 0.5

    # # 
    # d01 = abs(bloch.laser_detd2(0)[21,6])
    # trep = 100.5/(d01/2/np.pi)
    # # print("trep %f" %trep)
    # # print("gtau %f" %gausstau)
    # # sys.exit(0)
    # npulse = 100
    # # detu = -2009.3/2
    # detu = 0

    # # mnames, v, laser_det, delta, pulsefunc, pulseshape, pulsearea, pulsetotaltime, pulsepoints, trep, npulse = args
    # res =  pulsescalc((mnames, v, bloch.laser_detd2, detu, gausspulse, gausssigma, gausstheta, gausstau, 30, trep, npulse))
    # pulses = range(npulse+1)
    # pl.figure(1)
    # for i in xrange(0,2):
    #     pl.plot(pulses, res[i, :], '.-', label='%d'%i)
    # pl.plot(pulses, res[0, :]+res[1, :], 'kx-', label='Sum')
    # pl.title('Lower state populations')
    # pl.legend(loc='best')

    # pl.figure(0)
    # for i in xrange(2,6):
    #     pl.plot(pulses, res[i, :], '.-', label='%d'%i)
    # pl.plot(pulses, res[2, :]+res[3, :]+res[4, :]+res[5, :], 'kx-', label='Sum')
    # pl.title('Upper state populations')
    # pl.legend(loc='best')

    # # pl.figure()
    # # for i in xrange(4, 6):
    # #     pl.plot(pulses, res[i, :], label='%d'%i)
    # # pl.title('Real Coherence')
    # # pl.legend(loc='best')
    # # pl.figure()
    # # for i in xrange(10, ):
    # #     pl.plot(pulses, res[i, :], label='%d'%i)
    # # pl.title('Imag Coherence')
    # # pl.legend(loc='best')
    # pl.show()
    # sys.exit(0)



    # sys.exit(0)
    # # #### Fixed repetition rate and scanned detuning
    G = 32.889e6
    timescale = 1/G
    # pulse length = 1ps
    tauP = 1e-12 / timescale
    gausssigma = tauP * sqrt(pi/(2*log(2)))
    gausstheta = 1/25
    gausstau = 4 * gausssigma

    v = matrix(zeros((36, 1)))
    v[0] = 0.5
    v[1] = 0.5

    d01 = abs(bloch.laser_detd2(0)[21,6])
    # trep = 100.5/(d01/2/np.pi)
    # print("trep %f" %trep)
    # print("gtau %f" %gausstau)
    # sys.exit(0)
    npulse = 500
    # # detu = -2009.3/2
    # detu = 0

    trepbase = 100
    dt = 0.04
    ntrep = 81

    treplist = linspace(trepbase-dt, trepbase+dt, ntrep)/(d01/2/np.pi)
    figs = ['6level_f32',
            '6level_f33',
            '6level_f34',
            '6level_f35',
            '6level_f42',
            '6level_f43',
            '6level_f44',
            '6level_f45']
    detus = [0, 28.89, 28.89+38.46, 28.89+38.46+47.97,
             -1756.33, -1756.33+28.89, -1756.33+28.89+38.46, -1756.33+28.89+38.46+47.97]

    # loop through all the settings
    for pars in zip(figs, detus):
        repratescan(treplist, pool=pool, savefigs=pars[0], mnames=mnames, v=v,
                detu=pars[1], gausspulse=gausspulse, gausssigma=gausssigma,
                gausstheta=gausstheta, gausstau=gausstau,
                npulse=npulse)


    # # on resonance with F=4->F'5
    # detu = -1638.01
    # repratescan(treplist, pool=pool, savefigs="6level_f45", mnames=mnames, v=v,
    #             detu=detu, gausspulse=gausspulse, gausssigma=gausssigma,
    #             gausstheta=gausstheta, gausstau=gausstau,
    #             npulse=npulse)
    pl.show()