chbergmann / OpticsWorkbench

GNU Lesser General Public License v3.0
69 stars 23 forks source link

Dispersion feature #14

Closed wohltat closed 2 years ago

wohltat commented 2 years ago

fixed the examples and added a new one for dispersion

chbergmann commented 2 years ago

you have forgotten to add the file examples/example_dispersion.py

chbergmann commented 2 years ago

If I run the 2D example, I get these errors:

18:31:27 Quantity::operator -(): Unit mismatch in minus operation 18:31:27 Traceback (most recent call last): File "/home/christi/.FreeCAD/Mod/OpticsWorkbench/Ray.py", line 55, in execute self.redrawRay(fp) File "/home/christi/.FreeCAD/Mod/OpticsWorkbench/Ray.py", line 117, in redrawRay rgb = wavelen2rgb(fp.Wavelength) File "/home/christi/.FreeCAD/Mod/OpticsWorkbench/wavelength_to_rgb/gentable.py", line 58, in wavelen2rgb green = -(nm - 645.0) / (645.0 - 580.0) <class 'ArithmeticError'>: {'sclassname': 'N4Base18UnitsMismatchErrorE', 'sErrMsg': 'Quantity::operator -(): Unit mismatch in minus operation', 'sfile': '', 'iline': 0, 'sfunction': '', 'swhat': 'Quantity::operator -(): Unit mismatch in minus operation', 'btranslatable': False, 'breported': True} 18:31:27 Quantity::operator -(): Unit mismatch in minus operation 18:31:27 Traceback (most recent call last): File "/home/christi/.FreeCAD/Mod/OpticsWorkbench/Ray.py", line 55, in execute self.redrawRay(fp) File "/home/christi/.FreeCAD/Mod/OpticsWorkbench/Ray.py", line 117, in redrawRay rgb = wavelen2rgb(fp.Wavelength) File "/home/christi/.FreeCAD/Mod/OpticsWorkbench/wavelength_to_rgb/gentable.py", line 58, in wavelen2rgb green = -(nm - 645.0) / (645.0 - 580.0) <class 'ArithmeticError'>: {'sclassname': 'N4Base18UnitsMismatchErrorE', 'sErrMsg': 'Quantity::operator -(): Unit mismatch in minus operation', 'sfile': '', 'iline': 0, 'sfunction': '', 'swhat': 'Quantity::operator -(): Unit mismatch in minus operation', 'btranslatable': False, 'breported': True} 18:31:27 Quantity::operator -(): Unit mismatch in minus operation 18:31:27 {'sclassname': 'N4Base18UnitsMismatchErrorE', 'sErrMsg': 'Quantity::operator -(): Unit mismatch in minus operation', 'sfile': '', 'iline': 0, 'sfunction': '', 'swhat': 'Quantity::operator -(): Unit mismatch in minus operation', 'btranslatable': False, 'breported': True}

chbergmann commented 2 years ago

You can get rid of the error above if you change App::PropertyLength to App::PropertyFloat in Ray.py line 47

wohltat commented 2 years ago

you have forgotten to add the file examples/example_dispersion.py

Ah damn, you are right. Wait a sec...

wohltat commented 2 years ago

I don't get errors with the PropertyLength, but i don't think it's absolutely necessary. Just though it is nice to have the units attached. I can change it but why are we seeing different behavior?

wohltat commented 2 years ago

I can change it but why are we seeing different behavior?

Btw, which version of FC are you using?