Optics Workbench
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
Optics Workbench
Hallo FreeCAD fans,
I have created an new workbench for geometrical optics simulation
Until it is unfinished and not installable from the Addons menu, you can download it here:
https://github.com/chbergmann/OpticsWorkbench
I have created an new workbench for geometrical optics simulation
Until it is unfinished and not installable from the Addons menu, you can download it here:
https://github.com/chbergmann/OpticsWorkbench
Last edited by christi on Tue Jul 13, 2021 5:12 pm, edited 1 time in total.
Re: Optics Workbench
There are lots of tools for geometrical optics simulation in the internet. But they all use there own libraries and GUI elements. Porting this to FreeCAD is not easy.johnwang wrote: ↑Sun Jul 04, 2021 1:03 am Has anyone play with this KDP-2 from http://ecalculations.com/ An old Fortran design program
And there is a Koko which is based on KDP-2, its longer-term plan is to integrate with FreeCAD
https://github.com/dinosauria123/Koko
The main part of my Optics workbench is not the optical physics, which is quite easy. The main part of the work is to get it work with FreeCAD objects.
I make use of the openCascade library that is integrated in FreeCAD. Most of the needed vector arithmetics functions are already included there.
Last edited by christi on Sun Jul 04, 2021 9:25 am, edited 1 time in total.
Re: Optics Workbench
I have pushed some Bugfixes. Please update the workbench and try again.spanner888 wrote: ↑Sat Jul 03, 2021 10:38 pmLooks especially nice for simpler use cases than many optics tools I have looked at...and not used.
However in my own dumb user klutz fashion, I have not quite understood how to define the elements. It would be very usefull if you could share the FreeCAD model of your example, so I can get past whatever sillyness I have done to cause below (just two sketches, each with one line, and one sketch made into a mirror, then adding a Ray gives below)
If I select the second sketch, then the mirror and try to create a ray, then get the same error again.Code: Select all
08:06:28 Illegal storage access... 08:06:28 Traceback (most recent call last): File "C:\Users\spanner888\AppData\Roaming\FreeCAD\Mod\OpticsWorkbench\Ray.py", line 40, in execute self.redrawRay(fp) File "C:\Users\spanner888\AppData\Roaming\FreeCAD\Mod\OpticsWorkbench\Ray.py", line 64, in redrawRay self.traceRay(fp, pos, linearray) File "C:\Users\spanner888\AppData\Roaming\FreeCAD\Mod\OpticsWorkbench\Ray.py", line 95, in traceRay isec = line.Curve.intersectCC(edge.Curve) <class 'RuntimeError'>: Illegal storage access! Please save your work under a new file name and restart the application!
Then I tried making another sketch with a rectangle and made that an absorber, but still get above error trying to add a Ray, so your example file would help me work out how to correctly use your addon.
There is also an example available. Menu Optics -> Example 1
-
- Posts: 327
- Joined: Tue May 28, 2019 10:51 am
Re: Optics Workbench
Thanks for the quick reply & the updates.
That is a very interesting way to create an example, I like it, and it works well.
I am still having some issues when I create a ray in the GUI, but noting your very new release comments, I will be patient, especially as I just released some code to the forum today as well!
Mean while, I will tweak your example code for the situation I want to test.
Thanks for a very interesting workbench.
That is a very interesting way to create an example, I like it, and it works well.
I am still having some issues when I create a ray in the GUI, but noting your very new release comments, I will be patient, especially as I just released some code to the forum today as well!
Mean while, I will tweak your example code for the situation I want to test.
Thanks for a very interesting workbench.
-
- Posts: 327
- Joined: Tue May 28, 2019 10:51 am
Re: Optics Workbench
I begin to see scripting is a very good way to use your workbench. At the moment just placing Rays for several light sources (soon at different heights and angles) and showing the beam spread and mirrored reflections into a lens.spanner888 wrote: ↑Sun Jul 04, 2021 10:36 am Mean while, I will tweak your example code for the situation I want to test.
So scripting allows easy copy/paste/edit and looping to create all the rays at different angles and positions.
Re: Optics Workbench
Here two gems to test the future 3D feature.
- Attachments
-
- RoundBrilliantCopy.FCStd
- (16.93 KiB) Downloaded 234 times
-
- TrillantHeartCopy.FCStd
- (20.83 KiB) Downloaded 203 times
Re: Optics Workbench
Nice work!
Greetings
user1234
Greetings
user1234
Re: Optics Workbench
3D support has been added, but it is not very accurate.
I have the problem that I cannot determine the exact position of a normal on a 3D surface.
There is an API function Surface.normalAt(u,v). I have a Point on the surface in form of a Vector(x,y,z)
Does anybody know how to get the parameters u and v from the vector ?
I have the problem that I cannot determine the exact position of a normal on a 3D surface.
There is an API function Surface.normalAt(u,v). I have a Point on the surface in form of a Vector(x,y,z)
Does anybody know how to get the parameters u and v from the vector ?
Re: Optics Workbench
Fixed it. Mirroring in 3D space works now.