def LandauLevelSpinor(self, B , n , x , y ,type=1): # Symmetric Gauge def energy(n): return np.sqrt( (self.mass*self.c**2)**2 + 2*B*self.c*self.hBar*n ) K = B*( (self.X-x)**2 + (self.Y-y)**2)/( 4.*self.c*self.hBar ) psi1 = np.exp(-K)*( energy(n) + self.mass*self.c**2 )*laguerre(n)( 2*K ) psi3 = np.exp(-K)*( energy(n) - self.mass*self.c**2 )*laguerre(n)( 2*K ) if n>0: psi2 = 1j*np.exp(-K)*( self.X-x + 1j*(self.Y-y) )*genlaguerre(n-1,1)( 2*K ) else: psi2 = 0.*K psi4 = psi2 if type==1: spinor = np.array([ psi1 , 0*psi2 , 0*psi3 , psi4 ]) elif type ==2: spinor = np.array([ 0*psi1 , psi2 , psi3 , 0*psi4 ]) else : print 'Error: type spinor must be 1 or 2' norm = self.Norm(spinor) spinor /= norm return spinor
def test_wigner_fock(): "wigner: test wigner function calculation for Fock states" xvec = linspace(-5.0, 5.0, 100) yvec = xvec X, Y = meshgrid(xvec, yvec) a = X + 1j * Y # consistent with g=2 option to wigner function dx = xvec[1] - xvec[0] dy = yvec[1] - yvec[0] N = 15 for n in [2, 3, 4, 5, 6]: psi = fock(N, n) # calculate the wigner function using qutip and analytic formula W_qutip = wigner(psi, xvec, yvec, g=2) W_analytic = 2 / pi * (-1)**n * exp(-2 * abs(a)**2) * polyval( laguerre(n), 4 * abs(a)**2) # check difference assert_(sum(abs(W_qutip - W_analytic)) < 1e-4) # check normalization assert_(sum(W_qutip) * dx * dy - 1.0 < 1e-8) assert_(sum(W_analytic) * dx * dy - 1.0 < 1e-8)
def test_wigner_fock(): "wigner: test wigner function calculation for Fock states" xvec = linspace(-5.0, 5.0, 100) yvec = xvec X,Y = meshgrid(xvec, yvec) a = X + 1j * Y # consistent with g=2 option to wigner function dx = xvec[1]-xvec[0] dy = yvec[1]-yvec[0] N = 15 for n in [2,3,4,5,6]: psi = fock(N, n) # calculate the wigner function using qutip and analytic formula W_qutip = wigner(psi, xvec, yvec, g=2) W_analytic = 2/pi * (-1)**n * exp(-2*abs(a)**2) * polyval(laguerre(n), 4*abs(a)**2) # check difference assert_(sum(abs(W_qutip - W_analytic)) < 1e-4) # check normalization assert_(sum(W_qutip) * dx * dy - 1.0 < 1e-8) assert_(sum(W_analytic) * dx * dy - 1.0 < 1e-8)
def W(x, y): #Coherent state #return 2/np.pi* np.exp(-2*(x-x0)**2-2*(y-y0)**2) #Number state L = laguerre(n) return 2 / np.pi * (-1)**n * L(4 * (x**2 + y**2)) * np.exp(-2 * (x**2 + y**2))
def R_func(r, n, l): N = (2 / (n * a0))**(3 / 2) * np.sqrt( (np.math.factorial(n - l - 1)) / (2 * n * ((np.math.factorial(n + l)))**3)) L = laguerre(n + l) L = L / np.abs(L[n + l]) assoc_L = derivative(L, 2 * r / (n * a0), n=2 * l + 1, order=2 * l + 3) R = -N * (2 * r / (n * a0))**l * np.exp(-r / (n * a0)) * assoc_L return R
# -*- coding: utf-8 -*- from matplotlib.pyplot import * from numpy import * from scipy.special import laguerre colores=['blue','red','brown','purple','black'] dasheses=[[],[5,2],[5,5],[5,2,2,2],[2,2]] x = linspace(-5,20,1000) fig = figure(figsize=(8,6)) for n in range(5): plot(x,polyval(laguerre(n),x),colores[n], dashes=dasheses[n],label=r'$L_{%d}(x)$'%n, linewidth=2) ylim(-10,20) xlabel('$x$',fontsize=15) ylabel(r'$L_n(x)$',fontsize=15) legend(loc='best',fontsize=13) grid() savefig('../figs/fig-Laguerre.pdf')
import numpy as np from numpy import exp, sqrt from scipy.special import laguerre, gamma from matplotlib import pyplot as plt from matplotlib import cm n = 10 x = np.linspace(0.01, 30, 500) for i in range(n): plt.plot(x, exp(- x / i) * laguerre(i)(2 * x / i) / i**2, color = cm.viridis(i /n)) plt.show()
def laguerreTableInternal(eta): logger = logging.getLogger(__name__) eta2 = pow(eta, 2) logger.info( "Calculating Laguerre Table for eta^2={0}".format(eta2) ) laguerreTable = array([ laguerre(n)(eta2) for n in range(200) ]) return laguerreTable
def laguerreTableInternal(eta): logger = logging.getLogger(__name__) eta2 = pow(eta, 2) logger.info("Calculating Laguerre Table for eta^2={0}".format(eta2)) laguerreTable = array([laguerre(n)(eta2) for n in range(200)]) return laguerreTable