def compute_rabi_coupling(self): ''' Rabi couplings, see Leibfried (2003), eq:70 ''' eta = self.eta if self.sideband_order == 0: coupling_func = lambda n: np.exp(-1. / 2 * eta**2) * laguerre( n, 0, eta**2) elif self.sideband_order == 1: coupling_func = lambda n: np.exp(-1. / 2 * eta**2) * eta**(1) * ( 1. / (n + 1.))**0.5 * laguerre(n, 1, eta**2) elif self.sideband_order == 2: coupling_func = lambda n: np.exp(-1. / 2 * eta**2) * eta**(2) * ( 1.0 / ((n + 1.) * (n + 2)))**0.5 * laguerre(n, 2, eta**2) elif self.sideband_order == -1: coupling_func = lambda n: 0 if n == 0 else np.exp( -1. / 2 * eta**2) * eta**(1) * (1. / (n))**0.5 * laguerre( n - 1, 1, eta**2) elif self.sideband_order == -2: coupling_func = lambda n: 0 if n <= 1 else np.exp( -1. / 2 * eta**2) * eta**(2) * (1.0 / ( (n) * (n - 1.)))**0.5 * laguerre(n - 2, 2, eta**2) else: raise NotImplementedError( "Can't calculate rabi couplings sideband order {}".format( self.sideband_order)) return np.array([coupling_func(n) for n in range(self.nmax)])
def test_l_roots(): weightf = orth.laguerre(5).weight_func verify_gauss_quad(orth.l_roots, orth.eval_laguerre, weightf, 0., np.inf, 5) verify_gauss_quad(orth.l_roots, orth.eval_laguerre, weightf, 0., np.inf, 25, atol=1e-13) verify_gauss_quad(orth.l_roots, orth.eval_laguerre, weightf, 0., np.inf, 100, atol=1e-12) x, w = orth.l_roots(5, False) y, v, m = orth.l_roots(5, True) assert_allclose(x, y, 1e-14, 1e-14) assert_allclose(w, v, 1e-14, 1e-14) muI, muI_err = integrate.quad(weightf, 0, np.inf) assert_allclose(m, muI, rtol=muI_err) assert_raises(ValueError, orth.l_roots, 0) assert_raises(ValueError, orth.l_roots, 3.3)
def compute_rabi_coupling(self): ''' Rabi couplings, see Leibfried (2003), eq:70 ''' eta = self.eta if self.sideband_order == 0: coupling_func = lambda n: np.exp(-1./2*eta**2) * laguerre(n, 0, eta**2) elif self.sideband_order == 1: coupling_func = lambda n: np.exp(-1./2*eta**2) * eta**(1)*(1./(n+1.))**0.5 * laguerre(n, 1, eta**2) elif self.sideband_order == 2: coupling_func = lambda n: np.exp(-1./2*eta**2) * eta**(2)*(1./((n+1.)*(n+2)))**0.5 * laguerre(n, 2, eta**2) elif self.sideband_order == 3: coupling_func = lambda n: np.exp(-1./2*eta**2) * eta**(3)*(1./((n+1)*(n+2)*(n+3)))**0.5 * laguerre(n, 3 , eta**2) elif self.sideband_order == 4: coupling_func = lambda n: np.exp(-1./2*eta**2) * eta**(4)*(1./((n+1)*(n+2)*(n+3)*(n+4)))**0.5 * laguerre(n, 4 , eta**2) elif self.sideband_order == 5: coupling_func = lambda n: np.exp(-1./2*eta**2) * eta**(5)*(1./((n+1)*(n+2)*(n+3)*(n+4)*(n+5)))**0.5 * laguerre(n, 5 , eta**2) elif self.sideband_order == -1: coupling_func = lambda n: 0 if n == 0 else np.exp(-1./2*eta**2) * eta**(1)*(1./(n))**0.5 * laguerre(n - 1, 1, eta**2) elif self.sideband_order == -2: coupling_func = lambda n: 0 if n <= 1 else np.exp(-1./2*eta**2) * eta**(2)*(1./((n)*(n-1.)))**0.5 * laguerre(n - 2, 2, eta**2) elif self.sideband_order == -3: coupling_func = lambda n: 0 if n <= 2 else np.exp(-1./2*eta**2) * eta**(3)*(1./((n)*(n-1.)*(n-2)))**0.5 * laguerre(n -3, 3, eta**2) elif self.sideband_order == -4: coupling_func = lambda n: 0 if n <= 3 else np.exp(-1./2*eta**2) * eta**(4)*(1./((n)*(n-1.)*(n-2)*(n-3)))**0.5 * laguerre(n -4, 4, eta**2) elif self.sideband_order == -5: coupling_func = lambda n: 0 if n <= 4 else np.exp(-1./2*eta**2) * eta**(5)*(1./((n)*(n-1.)*(n-2)*(n-3)*(n-4)))**0.5 * laguerre(n -5, 5, eta**2) else: raise NotImplementedError("Can't calculate rabi couplings sideband order {}".format(self.sideband_order)) return np.array([coupling_func(n) for n in range(self.nmax)])
def _displaced_thermal(cls, alpha, nbar, n): """ returns the motional state distribution with the displacement alpha, motional temperature nbar for the state n """ # this is needed because for some inputs (larrge n or small nbar, this term is 0 while the laguerre term is infinite. their product is zero but beyond the floating point precision try: old_settings = np.seterr(invalid="raise") populations = ( 1.0 / (nbar + 1.0) * (nbar / (nbar + 1.0)) ** n * laguerre(n, 0, -alpha ** 2 / (nbar * (nbar + 1.0))) * np.exp(-alpha ** 2 / (nbar + 1.0)) ) except FloatingPointError: np.seterr(**old_settings) print "precise calculation required", alpha, nbar populations = [ mp.fprod( ( 1.0 / (nbar + 1.0), mp.power(nbar / (nbar + 1.0), k), mp.laguerre(k, 0, -alpha ** 2 / (nbar * (nbar + 1.0))), mp.exp(-alpha ** 2 / (nbar + 1.0)), ) ) for k in n ] print "done computing populations" populations = np.array(populations) print "returned array" return populations
def _displaced_thermal(cls, alpha, nbar, n): ''' returns the motional state distribution with the displacement alpha, motional temperature nbar for the state n ''' #this is needed because for some inputs (larrge n or small nbar, this term is 0 while the laguerre term is infinite. their product is zero but beyond the floating point precision try: old_settings = np.seterr(invalid='raise') populations = 1. / (nbar + 1.0) * (nbar / (nbar + 1.0))**n * laguerre( n, 0, -alpha**2 / (nbar * (nbar + 1.0))) * np.exp(-alpha**2 / (nbar + 1.0)) except FloatingPointError: np.seterr(**old_settings) print 'precise calculation required', alpha, nbar populations = [ mp.fprod((1. / (nbar + 1.0), mp.power(nbar / (nbar + 1.0), k), mp.laguerre(k, 0, -alpha**2 / (nbar * (nbar + 1.0))), mp.exp(-alpha**2 / (nbar + 1.0)))) for k in n ] print 'done computing populations' populations = np.array(populations) print 'returned array' return populations
def _displaced_thermal(cls, alpha, nbar, n): return ( 1.0 / (nbar + 1.0) * (nbar / (nbar + 1.0)) ** n * laguerre(n, 0, -alpha ** 2 / (nbar * (nbar + 1.0))) * np.exp(-alpha ** 2 / (nbar + 1.0)) )
def _displaced_thermal(cls, alpha, nbar, n): ''' returns the motional state distribution with the displacement alpha, motional temperature nbar for the state n ''' #this is needed because for some inputs (larrge n or small nbar, this term is 0 while the laguerre term is infinite. their product is zero but beyond the floating point precision try: old_settings = np.seterr(invalid='raise') populations = 1./ (nbar + 1.0) * (nbar / (nbar + 1.0))**n * laguerre(n, 0 , -alpha**2 / ( nbar * (nbar + 1.0))) * np.exp( -alpha**2 / (nbar + 1.0)) except FloatingPointError: print 'using coherent state' # np.seterr(**old_settings) # populations = np.exp(-alpha**2) * alpha**(2*n) / factorial(n) populations = (2 * np.pi * alpha**2)**(-.5) * np.exp(-(n - alpha**2)**2/(2*alpha**2)) return populations
def rabi_coupling(n, m, eta): '''return the Rabi matrix elements <m+n| exp(1j*eta*(a+a.dag)) |n> for n = 0...n-1 @ var n: size of the Hilbert space @ var m: order m of the sideband @ var eta: Lamd-Dicke parameter returns: Wnm Rabi matrix elements for n = 0,...n-1 ''' L = np.array([laguerre(ii, abs(m), eta**2) for ii in range(n)]) fctr = np.array([factorial_simplified(ii, abs(m))**(0.5) for ii in range(n)]) Wmn = exp(-1./2.*eta**2) * eta**abs(m) * fctr * L if m<0: Wmn = np.concatenate((np.zeros(-m), Wmn[:m])) return abs(Wmn)
def __init__(self, date, w0 = 2*np.pi*500e3, phi=np.pi/4, nmax=3000, basepath='/home/viellieb/work_resonator/datavault/Experiments.dir'): self.date = date self.basepath = basepath k = 2 * np.pi / 729.14e-9 eta0 = k * np.sqrt(const.hbar/(2*40*const.m_p*w0)) self.eta = eta0 * np.cos(phi) self.delay = 6.7 self.nmax = nmax print "Generating coupling tables" coupling_func = lambda n: np.exp(-1./2*self.eta**2) * laguerre(n, 0, self.eta**2) coupling_array = np.array([coupling_func(n) for n in range(self.nmax)]) self.rabi_coupling = coupling_array self.n_array = np.arange(self.nmax)
def rabi_coupling(n, m, eta): '''return the Rabi matrix elements <m+n| exp(1j*eta*(a+a.dag)) |n> for n = 0...n-1 @ var n: size of the Hilbert space @ var m: order m of the sideband @ var eta: Lamd-Dicke parameter returns: Wnm Rabi matrix elements for n = 0,...n-1 ''' L = np.array([laguerre(ii, abs(m), eta**2) for ii in range(n)]) fctr = np.array( [factorial_simplified(ii, abs(m))**(0.5) for ii in range(n)]) Wmn = exp(-1. / 2. * eta**2) * eta**abs(m) * fctr * L if m < 0: Wmn = np.concatenate((np.zeros(-m), Wmn[:m])) return abs(Wmn)
def test_l_roots(): weightf = orth.laguerre(5).weight_func verify_gauss_quad(orth.l_roots, orth.eval_laguerre, weightf, 0.0, np.inf, 5) verify_gauss_quad(orth.l_roots, orth.eval_laguerre, weightf, 0.0, np.inf, 25, atol=1e-13) verify_gauss_quad(orth.l_roots, orth.eval_laguerre, weightf, 0.0, np.inf, 100, atol=1e-12) x, w = orth.l_roots(5, False) y, v, m = orth.l_roots(5, True) assert_allclose(x, y, 1e-14, 1e-14) assert_allclose(w, v, 1e-14, 1e-14) muI, muI_err = integrate.quad(weightf, 0, np.inf) assert_allclose(m, muI, rtol=muI_err) assert_raises(ValueError, orth.l_roots, 0) assert_raises(ValueError, orth.l_roots, 3.3)
def _displaced_thermal(cls, alpha, nbar, n): ''' returns the motional state distribution with the displacement alpha, motional temperature nbar for the state n ''' #this is needed because for some inputs (larrge n or small nbar, this term is 0 while the laguerre term is infinite. their product is zero but beyond the floating point precision try: old_settings = np.seterr(invalid='raise') populations = 1. / (nbar + 1.0) * (nbar / (nbar + 1.0))**n * laguerre( n, 0, -alpha**2 / (nbar * (nbar + 1.0))) * np.exp(-alpha**2 / (nbar + 1.0)) except FloatingPointError: print 'using coherent state' # np.seterr(**old_settings) # populations = np.exp(-alpha**2) * alpha**(2*n) / factorial(n) populations = (2 * np.pi * alpha**2)**(-.5) * np.exp( -(n - alpha**2)**2 / (2 * alpha**2)) return populations
def _displaced_thermal(cls, alpha, nbar, n): ''' returns the motional state distribution with the displacement alpha, motional temperature nbar for the state n ''' #this is needed because for some inputs (larrge n or small nbar, this term is 0 while the laguerre term is infinite. their product is zero but beyond the floating point precision try: old_settings = np.seterr(invalid='raise') populations = 1. / (nbar + 1.0) * (nbar / (nbar + 1.0))**n * laguerre( n, 0, -alpha**2 / (nbar * (nbar + 1.0))) * np.exp(-alpha**2 / (nbar + 1.0)) except FloatingPointError: np.seterr(**old_settings) def fib(): a, b = 0, 1 while 1: yield a a, b = b, a + b import time t1 = time.time() print 'precise calculation required', alpha, nbar expon_term = mp.exp(-alpha**2 / (nbar + 1.0)) populations = [ float( mp.fprod((mp.power(nbar / (nbar + 1.0), k), mp.laguerre(k, 0, -alpha**2 / (nbar * (nbar + 1.0))), expon))) for k in n ] populations = np.array(populations) / (nbar + 1) print time.time() - t1 print 'done' return populations
def _displaced_thermal(cls, alpha, nbar, n): ''' returns the motional state distribution with the displacement alpha, motional temperature nbar for the state n ''' #this is needed because for some inputs (larrge n or small nbar, this term is 0 while the laguerre term is infinite. their product is zero but beyond the floating point precision try: old_settings = np.seterr(invalid='raise') populations = 1./ (nbar + 1.0) * (nbar / (nbar + 1.0))**n * laguerre(n, 0 , -alpha**2 / ( nbar * (nbar + 1.0))) * np.exp( -alpha**2 / (nbar + 1.0)) except FloatingPointError: np.seterr(**old_settings) def fib(): a, b = 0, 1 while 1: yield a a, b = b, a + b import time t1 = time.time() print 'precise calculation required', alpha, nbar expon_term = mp.exp(-alpha**2 / (nbar + 1.0)) populations = [float(mp.fprod((mp.power(nbar / (nbar + 1.0), k), mp.laguerre(k, 0, -alpha**2 / ( nbar * (nbar + 1.0))), expon))) for k in n] populations = np.array(populations) / (nbar + 1) print time.time() - t1 print 'done' return populations
def compute_rabi_coupling(cls, eta, sideband_order, nmax): ''' Rabi couplings, see Leibfried (2003), eq:70 ''' if sideband_order == 0: coupling_func = lambda n: np.exp(-1. / 2 * eta**2) * laguerre( n, 0, eta**2) elif sideband_order == 1: coupling_func = lambda n: np.exp(-1. / 2 * eta**2) * eta**(1) * ( 1. / (n + 1.))**0.5 * laguerre(n, 1, eta**2) elif sideband_order == 2: coupling_func = lambda n: np.exp(-1. / 2 * eta**2) * eta**(2) * ( 1. / ((n + 1.) * (n + 2)))**0.5 * laguerre(n, 2, eta**2) elif sideband_order == 3: coupling_func = lambda n: np.exp(-1. / 2 * eta**2) * eta**(3) * ( 1. / ((n + 1) * (n + 2) * (n + 3)))**0.5 * laguerre(n, 3, eta**2) elif sideband_order == 4: coupling_func = lambda n: np.exp(-1. / 2 * eta**2) * eta**(4) * ( 1. / ((n + 1) * (n + 2) * (n + 3) * (n + 4)))**0.5 * laguerre(n, 4, eta**2) elif sideband_order == 5: coupling_func = lambda n: np.exp(-1. / 2 * eta**2) * eta**(5) * ( 1. / ((n + 1) * (n + 2) * (n + 3) * (n + 4) * (n + 5)))**0.5 * laguerre(n, 5, eta**2) elif sideband_order == -1: coupling_func = lambda n: 0 if n == 0 else np.exp( -1. / 2 * eta**2) * eta**(1) * (1. / (n))**0.5 * laguerre( n - 1, 1, eta**2) elif sideband_order == -2: coupling_func = lambda n: 0 if n <= 1 else np.exp( -1. / 2 * eta**2) * eta**(2) * (1. / ( (n) * (n - 1.)))**0.5 * laguerre(n - 2, 2, eta**2) elif sideband_order == -3: coupling_func = lambda n: 0 if n <= 2 else np.exp( -1. / 2 * eta**2) * eta**(3) * (1. / ( (n) * (n - 1.) * (n - 2)))**0.5 * laguerre(n - 3, 3, eta**2) elif sideband_order == -4: coupling_func = lambda n: 0 if n <= 3 else np.exp( -1. / 2 * eta**2) * eta**(4) * (1. / ( (n) * (n - 1.) * (n - 2) * (n - 3)))**0.5 * laguerre(n - 4, 4, eta**2) elif sideband_order == -5: coupling_func = lambda n: 0 if n <= 4 else np.exp( -1. / 2 * eta**2) * eta**(5) * (1. / ( (n) * (n - 1.) * (n - 2) * (n - 3) * (n - 4)))**0.5 * laguerre(n - 5, 5, eta**2) else: raise NotImplementedError( "Can't calculate rabi couplings sideband order {}".format( sideband_order)) return np.array([coupling_func(n) for n in range(nmax)])
def _displaced_thermal(cls, alpha, nbar, n): return 1. / (nbar + 1.0) * (nbar / (nbar + 1.0))**n * laguerre( n, 0, -alpha**2 / (nbar * (nbar + 1.0))) * np.exp(-alpha**2 / (nbar + 1.0))