Write your own program for optical ray tracing - Here's mine in MatLab

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 พ.ย. 2024

ความคิดเห็น • 17

  • @ycliu49.10.1
    @ycliu49.10.1 ปีที่แล้ว +4

    Hi Stephen, I have been working in optics field (lidar, fiber coupling, and silicon semiconductor package) more than 10 years.This video is really great. It helped me review the principles of optics once again. Thank you.

  • @marknicholson5508
    @marknicholson5508 ปีที่แล้ว +2

    Great job Stephen! I think I may know why your BFL doesn't quite match OpticStudio's. OpticStudio defines the back focal length as the distance along the Z axis from the last surface made of glass to the paraxial image surface for the object at infinite conjugates. If your object isn't at infinite conjugates, you still need to do a ray-trace from infinity to compute BFL. This lets you compare the BFL of two lenses irrespective of conjugate ratio, or at least, at a fixed conjugate ratio.
    Hope that helps. Also, you didn't say but make sure your code is using double precision and not floats. As you trace surface by surface, errors accumulate. You don't specifically address how to handle the accumulation of errors, but the first place to start is to use doubles.

    • @stephenremillard1
      @stephenremillard1  ปีที่แล้ว +4

      Thanks Mark. Good point about double precision. Double is essential, especially given the number of quantities that rely on the difference between similar numbers. Because double precision is the default data type in MatLab, I got a little lazy and the importance of mentioning it didn't cross my mind, as it should have. So, thank you for bringing it up.
      I compute the BFL using an in-coming parallel ray at the height of the first clear semi-diameter. I didn't show the benchmarking with the infinite conjugate configuration of the telephoto lens, but it gave the same BFL as OpticStudio. Same too for the two periscopic lens models: finite and infinite conjugate. Of the four benchmarking models that I had Zemax screen shots for, the finite conjugate telephoto was the only model that had this small difference in the BFL. Small, but important. Maybe there's some detail that I didn't capture with the screen shot. Hopefully I'll find out some day when I fire up OpticStudio again.
      Regards,
      -Steve

  • @michaelbanach3741
    @michaelbanach3741 ปีที่แล้ว +3

    Great video, thanks!

  • @optiondrone5468
    @optiondrone5468 ปีที่แล้ว +2

    Stephen this was an excellent video, do you think you can make more videos which will teach novice like me all the fundamentals about optical simulation and eventually progress to self made optical simulation code development? Thank you again for such an excellent video

    • @stephenremillard1
      @stephenremillard1  ปีที่แล้ว +3

      Sure. Here are some: th-cam.com/play/PLmfHzApbF5dbx_S_h9A13uLm4LVK0f6XK.html

    • @optiondrone5468
      @optiondrone5468 ปีที่แล้ว

      @@stephenremillard1 thank you so much for those video links, I'm looking forward to going through them hopefully at the end I'll be able to write my own optical simulation program. Thank you for your help.

  • @brisingreye5209
    @brisingreye5209 5 หลายเดือนก่อน

    @Stephen Remillard. Could you explain the equation at line and 49 of your code (@7:18)? How did you come to this equation?
    thanks in advance!

    • @stephenremillard1
      @stephenremillard1  5 หลายเดือนก่อน +2

      Take a look at 3:46. This is the equation at the top of the screen, (n'u'=nu-y*phi). In Line 49, yt(i) is the chief ray height at surface i. uprime is the chief ray angle after the designated surface. So, uprime(i-1) is the chief ray angle incident at surface i, since it is the chief ray angle after surface i-1. Also, the angles are replaced with tangent of the angles to improve the accuracy.

  • @lfvlima6295
    @lfvlima6295 ปีที่แล้ว

    great job. do you have any tutorial video for metamaterials ou phononic crystals?

  • @manarc-cs6uv
    @manarc-cs6uv 3 หลายเดือนก่อน

    @Stephen Remillard. Hi Stephen, I am a student in optics.Could you explain the equation at line and 142 of your code (@15:11); In this section I don't konw the value EFL why not mentioned here?Also,I couldn't find the new variable EFL you used in line 159 (@15:49) in the previous code ? Please tell me the reason.

    • @stephenremillard1
      @stephenremillard1  3 หลายเดือนก่อน

      The quantity that is computed in the loop from lines 136 to 138 isn't the complete total track length. It is only the distance up to the last glass vertex. The back image distance still needs to be added to it in order to have the quantity that is typically referred to as total track length. The effective focal length is calculated on Line 152 (@15:37).

    • @manarc-cs6uv
      @manarc-cs6uv 3 หลายเดือนก่อน

      @@stephenremillard1 Thank You for your expaining, The problem has been solved。 But have a new problem , when I using your all code for learning MATLAB and Optical fundamental konwledge , the speed for program is to slowly .I let this code run for 15 minutes, and the code still has not jumped out of 44 lines of code to find the loop of the chief ray.(@8:23)

    • @stephenremillard1
      @stephenremillard1  3 หลายเดือนก่อน

      @manarc-cs6uv It sounds like the loop termination condition is either being missed, or not reached. You might try changing the size of the variable incr. Increase it a factor of 10 or decrease it a factor of 10. Then try factors of 100 or more if that doesn't work. If it is taking too long to complete the loop, then incr is too small. If it never completes, then incr might be too large - which is why I had to give it a small value.

    • @stephenremillard1
      @stephenremillard1  3 หลายเดือนก่อน

      I'll also add that a better programmer than I can come up with a better way to execute that operation in the red box @8:23. A while loop isn't very efficient, and is perhaps evidence of my Fortran 77 upbringing.

    • @manarc-cs6uv
      @manarc-cs6uv 3 หลายเดือนก่อน

      ​@@stephenremillard1 I tried the variables of reduction and enlarging INCR again, but it still seemed to be unable to meet the condition in the WHILE loop Done == 1.

  • @HarshPanchal-vt6qe
    @HarshPanchal-vt6qe 7 หลายเดือนก่อน

    sir can you share the code for this?