cihologramas / pyoptools

Python tools for optical design
GNU General Public License v3.0
137 stars 46 forks source link

Lens focus wrong? #94

Closed ldm78 closed 2 years ago

ldm78 commented 3 years ago

I had some trouble with a lens, so I made a minimal notebook to confirm the focal length. I attached it here: Toy.zip Basically I'm sending three parallel rays through a lens with a focal length of 300mm, and they intersect at 437mm instead. Am I doing something wrong, or is the surface of the lens too coarse for such a long focal length?

ldm78 commented 3 years ago

It can't be the surface voxelation, the values don't change if I change the separation of the parallel rays or the radius of the lens.

ramezquitao commented 3 years ago

I will check tomorrow what is going on.

El jue, 22 de abr. de 2021 a la(s) 12:42, ldm78 @.***) escribió:

It can't be the surface voxelation, the values don't change if I change the separation of the parallel rays or the radius of the lens.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cihologramas/pyoptools/issues/94#issuecomment-825055240, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPKS5SX4FK5RV4TG6LJZE3TKBNZXANCNFSM43LKJYLQ .

ramezquitao commented 3 years ago

I just checked your toy.zip file. There must be a numerical rounding issue with the spherical surfaces behaviour when the surface is very flat. I need to check what is going on. Still, if you use c2=0 (and not 1e-99), the SphericalLens constructor will use a flat surface instead an spherical one. In this case, the ray tracing seems to be working fine. Can you check and give me feedback?

ldm78 commented 3 years ago

Huh. I used that value because I got a division by zero error before. I'll try it out.

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Ricardo @.> Sent: Friday, April 23, 2021 12:29:15 PM To: cihologramas/pyoptools @.> Cc: Lars Martin @.>; Author @.> Subject: Re: [cihologramas/pyoptools] Lens focus wrong? (#94)

I just checked your toy.zip file. There must be a numerical rounding issue with the spherical surfaces behaviour when the surface is very flat. I need to check what is going on. Still, if you use c2=0 (and not 1e-99), the SphericalLens constructor will use a flat surface instead an spherical one. In this case, the ray tracing seems to be working fine. Can you check and give me feedback?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://can01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcihologramas%2Fpyoptools%2Fissues%2F94%23issuecomment-825872862&data=04%7C01%7Clmartin%40triumf.ca%7C98f3e02296644d4fd79208d9068e1511%7Cc20535109cb34679a2d38f442e03b587%7C1%7C0%7C637548029582396994%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=fD9k%2FE9vMsah72qwJ4FG2f%2FnZnv3yRmZaIf82%2FlLOA4%3D&reserved=0, or unsubscribehttps://can01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAMBAA6GT46FOJ5266VBKOGDTKHDAXANCNFSM43LKJYLQ&data=04%7C01%7Clmartin%40triumf.ca%7C98f3e02296644d4fd79208d9068e1511%7Cc20535109cb34679a2d38f442e03b587%7C1%7C0%7C637548029582396994%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=4E2g9PYqlhkYTqR9T51u1TYLIIcZNZXQVCDCF1CZUu4%3D&reserved=0.

ederag commented 2 years ago

@ldm78 Thanks for providing a fine minimal example ! With c2 = 0, paraxial_constants indeed fails with division by zero (I have a fix, to submit after #116 is merged. With this fix, the notebook runs, and the focal length is correct).

c2 = 1e-9yields 3.00066643e+02, close enough to the expected 300 mm, but for c2 = 1e-10, it jumps to the 4.37294252e+02, which is close to the 437 mm observed for c2 = 1e-99.

ramezquitao commented 2 years ago

@ederag #116 is merged.

ederag commented 2 years ago

Thanks, #119 fixes the warning itself.