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!
Post Reply
drmacro
Veteran
Posts: 8865
Joined: Sun Mar 02, 2014 4:35 pm

Re: Optics Workbench

Post by drmacro »

Boogieman wrote: Mon Aug 23, 2021 2:15 pm
drmacro wrote: Sun Aug 22, 2021 10:24 pm good to know, I'll tinker more tomorrow...thanks.
I just saw that your ray has some differing properties in the View-Tab.
In "Line Material" and "Shape Material" there just is "<Material Object>" instead of all the sub parameter for these settings.
Are you using the latest version of the OpticsWB? Which FreeCAD version do you have?
If you cannot solve this right away by updating and reseting/restarting, its maybe better to open an issue at https://github.com/chbergmann/OpticsWorkbench/issues an continue the discussion there.
I installed Optics WB from git yesterday.

FreeeCAD:
OS: Debian GNU/Linux 10 (buster) (XFCE/lightdm-xsession)
Word size of FreeCAD: 64-bit
Version: 0.20.25544 (Git)
Build type: Release
Branch: master
Hash: dcaab146c129ffc3b5d55616d04301539496b40f
Python version: 3.7.3
Qt version: 5.11.3
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
christi
Posts: 203
Joined: Wed Oct 24, 2018 7:03 am
Location: Karlsruhe, Germany
Contact:

Re: Optics Workbench

Post by christi »

drmacro wrote: Sun Aug 22, 2021 7:02 pm I'm missing something simple I think.

I ran the example1.py and it did work.

I made a sketch and a lens and a ray.

But, can't seem to get any refraction... :(
There was a bug. A ray did not see sketches which were not at position (0 ,0 ,0)
I fixed it. Please update the workbench and try again.
drmacro
Veteran
Posts: 8865
Joined: Sun Mar 02, 2014 4:35 pm

Re: Optics Workbench

Post by drmacro »

Looks like that got it!

Thanks!
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Hero Of Monkeys
Posts: 1
Joined: Tue Aug 24, 2021 1:54 am

Re: Optics Workbench

Post by Hero Of Monkeys »

Amazing workbench, I am using it to design a parabolic mirror for a 3D printed red dot. Keep the good work.
Last edited by Hero Of Monkeys on Tue Aug 24, 2021 2:25 am, edited 2 times in total.
User avatar
Boogieman
Posts: 34
Joined: Wed Apr 18, 2018 9:03 am

dispersion

Post by Boogieman »

I've added dispersion to the workbench.

Image
Image
Image

The calculation is based on Cauchy equation. You can see the Cauchy coefficients A and B in the properties panel for dense flint glass.
It is not quite finished yet but would polish it if you are interested in getting it in the main workbench branch.

This is the code to generate the rays

Code: Select all

import OpticsWorkbench
import math
from FreeCAD import Vector, Rotation
import numpy as np
from numpy import linspace

a=App.activeDocument()

num_rays = 100
for l in linspace(400, 800, num_rays):
	r = OpticsWorkbench.makeRay(position = Vector(0, 0, 0), wavelength=l)
	r.ViewObject.LineWidth = 1

	group = a.getObject('Group')
	r.adjustRelativeLinks(group)
	group.addObject(r)
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Optics Workbench

Post by Kunda1 »

Yes, please! That's awesome!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
drmacro
Veteran
Posts: 8865
Joined: Sun Mar 02, 2014 4:35 pm

Re: Optics Workbench

Post by drmacro »

I am experimenting with the workbench. It is really helpful for visualizing lens systems, thanks!
Some questions/observations.

1) When I open a file with optic elements I get:

Code: Select all

08:29:19  Traceback (most recent call last):
  File "/home/mac/.FreeCAD/Mod/OpticsWorkbench/Ray.py", line 53, in onChanged
    self.redrawRay(fp)
  File "/home/mac/.FreeCAD/Mod/OpticsWorkbench/Ray.py", line 85, in redrawRay
    insiders = self.isInsideLens(ray.Vertexes[0])
  File "/home/mac/.FreeCAD/Mod/OpticsWorkbench/Ray.py", line 271, in isInsideLens
    if obj.Shape.distToShape(Part.Vertex(vertex))[0] < EPSILON:
<class 'RuntimeError'>: BRepExtrema_DistShapeShape failed
2) When I change the Refraction index property. The first change automatically updates the refraction path of the ray. Sometimes, further changes in the index update the ray, sometimes not. (I have yet to tie down a repeatable sequence to replicate, sorry.)

3) The refraction path doesn't seem to work if the sketch is on other than the X, Y plane.

4) The lens container has a Placement object, but changes don't seem to have any effect. The Placement object of the contained sketch does move the sketch and effect the refraction path. (this is in a sketch on the X, Y plane; neither has any effect on a sketch on other planes.)

5) The default length of the Ray at 1 million make 3D view navigation a bit cumbersome and I always immediately set it to a more manageable 100. (obviously this would need to be increased based on the design of the lens system) Is/would it possible to set this default as a preference?



OS: Debian GNU/Linux 10 (buster) (XFCE/lightdm-xsession)
Word size of FreeCAD: 64-bit
Version: 0.20.25553 (Git)
Build type: Release
Branch: master
Hash: 08736cb4ce42f7bddf9419b48b4f4153da4d6cfa
Python version: 3.7.3
Qt version: 5.11.3
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Optics Workbench

Post by Kunda1 »

Can we add optics version number in to the workbench name like Trails and other workbenches do? That way we know what version of optics people are using when they report bugs...
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
christi
Posts: 203
Joined: Wed Oct 24, 2018 7:03 am
Location: Karlsruhe, Germany
Contact:

Re: dispersion

Post by christi »

Boogieman wrote: Wed Aug 25, 2021 12:35 am I've added dispersion to the workbench.
This is great !
There is one think we have to consider before we add it to the workbench: What happens if a dispersed ray hits another mirror or lens ?
Also with a lens you always have two dispersions, when the ray enters the lens and when it exits the lens.
Did you already fork the OpticsWorkbench on Github ?
User avatar
christi
Posts: 203
Joined: Wed Oct 24, 2018 7:03 am
Location: Karlsruhe, Germany
Contact:

Re: Optics Workbench

Post by christi »

Kunda1 wrote: Thu Aug 26, 2021 4:20 pm Can we add optics version number in to the workbench name like Trails and other workbenches do? That way we know what version of optics people are using when they report bugs...
We do not make releases with a version number on our workbenches on Github. I am not sure if we really need versions and where to place and show the version number.
The Trails workbench has a file version.py that contains

Code: Select all

__version__ = "0.01"
I guess this number has never been updated.
Post Reply