Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.40 KB | None | 0 0
  1. import numpy as np
  2. from matplotlib import pyplot as plt
  3. import matplotlib.animation as animation
  4.  
  5. hbar=1.054718E-34
  6. N=10
  7. V0=2.0E-19
  8. m=9.11E-31
  9. dx = 1.0E-10
  10. Vmax=13.0E-20
  11. tidssteg=5.0E-15
  12. iterations=5
  13. b=15
  14. p0 = 3.2*np.pi*hbar/(b*dx) #resonant energi
  15. #p0 = np.pi*hbar*2.9/(b*dx) #ikke-resonant energi
  16. k0=p0/hbar
  17.  
  18. #Område der vi skal finne P(t)
  19. vens = 101*N
  20. hoyr = (101+b)*N
  21. vlen = vens*dx
  22. hlen = hoyr*dx
  23.  
  24. #definerer potensialene
  25. left=[0.0]*100*N
  26. barrier_left=[V0]*N
  27. between=[0.0]*b*N
  28. barrier_right=[V0]*N
  29. right=[0.0]*100*N
  30. V=np.asarray(left+barrier_left+between+barrier_right+right)
  31.  
  32. #stasjonære tilstander
  33. d = [v + hbar**2/(2*m*dx**2) for v in V]
  34. e = - hbar**2/(2*m*dx**2)
  35. Ntot = len(V)
  36. H = [[0]*(Ntot) for n in range(Ntot)]
  37. for i in range(Ntot):
  38.     for j in range(Ntot):
  39.         if i==j:
  40.             H[i][j]=d[i]
  41.         if abs(i-j)==1:
  42.             H[i][j]=e
  43.            
  44. H=np.asarray(H)
  45. energy,psi_matrix = np.linalg.eigh(H)
  46.  
  47.            
  48. #initialtilstand
  49. x = np.asarray([dx*n for n in range(Ntot)])
  50. x0 = 50*N*dx
  51. sigma = 10*N*dx
  52. delta_x = sigma
  53. delta_p = hbar/(2.0*sigma)
  54. normfactor = (2*np.pi*sigma**2)**(-0.25)
  55. gaussinitial = np.exp(-(x-x0)**2/(4*sigma**2))
  56. planewavefactor = np.exp(1j*k0*x)
  57. psi0 = normfactor*gaussinitial*planewavefactor
  58.  
  59.  
  60. #bølgepakke som lineær komb. av stasj. tilstander
  61. psi_matrix_complex = psi_matrix*(1.0 + 0.0j)
  62. c=np.zeros(Ntot, dtype = np.complex128)
  63. for n in range(Ntot):
  64.     c[n]=np.vdot(psi_matrix_complex[:,n],psi0)
  65.  
  66. #finner andel av bølgen som befinner seg mellom veggene
  67. probabilitylist = []
  68. frames = 250
  69. tlist = [n*tidssteg for n in range(frames)]
  70. for i in range(frames):
  71.     t = i*tidssteg
  72.     psi_t=np.zeros(Ntot, dtype=np.complex128)
  73.     rhosum_enclosed = 0
  74.     for n in range(Ntot):
  75.         psi_t=psi_t+c[n]*psi_matrix_complex[:,n]*np.exp(-1j*energy[n]*t/hbar)
  76.         if n>=vens and n<=hoyr:
  77.             rhosum_enclosed += np.abs(psi_t[n])**2 #mengde mellom vegger
  78.     rho_t=np.abs(psi_t)**2
  79.     total_rho = np.sum(rho_t) #hele rho_t
  80.     probabilitylist.append(rhosum_enclosed/total_rho)
  81.  
  82. def trapezoid(f, xlist):
  83.     Sum = 0
  84.     for i in range(len(xlist)-1):
  85.         Sum += (dx/2)*(f[i]+f[i+1])
  86.     return Sum
  87.  
  88. """
  89. plist=np.linspace(p0/4, p0*1.1, 60)
  90.  
  91. Tlist=[]
  92. energylist=[]
  93.  
  94. for i in range(60):
  95.  p_temp = plist[i]
  96.  k0=p_temp/hbar
  97.  t=(tidssteg)
  98.    
  99.  planewavefactor = np.exp(1j*k0*x)
  100.  psi0 = normfactor*gaussinitial*planewavefactor
  101.  c=np.zeros(Ntot, dtype = np.complex128)
  102.  for n in range(Ntot):
  103.      c[n]=np.vdot(psi_matrix_complex[:,n],psi0)
  104.  psi_t=np.zeros(Ntot, dtype=np.complex128)
  105.  for n in range(Ntot):
  106.      psi_t=psi_t+c[n]*psi_matrix_complex[:,n]*np.exp(-1j*energy[n]*t/hbar)
  107.  
  108.  rho_t=np.abs(psi_t)**2
  109.  R = trapezoid(rho_t, left)
  110.  T=1-R
  111.  Tlist.append(T)
  112.  energylist.append(p_temp*p_temp/(2*m))
  113.  
  114. plt.figure()    
  115.  
  116. plt.xlabel('E', fontsize=16)
  117. plt.ylabel('T(E)', fontsize=16)
  118. plt.plot(energylist, Tlist)
  119. plt.savefig('Transsans(E).pdf')
  120. plt.show()
  121. """
  122.  
  123. plt.figure('P(t)', figsize=(20,20))
  124. plt.title('Sannsynlighet for å finne elektron mellom barrierene, resonans', fontsize=22)
  125. #plt.title('Sannsynlighet for å finne elektron mellom barrierene, ikke resonans', fontsize=22)
  126. plt.plot(tlist, probabilitylist)
  127. plt.ylabel('P_b(t)',fontsize=20)
  128. plt.xlabel('t', fontsize=20)
  129. plt.savefig('Doublebarrier_resonance.pdf')
  130. #plt.savefig('Doublebarrier_nonresonance.pdf')
  131. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement