Advertisement
bcbwilla

Angled Diffraction Grating

Jan 23rd, 2013
578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. (* Angle of maxima *)
  2. thetaMax[thetaG_, m_, lambda_: 0.6328, d_: 1.66667] := ArcSin[(m*(lambda))/d + Sin[thetaG]] - thetaG;
  3. (* Maxima distance from central maximum *)
  4. y[thetaG_, m_, x_: 1] := Sin[thetaMax[thetaG, m]]*x/Sqrt[1 - Sin[thetaMax[thetaG, m]]^2];
  5.  
  6. (* Interactive Simulation *)
  7. Manipulate[
  8. Graphics[{
  9. (* Draw the Maxima *)
  10. PointSize[Large], Red, Point[{1, y[t, 0]}],
  11. If[y[t, -1] \[Element] Reals, Point[{1, y[t, -1]}]],
  12. If[y[t, -2] \[Element] Reals, Point[{1, y[t, -2]}]],
  13. If[y[t, 1] \[Element] Reals, Point[{1, y[t, 1]}]],
  14. If[y[t, 2] \[Element] Reals, Point[{1, y[t, 2]}]],
  15.  
  16. (* Draw the rest of the shapes *)
  17. Black,
  18. Text[Style[
  19. "\!\(\*SubscriptBox[\(\[Theta]\), \(g\)]\) = " <>
  20. ToString[NumberForm[-t*180/Pi, 3]] <> "\[Degree]",
  21. FontSize -> 18, FontColor -> Darker[Green]], {0, 1}],
  22. If[thetaMax[t, m] \[Element] Reals,
  23. Text[Style[
  24. "\!\(\*SubscriptBox[\(\[Theta]\), \(m\)]\) = " <>
  25. ToString[NumberForm[thetaMax[t, m]*180/Pi, 3] // Chop] <>
  26. "\[Degree]", FontSize -> 18,
  27. FontColor -> Darker[Blue]], {0, -1}],
  28. Text[Style["\!\(\*SubscriptBox[\(\[Theta]\), \(max\)]\) = N/A",
  29. FontSize -> 18, FontColor -> Darker[Blue]], {0, -1}]],
  30. Red, Line[{{-1, 0}, {0, 0}}], Arrowheads[0.04],
  31. Arrow[{{-1, 0}, {-0.3, 0}}],
  32. If[y[t, m] \[Element] Reals, Arrow[{{0, 0}, {1, y[t, m]}}]],
  33. Black, Rectangle[{-1.25, -0.05}, {-0.9, 0.05}],
  34. Dashed, Line[{{0, 0}, {1, 0}}], Black,
  35. Rotate[Line[{{-0.5, 0}, {0, 0}}], -t, {0, 0}],
  36. Darker[Green], Circle[{0, 0}, 0.35, {Pi, Pi - t}],
  37. Darker[Blue],
  38. If[thetaMax[t, m] \[Element] Reals,
  39. Circle[{0, 0}, 0.5, {0, thetaMax[t, m]}]],
  40. Darker[Gray], Rotate[Rectangle[{-0.02, -0.4}, {0.02, 0.4}], -t]},
  41.  
  42. PlotRange -> {{-1.5, 1.5}, {-1.5, 1.5}}],
  43. {{t, 0, "\!\(\*SubscriptBox[\(\[Theta]\), \(g\)]\)"}, -Pi/2,
  44. Pi/2}, {{m, 0}, {-2, -1, 0, 1, 2}},
  45. FrameLabel -> {"", "",
  46. Style["Diffraction Grating at an Angle", 18, Bold], ""},
  47. ControlPlacement -> Bottom]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement