Advertisement
Guest User

Difffration grating code

a guest
Feb 23rd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1.  
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4. n=45 # Value of the refractive index
  5. d=0.02  #Slit separation value
  6. L=500e-6  #The Wavelength value
  7. theta_i=np.linspace(0,100,10)*np.pi/180 # the incident angle
  8. print(theta_i) #printing theta_i values
  9. theta_n=np.arcsin(n*L/d-np.sin(theta_i)) # the diffraction angle
  10. s=theta_n*180/np.pi # diffraction angle is converted to degrees
  11. plt.xlim(10,90)   #setting the x axis limits (scale)
  12. plt.ylim(0,80)   #setting the y axis limits (scale)
  13. plt.plot(theta_i*180/np.pi,s)  # x axis is converted to degrees then plotting x and y axis
  14. plt.xlabel("theta_i")  #x axis labeling
  15. plt.ylabel("theta_n")  #y axis labeling
  16. plt.title("Diffraction angle as a function of incident angle") #Title labeling
  17. plt.show() #this command was written to show the graph
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement