Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. #plotting probability for finding a particle between barriers
  2. %matplotlib inline
  3. import numpy as np
  4. import matplotlib.pyplot as plt
  5. import matplotlib.animation as animation
  6. from IPython.display import HTML
  7.  
  8.  
  9. N = 10
  10. V0 = 2e-19
  11. hbar = 1.05e-34
  12. m = 9.11e-31
  13. dx = 1e-10
  14. left = [0.0]*100*N
  15. barrier = [V0]*N
  16. barrier2 = [V0]*N
  17. middle = [0.0]*50*N
  18. right = [0.0]*100*N
  19.  
  20.  
  21. V = np.asarray(left+barrier+middle+barrier2+right)
  22.  
  23. #making psi_n matrix and energy eigenvalues solving TISE
  24. d = [v + hbar**2/(m*dx**2) for v in V]
  25. e = - hbar**2/(2*m*dx**2)
  26. Ntot=len(V)
  27. H = [[0]*(Ntot) for n in range(Ntot)]
  28. for i in range(Ntot):
  29. for j in range(Ntot):
  30. if i==j:
  31. H[i][j]=d[i]
  32. if abs(i-j)==1:
  33. H[i][j]=e
  34. H = np.asarray(H)
  35. energy,psi_matrix = np.linalg.eigh(H)
  36.  
  37. def wave_maker(E):
  38. m = 9.11e-31
  39. hbar = 1.05e-34
  40. dx = 1e-10
  41. x = np.asarray([dx*n for n in range(Ntot)])
  42. x0 = 50*N*dx
  43. sigma = 10*N*dx
  44. Delta_x = sigma
  45. Delta_p = hbar/(2.0*sigma)
  46. #k0 = p0/hbar
  47. k0 = np.sqrt(2*m*E)/hbar
  48. normfactor = (2*np.pi*sigma**2)**(-0.25)
  49. gaussinit = np.exp(-(x-x0)**2/(4*sigma**2))
  50. psi_matrix_complex = psi_matrix*(1.0 + 0.0j)
  51.  
  52. planewavefactor = np.exp(1j*k0*x)
  53. Psi0 = normfactor*gaussinit*planewavefactor
  54. c = np.zeros(Ntot, dtype = np.complex128)
  55. for n in range(Ntot):
  56. c[n] = np.vdot(psi_matrix_complex[:,n],Psi0)
  57.  
  58. t = 240*m*N*dx/(k0*hbar)
  59. timelist = np.linspace(t/20,t*20,200)
  60. problist = [0]*len(timelist)
  61. for i in range(len(timelist)):
  62. Psi_t = np.zeros(Ntot,dtype=np.complex128)
  63. for n in range(Ntot):
  64. Psi_t = Psi_t + c[n]*psi_matrix_complex[:,n]*np.exp(-1j*energy[n]*timelist[i]/hbar)
  65. rho_t = np.abs(Psi_t)**2
  66. M = np.sum(rho_t[len(left):len(middle)+len(left)]*dx)/sum(rho_t*dx)
  67. problist[i]=M
  68. return timelist,problist
  69.  
  70.  
  71. p0 = 1e-24
  72. E = p0**2/(2*m)
  73.  
  74. timelist,problist = wave_maker(E)
  75.  
  76. plt.figure()
  77. plt.title("Sannsynlighet P for å finne partikkel mellom to barrierer som funksjon av tida, uten resonans")
  78. plt.plot(timelist,problist, label = "P(t)")
  79. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement