Guest User

Untitled

a guest
May 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. from matplotlib import pyplot as plt
  2. from matplotlib import animation
  3. import numpy as np
  4. from scipy import special
  5. bessel = special.jv
  6. i = complex(0, 1)
  7.  
  8.  
  9. def q(z):
  10. return z + i*10
  11.  
  12.  
  13. def calc_diffraction(r, z):
  14. return (1 ** 2) * (0.0015 ** 2 / 0.001 ** 2) * np.exp(
  15. (-2 * z ** 2 * (np.sin(0.1)) ** 2) / (0.0015 ** 2)) * np.exp(
  16. (-2 * r ** 2) / (0.0015 ** 2)) * bessel(0, np.conjugate(q(0)) * 2 *
  17. np.pi * r * np.sin(0.1) / (np.conjugate(q(z)) * 0.000000750)) *
  18. bessel(0, (q(0)) * 2 * np.pi * r * np.sin(0.01) / ((q(z)) * 0.000000750))
  19.  
  20.  
  21. def plotradialevolutionArtist(begin, end, number):
  22. xDim = 0.0000055 * 2048
  23. yDim = 0.0000055 * 1088
  24.  
  25. x = np.linspace(-xDim / 2, xDim / 2, 2048)
  26. y = np.linspace(-yDim / 2, yDim / 2, 1088)
  27.  
  28. X, Y = np.meshgrid(x, y)
  29. R = np.sqrt(X ** 2 + Y ** 2)
  30.  
  31. fig, ax = plt.subplots(1, number)
  32.  
  33. number_list = np.linspace(begin, end, number)
  34.  
  35. ims = []
  36.  
  37. for i in range(len(number_list)):
  38. print(i)
  39. Z = np.real(calc_diffraction(R, number_list[i]))
  40. ax[i].set_aspect('equal')
  41. ax[i].contourf(X, Y, Z, 3)
  42. ax[i].tick_params(direction='inout', length=8, width=1, pad=8, labelsize=18, top=False, right=False)
  43. ims.append(ax[i])
  44.  
  45. anim = animation.ArtistAnimation(fig, ims, interval=100, blit=True,
  46. repeat=True, repeat_delay=100)
  47. plt.show()
  48.  
  49.  
  50. plotradialevolutionArtist(0, 1, 10)
  51.  
  52. from matplotlib import pyplot as plt
  53. from matplotlib import animation
  54. import numpy as np
  55. from scipy import special
  56. bessel = special.jv
  57. i = complex(0, 1)
  58.  
  59.  
  60. def q(z):
  61. return z + i*10
  62.  
  63.  
  64. def calc_diffraction(r, z):
  65. return (1 ** 2) * (0.0015 ** 2 / 0.001 ** 2) * np.exp(
  66. (-2 * z ** 2 * (np.sin(0.1)) ** 2) / (0.0015 ** 2)) * np.exp(
  67. (-2 * r ** 2) / (0.0015 ** 2)) * bessel(0, np.conjugate(q(0)) * 2 *
  68. np.pi * r * np.sin(0.1) / (np.conjugate(q(z)) * 0.000000750)) *
  69. bessel(0, (q(0)) * 2 * np.pi * r * np.sin(0.01) / ((q(z)) * 0.000000750))
  70.  
  71.  
  72. def plotradialevolutionArtist(begin, end, number):
  73. xDim = 0.0000055 * 2048
  74. yDim = 0.0000055 * 1088
  75.  
  76. x = np.linspace(-xDim / 2, xDim / 2, 2048)
  77. y = np.linspace(-yDim / 2, yDim / 2, 1088)
  78.  
  79. X, Y = np.meshgrid(x, y)
  80. R = np.sqrt(X ** 2 + Y ** 2)
  81.  
  82. fig, ax = plt.subplots()
  83.  
  84. number_list = np.linspace(begin, end, number)
  85.  
  86. ims = []
  87.  
  88. for i in range(len(number_list)):
  89. print(i)
  90. ax.clear()
  91. Z = np.real(calc_diffraction(R, number_list[i]))
  92. ax.set_aspect('equal')
  93. ax.contourf(X, Y, Z, 3)
  94. ax.tick_params(direction='inout', length=8, width=1, pad=8, labelsize=18, top=False, right=False)
  95. ims.append(ax)
  96.  
  97. anim = animation.ArtistAnimation(fig, ims, interval=100, blit=True,
  98. repeat=True, repeat_delay=100)
  99. plt.show()
  100.  
  101.  
  102. plotradialevolutionArtist(0, 1, 10)
Add Comment
Please, Sign In to add comment