Optics Workbench

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
AeluVidy
Posts: 1
Joined: Mon Jun 03, 2019 11:56 am
Contact:

Re: Optics Workbench

Post by AeluVidy »

@christi & other contributors : Thank a lot for all the job done, this is a very useful and wonderful workbench

I'm testing it making a little project that I have in mind for a long time, it's a DIY Newtonian telescope to look at sky with kids thank to a little convergent mirror that I bought online and a Raspberry Pi with a HQ camera. We will see maybe around Christmas, I'll be maybe ready.

Image
https://github.com/GAvidu1983/OpticsWor ... xample.png

I've also allowed me to fork your project. I would like to add an element in the workbench : a theoretical Lens. Because in practice, how I work indeed, I just want for instance a lens with a focal of x mm that is maybe achromatic and with a given diameter and thickness. I bought it in this shop, and when I'm making the CAD, I don't to waste time to model in detail the curvatures of the lens, only the optical effect is interesting. People often don't care about the exact curvature of the lens that you are using at the end. You care about it only if you produce it, but this is really not a common case, very interesting took. So I've done a new branch, when it will work approximately enough well I'll make a new sign.


Image
https://github.com/GAvidu1983/OpticsWor ... xample.png
---
Aeluvidy
Cobras62
Posts: 14
Joined: Thu Oct 28, 2021 9:37 am

Re: Optics Workbench

Post by Cobras62 »

Hi,
Great job AeluVidy!
It's indeed interesting as a new tool! Is it possible to do the same with mirrors?
Otherwise for a project, I had been downloading the step files of the lenses at Thorlabs website.
Thank you all for your work and for ensuring that this workshop and more generally FreeCad continue to develop!
@christi : normally, Freecad and Optics Workbench will be named in a scientific publication ;)
User avatar
christi
Posts: 203
Joined: Wed Oct 24, 2018 7:03 am
Location: Karlsruhe, Germany
Contact:

Re: Optics Workbench

Post by christi »

@AeluVidy: This is a great enhancement for the Optics workbench. Please do a pull request when you are ready. I will merge it into the main branch then.
Last edited by christi on Sun Nov 21, 2021 9:21 am, edited 1 time in total.
User avatar
christi
Posts: 203
Joined: Wed Oct 24, 2018 7:03 am
Location: Karlsruhe, Germany
Contact:

Re: Optics Workbench

Post by christi »

I fixed a little bug in Snells Law algorithm. If you are using lenses, please update the workbench ! Sorry for this.
Cobras62
Posts: 14
Joined: Thu Oct 28, 2021 9:37 am

Re: Optics Workbench

Post by Cobras62 »

christi wrote: Sun Nov 21, 2021 9:06 am I fixed a little bug in Snells Law algorithm. If you are using lenses, please update the workbench ! Sorry for this.
Hi Christi,
The workshop is up to date on github?
On the website, it is noted that the last update was 15 days ago.
Thank you.
User avatar
christi
Posts: 203
Joined: Wed Oct 24, 2018 7:03 am
Location: Karlsruhe, Germany
Contact:

Re: Optics Workbench

Post by christi »

Cobras62 wrote: Mon Nov 22, 2021 12:24 pm Hi Christi,
The workshop is up to date on github?
On the website, it is noted that the last update was 15 days ago.
Thank you.
Yes, github is up to date
Cobras62
Posts: 14
Joined: Thu Oct 28, 2021 9:37 am

Re: Optics Workbench

Post by Cobras62 »

Ok!
Thank you!
;)
joha2
Posts: 303
Joined: Tue Oct 11, 2016 9:48 pm

Re: Optics Workbench

Post by joha2 »

christi wrote: Sun Nov 07, 2021 9:10 am ping
HoWil wrote: Sat Nov 06, 2021 12:40 pm ping
Hey guys! Sorry for my late response (somehow I get no emails when noticed in some thread)! :cry: :shock: :twisted:

Definitely it is on our agenda to support FreeCAD objects, but we wanted to first provide a core code which can be used without FreeCAD and then write some interface to FreeCAD. Unfortunately, the development of pyrate is very slow during the last months and we still have some conceptional problems. The FreeCAD interface for us is also not clear, since we do not have a good idea how to manage a loose coupling which we don't have to rewrite completely once the API changes a little.

Our base object is ClassWithOptimizableVariables (horrible name :mrgreen:) and we want to interface that into FreeCAD. Some suggestions on this can be found, e.g., in https://salsa.debian.org/mess42/pyrate/ ... eWorkbench

Actually that ClassWithOptimizableVariables interface is one thing. Another thing to consider is how to interact with the FreeCAD geometry (e.g. using geometry for refracting or reflecting rays). This is something which is considered a new feature and is postponed until we solve the problems at hand with our core code. But mockup code for this is still appreciated, if anybody wants to contribute to this feature. (For this one has to decompose the geometry into several surfaces, which can be done in FreeCAD. Then every surface has to be incorporated into a Surface object with its own local coordinate system and aperture. Maybe this could be the global coordinate system since all intersection points are calculated in global coordinates anyway be FreeCAD. I think it should be possible doing this by deriving from the classes OpticalElement and Shape. It is still to be decided which parts of the calculation are done by FreeCAD and which by pyrate core code, but that's details.)

Hope this helps for a little insight into pyrate.

Best wishes
Johannes

Edit: Some old thread (in german) where I described the problem: https://forum.freecadweb.org/viewtopic. ... 90#p175297 The link there is broken, so please have a look at https://salsa.debian.org/mess42/pyrate/ ... cad/Macros for the appropriate files.
User avatar
christi
Posts: 203
Joined: Wed Oct 24, 2018 7:03 am
Location: Karlsruhe, Germany
Contact:

Re: Optics Workbench

Post by christi »

joha2 wrote: Sat Dec 18, 2021 11:55 pm Hope this helps for a little insight into pyrate.
Hi Joha, thanks for your insight into pyrate.

I will try to give an insight into the Optics workbench.
As you see there is not much code. The main work is done in Ray.py
The way it works is:
- Create a line (ray) with infinite length
- Find all intersection points with any FreeCAD geometry
- Find the nearest intersection point that is part of an OpticalObject (=lens, mirror or absorber)
- Create a mirrored or refracted ray with the help of the normal vector on the intersection point

You can get all surfaces of a FreeCAD object if you loop through Shape.Faces. Each face has a surface component, but there are many different types of surface. See section GeometrySurface(Geometry) in Part.html in the automatic Python modules documentation. The conversion should be simple if the FreeCAD type equals a surface type in pyrate.
User avatar
PJT
Posts: 33
Joined: Sun Aug 15, 2021 9:39 pm

Re: Optics Workbench

Post by PJT »

Hello. Thanks for making this really nice tool. I am starting to learn how to use it. Please can you tell me how to adjust the angle and position of a SunRay? I have one SunRay which I use as the optical axis ray. I would like to add another SunRay at a particular offset and angle to the first to I can see the effect of some optics on both the chromatic dispersion and focus point where the two SunRays converge. Each SunRay appears as a folder of 100 ray objects and I don't want to go round transforming each one manually if I can help it! Thanks.
Post Reply