Optics in FreeCAD

Show off your FreeCAD projects here!
DeepSOIC
Posts: 4679
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Optics in FreeCAD

Postby DeepSOIC » Sat Sep 20, 2014 4:02 pm

Hi
I want to share some tricks (building blocks) for optics design. With the ellipse support that is coming, FreeCAD looks like a promising tool for simple optics design.
I have only two right now, but maybe more will come later
Attachments
Snells law.FCStd.png
Snell's law constraint screenshot. set the distances according to refraction indices of media.
Snells law.FCStd.png (15.46 KiB) Viewed 5178 times
Snells law.FCStd
Snell's law constraint. Set the distances according to refraction indices of media.
(2.94 KiB) Downloaded 63 times
spherical_refl.png
demonstration of aberration when focusing parallel beam using spherical reflector.
spherical_refl.png (20.59 KiB) Viewed 5178 times
spherical_refl.FCStd
demonstration of aberration when focusing parallel beam using spherical reflector.
(3.1 KiB) Downloaded 60 times
DeepSOIC
Posts: 4679
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Optics in FreeCAD

Postby DeepSOIC » Sat Sep 20, 2014 4:50 pm

Here's another one, a bit more interesting: simulation of a thick lens.
This lens was drawn by accident and wasn't actually engineered. It is here just to demonstrate that one can simulate a ray passing through it.
Attachments
thick_lens_simulation.FCStd.png
simulation of a thick lens (screenshot)
thick_lens_simulation.FCStd.png (37.75 KiB) Viewed 5164 times
thick_lens_simulation.FCStd
simulation of a thick lens
(3.83 KiB) Downloaded 53 times
DeepSOIC
Posts: 4679
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Optics in FreeCAD

Postby DeepSOIC » Sun Dec 14, 2014 12:00 am

I have written a built-in Snell's law constraint for the sketcher, and playing with refraction has just become very easy.
ellipsoid-spherical lens at an angle.png
ellipsoid-spherical lens at an angle.png (175.61 KiB) Viewed 4065 times
This lens perfectly focuses a parallel beam of light into a point when it's along optical axis, but sucks at focusing the beam when it is at an angle. Does this explain why human eye has poor peripheral vision :roll: ?

To use the model, FreeCAD with the constraint is needed. You'll have to compile it from my branch, or use my Windows build (and possibly get my viruses ;) ). Check out Optical constraints development forum thread for the links.

If anyone wants to see this in master, please let me know.
Attachments
ellipsoid-spherical lens at an angle.FCStd
(6.49 KiB) Downloaded 43 times
Last edited by DeepSOIC on Tue Mar 03, 2015 11:50 pm, edited 1 time in total.
Reason: Uploaded a repaired FCStd. The original was created in early development version and didn't work in current master.
cox
Posts: 915
Joined: Wed Nov 26, 2014 11:37 pm

Re: Optics in FreeCAD

Postby cox » Sun Dec 14, 2014 3:21 pm

I find your work fasinating and wold definitely like to see it in master.

Thank you for sharing

Keep up the good work.
Need help? Feel free to ask, but please read the guidelines first
DeepSOIC
Posts: 4679
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Optics in FreeCAD

Postby DeepSOIC » Sun Dec 14, 2014 11:45 pm

Thanks cox!
DeepSOIC
Posts: 4679
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Optics in FreeCAD

Postby DeepSOIC » Thu Mar 16, 2017 10:50 pm

My first ever attempt at ray-tracing. I gave a try to OCC's super new CAD Rays.

I mocked up a scene, with a lens I thought I designed to focus perfectly...
lens scene cad.png
lens scene cad.png (30.69 KiB) Viewed 1666 times

And I tried to render it, in hope to see the image of objects in front of the lens. But all I got was lots of stray light, and no actual image. Then I removed the objects, and placed a light source. At first, I got something strange and very slowly, but I realized I forgot to switch off the sun :mrgreen: , and after doing that...
lens scene.png
lens scene.png (642.63 KiB) Viewed 1666 times
To my disappointment, the result is still very noisy after a few minutes of waiting. :( But it definitely shows something useful. It demonstrates that my lens is very far from perfect. All that halo around the image...

So I went back to FreeCAD, and checked the design. Sure enough...
lens scene lens design.png
lens scene lens design.png (414.16 KiB) Viewed 1666 times


It's definitely cool to see stuff like this! But I'm not happy with the UI of CADRays. It's strange. Moving around is hard. It often becomes very laggy, so I have to switch over to opengl rendering. It doesn't like touchscreen input, and even with pen, I often find out CADRays decided I want to drag the wrong numberbox, or reset my hue value of color, or not accept light source power below 1.0...

I want gesture navigation style from FreeCAD to be in there! I still have not figured out how to pan! (apart from AWSD)
Attachments
lens-scene.FCStd
(25.97 KiB) Downloaded 9 times
DeepSOIC
Posts: 4679
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Optics in FreeCAD

Postby DeepSOIC » Thu Mar 16, 2017 11:27 pm

Now we are talking. Rectified my lens design, focuses perfectly!
correct lens.png
correct lens.png (304.83 KiB) Viewed 1648 times
User avatar
kkremitzki
Posts: 359
Joined: Thu Mar 03, 2016 9:52 pm
Location: Texas

Re: Optics in FreeCAD

Postby kkremitzki » Fri Mar 17, 2017 12:12 am

Now that's pretty dang cool! 8-)
DeepSOIC
Posts: 4679
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Optics in FreeCAD

Postby DeepSOIC » Fri Mar 17, 2017 12:37 am

Got an image of some stuff through the lens!
lens-scene 2 render.png
lens-scene 2 render.png (261.71 KiB) Viewed 1632 times

On AMD Radeon 7700 and with regular mouse, CADRays is behaving much much better, and makes a nice rendering faster.
ian.rees
Posts: 581
Joined: Sun Jun 15, 2014 3:28 am
Contact:

Re: Optics in FreeCAD

Postby ian.rees » Fri Mar 17, 2017 4:42 am

Bonus points for hooking this up with FEM and melting something with focused light ;). -Ian-