Paraxial focal length: fix wrong sign for negative lenses#382
Paraxial focal length: fix wrong sign for negative lenses#382rjmoerland wants to merge 4 commits intoHarrisonKramer:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## master #382 +/- ##
==========================================
+ Coverage 92.81% 92.99% +0.18%
==========================================
Files 245 303 +58
Lines 13839 17766 +3927
==========================================
+ Hits 12845 16522 +3677
- Misses 994 1244 +250
... and 129 files with indirect coverage changes 🚀 New features to boost your workflow:
|
|
Hi @rjmoerland, Sorry for the delay. It's been a long week. I had a chance to go through this in more detail. Thanks for submitting this! I think your reasoning checks out in most cases, though I wonder if there might be a simpler, more physically direct way to determine the sign. From a paraxial optics standpoint, the sign of the effective focal length should follow naturally from how a parallel input ray exits the system. That's essentially the same information contained in the ABCD matrix, but obtainable from a single paraxial ray trace. In principle, (i think) tracing one ray parallel to the optical axis and taking the ratio I’ll try to verify that this gives consistent results with your current implementation, but if it does, it might simplify the logic quite a bit. Thanks, |
|
No worries, all good. I realized in the mean time that this does not fix the sign for mirror optics. That'll need another fix. I'm not sure you can get away from considering internal foci, but if you can that's great, and for sure I'd appreciate it if you critically look at my reasoning. I was also thinking about a more general approach, since the code (seems to) assume that all optical elements are on a straight line, even though the real rays can be traced in 3D space. It would be great if the paraxial tracing would equally "not care" about 45° mirrors and such. I am thinking along the lines of tracings a (paraxial) ray along the optical axis with normal (x, y, z) = (0,0,1), and tracing a ray at (say) +1.0 Y with normal (0,0,1). Where these two rays end up on the last surface defines the orientation of the projection of the coordinate system. The +y axis' origin on the last surface is wherever the paraxial ray along the optical axis ended, and the positive direction is wherever the ray starting at y=+1 ended up. I think that the same information that currently is used in the code (plus or minus y, plus or minus u) is present in those vectors, and my expectation is that the sign of the cross product of the "local" y and the ray leaving the last surface should tell us something about the sign of the focus. Would need to write it out to be sure though. |
|
Hey @HarrisonKramer , did you manage to find some time to look into a potential simplification? |
I would like to see the implementation too. When you get to know about it, it is not big deal but probably there will someone else in future coming with the same issue. |
|
Hi @rjmoerland and @ZvejysMegejas, Sorry for the long delay! I missed this one. I revisited this and think we can solve it by making two changes:
I am not certain, but I think the But please, check my logic. Do you agree with the simple approach above? I quickly checked this against a commercial tool and see it gives the correct signs. Thanks, |
|
Hi @HarrisonKramer , yeah, I had to get a misconception out of my head. I've checked your proposed solution (in air) with Winlens3D Basic and OSLO EDU, and both agree with your formula. Shall I update the PR to what you proposed while keeping the extra pytests I introduced? |
|
Hi @rjmoerland, yes, that would be great if you can implement this, and thanks for double checking the calculation against other tools. You can confirm the logic, but you should be able to retrieve the unsigned image-space index via the standard Thanks again, |
Why
The paraxial back focal length
f2of a negative lens is returned as a positive number by Optiland:Output:
50.0. The code contained abe.abs([...])statement that, when removed, would return the correct value of -50 for this negative lens. However, it would also return a negative value for compound lenses that, overall, have a positive focal length, but contain an internal focus, as the sign of the ray's y-location is not taken into account.Implementation
I've updated the logic, where I hopefully make the correct choice depending on the ray location, slope, and whether or not there are internal foci:
I've checked that a lens system is considered positive, even if the focal plane is inside the system, with Winlens3D (Basic) and OpTaliX. All (py) tests I could think of now check out, but it's worth having a critical review. FWIW, all new pytests that I thought of fail on
master, which I think is a good sign.I've learned more about paraxial ray tracing than I ever wanted to (also, not as trivial as it sounds 😅 )