optics_design_workbench 0.4.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. optics_design_workbench-0.4.3/.gitattributes +2 -0
  2. optics_design_workbench-0.4.3/.github/workflows/python-app.yml +34 -0
  3. optics_design_workbench-0.4.3/.gitignore +28 -0
  4. optics_design_workbench-0.4.3/LICENSE.txt +66 -0
  5. optics_design_workbench-0.4.3/MANIFEST.in +2 -0
  6. optics_design_workbench-0.4.3/PKG-INFO +183 -0
  7. optics_design_workbench-0.4.3/README.md +97 -0
  8. optics_design_workbench-0.4.3/examples/1-source-and-detector/main.FCStd +0 -0
  9. optics_design_workbench-0.4.3/examples/1-source-and-detector/main.ipynb +70 -0
  10. optics_design_workbench-0.4.3/examples/1-source-and-detector/screenshot-monte-carlo.png +0 -0
  11. optics_design_workbench-0.4.3/examples/1-source-and-detector/screenshot-ray-fan.png +0 -0
  12. optics_design_workbench-0.4.3/examples/2-lens-and-mirror/main.FCStd +0 -0
  13. optics_design_workbench-0.4.3/examples/2-lens-and-mirror/screenshot.png +0 -0
  14. optics_design_workbench-0.4.3/examples/3-parameter-sweeps/main.FCStd +0 -0
  15. optics_design_workbench-0.4.3/examples/3-parameter-sweeps/main.OpticsDesign/notebooks/sweep.ipynb +214 -0
  16. optics_design_workbench-0.4.3/freecad/optics_design_workbench/__init__.py +68 -0
  17. optics_design_workbench-0.4.3/freecad/optics_design_workbench/detect_pyside.py +58 -0
  18. optics_design_workbench-0.4.3/freecad/optics_design_workbench/distributions/__init__.py +11 -0
  19. optics_design_workbench-0.4.3/freecad/optics_design_workbench/distributions/points_by_density.py +198 -0
  20. optics_design_workbench-0.4.3/freecad/optics_design_workbench/distributions/random_number_generator.py +652 -0
  21. optics_design_workbench-0.4.3/freecad/optics_design_workbench/freecad_elements/__init__.py +26 -0
  22. optics_design_workbench-0.4.3/freecad/optics_design_workbench/freecad_elements/common.py +40 -0
  23. optics_design_workbench-0.4.3/freecad/optics_design_workbench/freecad_elements/find.py +114 -0
  24. optics_design_workbench-0.4.3/freecad/optics_design_workbench/freecad_elements/generic_source.py +208 -0
  25. optics_design_workbench-0.4.3/freecad/optics_design_workbench/freecad_elements/optical_group.py +190 -0
  26. optics_design_workbench-0.4.3/freecad/optics_design_workbench/freecad_elements/point_source.py +381 -0
  27. optics_design_workbench-0.4.3/freecad/optics_design_workbench/freecad_elements/ray.py +294 -0
  28. optics_design_workbench-0.4.3/freecad/optics_design_workbench/freecad_elements/replay_source.py +197 -0
  29. optics_design_workbench-0.4.3/freecad/optics_design_workbench/freecad_elements/simulation_actions.py +81 -0
  30. optics_design_workbench-0.4.3/freecad/optics_design_workbench/freecad_elements/simulation_settings.py +247 -0
  31. optics_design_workbench-0.4.3/freecad/optics_design_workbench/gui_windows/__init__.py +11 -0
  32. optics_design_workbench-0.4.3/freecad/optics_design_workbench/gui_windows/common.py +7 -0
  33. optics_design_workbench-0.4.3/freecad/optics_design_workbench/gui_windows/progress.py +171 -0
  34. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/absorber.svg +542 -0
  35. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/add-absorber.svg +562 -0
  36. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/add-lens.svg +517 -0
  37. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/add-mirror.svg +475 -0
  38. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/add-pointsource.svg +477 -0
  39. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/add-replaysource.svg +479 -0
  40. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/add-settings.svg +478 -0
  41. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/add-vacuum.svg +494 -0
  42. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/clear.svg +462 -0
  43. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/fans.svg +490 -0
  44. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/lens.svg +497 -0
  45. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/mirror.svg +455 -0
  46. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/pointsource.svg +457 -0
  47. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/pseudo.svg +438 -0
  48. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/reload.svg +442 -0
  49. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/replaysource.svg +462 -0
  50. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/settings-inactive.svg +466 -0
  51. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/settings.svg +466 -0
  52. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/singlepseudo.svg +450 -0
  53. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/singletrue.svg +460 -0
  54. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/stop.svg +440 -0
  55. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/true.svg +442 -0
  56. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/vacuum.svg +474 -0
  57. optics_design_workbench-0.4.3/freecad/optics_design_workbench/icons/workbench.svg +519 -0
  58. optics_design_workbench-0.4.3/freecad/optics_design_workbench/init_gui.py +67 -0
  59. optics_design_workbench-0.4.3/freecad/optics_design_workbench/io.py +237 -0
  60. optics_design_workbench-0.4.3/freecad/optics_design_workbench/jupyter_utils/__init__.py +19 -0
  61. optics_design_workbench-0.4.3/freecad/optics_design_workbench/jupyter_utils/freecad_document.py +1319 -0
  62. optics_design_workbench-0.4.3/freecad/optics_design_workbench/jupyter_utils/histogram.py +149 -0
  63. optics_design_workbench-0.4.3/freecad/optics_design_workbench/jupyter_utils/hits.py +338 -0
  64. optics_design_workbench-0.4.3/freecad/optics_design_workbench/jupyter_utils/parameter_sweeper.py +787 -0
  65. optics_design_workbench-0.4.3/freecad/optics_design_workbench/jupyter_utils/progress.py +181 -0
  66. optics_design_workbench-0.4.3/freecad/optics_design_workbench/simulation/__init__.py +32 -0
  67. optics_design_workbench-0.4.3/freecad/optics_design_workbench/simulation/processes/__init__.py +20 -0
  68. optics_design_workbench-0.4.3/freecad/optics_design_workbench/simulation/processes/simulation_loop.py +590 -0
  69. optics_design_workbench-0.4.3/freecad/optics_design_workbench/simulation/processes/worker_process.py +114 -0
  70. optics_design_workbench-0.4.3/freecad/optics_design_workbench/simulation/results_store.py +513 -0
  71. optics_design_workbench-0.4.3/freecad/optics_design_workbench/simulation/tracing_cache.py +81 -0
  72. optics_design_workbench-0.4.3/freecad/optics_design_workbench/timing.py +171 -0
  73. optics_design_workbench-0.4.3/package.xml +22 -0
  74. optics_design_workbench-0.4.3/pyproject.toml +62 -0
  75. optics_design_workbench-0.4.3/pytest.ini +2 -0
  76. optics_design_workbench-0.4.3/test/__init__.py +4 -0
  77. optics_design_workbench-0.4.3/test/freecad/__init__.py +4 -0
  78. optics_design_workbench-0.4.3/test/freecad/gaussian.FCStd +0 -0
  79. optics_design_workbench-0.4.3/test/freecad/gausssian-notest.ipynb +146 -0
  80. optics_design_workbench-0.4.3/test/freecad/lens-optimizer-sweep.ipynb +172 -0
  81. optics_design_workbench-0.4.3/test/freecad/lens-optimizer.FCStd +0 -0
  82. optics_design_workbench-0.4.3/test/freecad/lens-optimizer.OpticsDesign/notebooks/sweep.ipynb +183 -0
  83. optics_design_workbench-0.4.3/test/freecad/playground.FCStd +0 -0
  84. optics_design_workbench-0.4.3/test/freecad/replay.FCStd +0 -0
  85. optics_design_workbench-0.4.3/test/freecad/test_run_and_simulate.py +204 -0
  86. optics_design_workbench-0.4.3/test/python/__init__.py +4 -0
  87. optics_design_workbench-0.4.3/test/python/distributions_basics.ipynb +388 -0
  88. optics_design_workbench-0.4.3/test/python/distributions_quantitative.ipynb +225 -0
  89. optics_design_workbench-0.4.3/test/python/meshes_by_density.ipynb +352 -0
  90. optics_design_workbench-0.4.3/test/python/test_notebooks.py +24 -0
  91. optics_design_workbench-0.4.3/uv.lock +2245 -0
  92. optics_design_workbench-0.4.3/workbench.svg +519 -0
@@ -0,0 +1,2 @@
1
+ *.ipynb filter=clean-ipynb
2
+
@@ -0,0 +1,34 @@
1
+ # This workflow will install Python dependencies, run tests and lint with a single version of Python
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3
+
4
+ name: Python application
5
+
6
+ on:
7
+ push:
8
+ branches: [ "master" ]
9
+ pull_request:
10
+ branches: [ "master" ]
11
+
12
+ permissions:
13
+ contents: read
14
+
15
+ jobs:
16
+ build-and-test:
17
+ strategy:
18
+ matrix:
19
+ version: ["v3.11", "v3.12", "v3.13"]
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - uses: actions/checkout@v4
23
+ - name: Install uv
24
+ uses: astral-sh/setup-uv@v5
25
+ - name: Install dependencies
26
+ run: |
27
+ git fetch --deepen 50
28
+ uv venv --python=${{ matrix.version }}
29
+ uv pip install pytest
30
+ uv pip install jupyter nbconvert
31
+ uv sync --all-extras --dev
32
+ - name: Test with pytest
33
+ run: |
34
+ uv run pytest
@@ -0,0 +1,28 @@
1
+ fcstd
2
+ build
3
+ dist
4
+ *.FCBak
5
+ __pycache__
6
+ *.ipynb_checkpoints*
7
+ *.pkl
8
+ *.pdf
9
+ *.png
10
+ *.jpg
11
+ *.tar.gz
12
+ *.egg-info
13
+ *.nbconvert*
14
+ **/*.OpticsDesign/raw/*
15
+ **/*.OpticsDesign/**/*.pdf
16
+ **/*.OpticsDesign/**/*.png
17
+ **/*.OpticsDesign/**/*.jpg
18
+ **/*.OpticsDesign/**/*.md
19
+ **/*.OpticsDesign/**/*.txt
20
+ **/*.OpticsDesign/**/*.log
21
+ **/*.OpticsDesign/**/simulation-*
22
+ *.md5
23
+ test-docker/**/container-home
24
+ *.AppImage
25
+ releases
26
+
27
+ # include screenshots in examples
28
+ !examples/**/*.png
@@ -0,0 +1,66 @@
1
+
2
+ GNU LESSER GENERAL PUBLIC LICENSE
3
+
4
+ Version 3, 29 June 2007
5
+
6
+ Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
7
+
8
+ Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
9
+
10
+ This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
11
+ 0. Additional Definitions.
12
+
13
+ As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
14
+
15
+ “The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
16
+
17
+ An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
18
+
19
+ A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
20
+
21
+ The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
22
+
23
+ The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
24
+ 1. Exception to Section 3 of the GNU GPL.
25
+
26
+ You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
27
+ 2. Conveying Modified Versions.
28
+
29
+ If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
30
+
31
+ a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
32
+ b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
33
+
34
+ 3. Object Code Incorporating Material from Library Header Files.
35
+
36
+ The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
37
+
38
+ a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
39
+ b) Accompany the object code with a copy of the GNU GPL and this license document.
40
+
41
+ 4. Combined Works.
42
+
43
+ You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
44
+
45
+ a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
46
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
47
+ c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
48
+ d) Do one of the following:
49
+ 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
50
+ 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
51
+ e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
52
+
53
+ 5. Combined Libraries.
54
+
55
+ You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
56
+
57
+ a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
58
+ b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
59
+
60
+ 6. Revised Versions of the GNU Lesser General Public License.
61
+
62
+ The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
63
+
64
+ Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
65
+
66
+ If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
@@ -0,0 +1,2 @@
1
+ include freecad/optics_design_workbench/icons/*
2
+
@@ -0,0 +1,183 @@
1
+ Metadata-Version: 2.4
2
+ Name: optics_design_workbench
3
+ Version: 0.4.3
4
+ Summary: Physically accurate forward ray tracing for optics simulation and optimization with FreeCAD workbench frontend inspired by the FreeCAD OpticsWorkbench
5
+ Project-URL: Homepage, https://github.com/zaphB/freecad.optics_design_workbench
6
+ Project-URL: Repository, https://github.com/zaphB/freecad.optics_design_workbench.git
7
+ Author-email: Philipp Bredol <philipp.bredol@rwth-aachen.de>
8
+ License:
9
+ GNU LESSER GENERAL PUBLIC LICENSE
10
+
11
+ Version 3, 29 June 2007
12
+
13
+ Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
14
+
15
+ Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
16
+
17
+ This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
18
+ 0. Additional Definitions.
19
+
20
+ As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
21
+
22
+ “The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
23
+
24
+ An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
25
+
26
+ A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
27
+
28
+ The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
29
+
30
+ The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
31
+ 1. Exception to Section 3 of the GNU GPL.
32
+
33
+ You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
34
+ 2. Conveying Modified Versions.
35
+
36
+ If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
37
+
38
+ a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
39
+ b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
40
+
41
+ 3. Object Code Incorporating Material from Library Header Files.
42
+
43
+ The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
44
+
45
+ a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
46
+ b) Accompany the object code with a copy of the GNU GPL and this license document.
47
+
48
+ 4. Combined Works.
49
+
50
+ You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
51
+
52
+ a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
53
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
54
+ c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
55
+ d) Do one of the following:
56
+ 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
57
+ 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
58
+ e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
59
+
60
+ 5. Combined Libraries.
61
+
62
+ You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
63
+
64
+ a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
65
+ b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
66
+
67
+ 6. Revised Versions of the GNU Lesser General Public License.
68
+
69
+ The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
70
+
71
+ Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
72
+
73
+ If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
74
+ License-File: LICENSE.txt
75
+ Requires-Python: >=3.10
76
+ Requires-Dist: atomicwrites
77
+ Requires-Dist: cloudpickle
78
+ Requires-Dist: jupyterlab
79
+ Requires-Dist: matplotlib
80
+ Requires-Dist: numpy>1.24.4
81
+ Requires-Dist: pyside6
82
+ Requires-Dist: scipy>=1.14.0
83
+ Requires-Dist: seaborn
84
+ Requires-Dist: sympy
85
+ Description-Content-Type: text/markdown
86
+
87
+ # Optics Design Workbench
88
+
89
+ This workbench was inspired by the [OpticsWorkbench](https://github.com/chbergmann/OpticsWorkbench) and aims to extend its functionality towards design and optimization of optical assemblies.
90
+
91
+ Feel free to ask any question in the [forum thread](https://forum.freecad.org/viewtopic.php?t=89264).
92
+
93
+
94
+ ## Prerequisites
95
+
96
+ FreeCAD version >=0.21, python packages numpy, scipy, matplotlib, atomicwrites. A jupyter notebook installation is recommended.
97
+
98
+
99
+ ## Installing the FreeCAD workbench
100
+
101
+ To make the Optics Design Workbench available in FreeCAD, install it using FreeCAD's built in addon manager.
102
+
103
+ If you want to install without the addon manager, head to the releases section and download the zipped source of your version of choice. Extract the downloaded zip to the Mod folder of your FreeCAD installation. Make sure that the folder containing the `init_gui.py` is on the third subfolder level below the Mod directory like this:
104
+
105
+ ```bash
106
+ ..../Mod/freecad.optics_design_workbench-1.2.3/freecad/optics_design_workbench/init_gui.py
107
+ ```
108
+
109
+
110
+ ## Installing for usage in external python shells and jupyter notebooks
111
+
112
+ To install as a regular python package run
113
+
114
+ ```bash
115
+ pip install optics_design_workbench
116
+ ```
117
+
118
+ (Note that the package looks very much like a `freecad.optics_design_workbench` namespace package, however it is uploaded to PyPi just as `optics_design_workbench`, i.e., not being part of the freecad namespace. The reason for this is that the freecad base package is not pip-installable yet and is therefore very difficult to install in virtual environments. The `optics_design_workbench` without the namespace component does not rely on the freecad package to exist, therefore can be installed via pip in any virtual environment without any issue.)
119
+
120
+
121
+ ## Development installation
122
+
123
+ Clone this repository, install the python module in development mode using `pip install -e .`. Create a symlink in your FreeCAD's Mod folder pointing to the directory of the cloned directory. With this setup, changes in the cloned repository folder will be effective immediately when restarting FreeCAD. Avoid using regular PyPi or addon manager installations in parallel with the development installation.
124
+
125
+
126
+ ## Getting started with examples
127
+
128
+ To get started, FCStd files and corresponding jupyter notebooks can be found the examples folder of this repository.
129
+
130
+
131
+ ### Gaussian beam point source and detector
132
+
133
+ [examples/1-source-and-detector](./examples/1-source-and-detector)
134
+
135
+ #### Ray-fan simulation mode
136
+
137
+ The ray-fan mode renders rays for cross-sections of the solid angle with a spacing matching the inverse power density of the light source. This mode renders fast and gives a good first impression where the optical power of your sources ends up.
138
+
139
+ ![ray-fan mode screenshot](./examples/1-source-and-detector/screenshot-ray-fan.png)
140
+
141
+
142
+ #### Monte-Carlo simulation mode
143
+
144
+ In the Monte-Carlo simulation mode, rays are placed randomly in the full solid angle according to the given power density of the light source. If the simulation is run in continuous mode, recorded ray hits will be stored to disk and can be loaded and further analyzed with the accompanying notebook in the example folder.
145
+
146
+ ![monte-carlo mode screenshot](./examples/1-source-and-detector/screenshot-monte-carlo.png)
147
+
148
+
149
+ ### Spherical lens and parabolic mirror
150
+
151
+ [examples/2-lens-and-mirror](./examples/2-lens-and-mirror)
152
+
153
+ Any geometric body in FreeCAD can become member of one of the `OpticalGroup`s to turn them into reflective, refractive, absorbing or ray-detecting objects. This example contains spherical lenses and slotted parabolic mirrors, transparent and absorbing detectors. When running the continuous simulation, folders for all objects that have set `Store Hits` to true will be generated.
154
+
155
+ ![lens and mirror screenshot](./examples/2-lens-and-mirror/screenshot.png)
156
+
157
+
158
+ ### Geometry parameter optimization
159
+
160
+ [examples/3-parameter-sweeps](./examples/3-parameter-sweeps)
161
+
162
+ All parameters of the FreeCAD model are accessible from an external python shell through the `jupyter_utils` submodule. The recommended workflow is to use a jupyter notebook for such edits (hence the module name). The example shows a simple spherical lens, the radius of which is optimized to minimize the spot size on a detector.
163
+
164
+
165
+ ## Troubleshooting
166
+
167
+ When things don't work as expected first make sure you are actually running want you intend to run and whether the same workbench version is installed on the python and the FreeCAD side. To check this, run
168
+
169
+ ```python
170
+ import optics_design_workbench
171
+ optics_design_workbench.versionInfo()
172
+ ```
173
+
174
+ in the FreeCAD python shell and
175
+
176
+ ```python
177
+ import optics_design_workbench
178
+ optics_design_workbench.versionInfo()
179
+ ```
180
+
181
+ in your regular python shell of choice.
182
+
183
+ Make sure that the workbench versions seen by FreeCAD and by python match and that all the displayed versions and paths match your expectations.
@@ -0,0 +1,97 @@
1
+ # Optics Design Workbench
2
+
3
+ This workbench was inspired by the [OpticsWorkbench](https://github.com/chbergmann/OpticsWorkbench) and aims to extend its functionality towards design and optimization of optical assemblies.
4
+
5
+ Feel free to ask any question in the [forum thread](https://forum.freecad.org/viewtopic.php?t=89264).
6
+
7
+
8
+ ## Prerequisites
9
+
10
+ FreeCAD version >=0.21, python packages numpy, scipy, matplotlib, atomicwrites. A jupyter notebook installation is recommended.
11
+
12
+
13
+ ## Installing the FreeCAD workbench
14
+
15
+ To make the Optics Design Workbench available in FreeCAD, install it using FreeCAD's built in addon manager.
16
+
17
+ If you want to install without the addon manager, head to the releases section and download the zipped source of your version of choice. Extract the downloaded zip to the Mod folder of your FreeCAD installation. Make sure that the folder containing the `init_gui.py` is on the third subfolder level below the Mod directory like this:
18
+
19
+ ```bash
20
+ ..../Mod/freecad.optics_design_workbench-1.2.3/freecad/optics_design_workbench/init_gui.py
21
+ ```
22
+
23
+
24
+ ## Installing for usage in external python shells and jupyter notebooks
25
+
26
+ To install as a regular python package run
27
+
28
+ ```bash
29
+ pip install optics_design_workbench
30
+ ```
31
+
32
+ (Note that the package looks very much like a `freecad.optics_design_workbench` namespace package, however it is uploaded to PyPi just as `optics_design_workbench`, i.e., not being part of the freecad namespace. The reason for this is that the freecad base package is not pip-installable yet and is therefore very difficult to install in virtual environments. The `optics_design_workbench` without the namespace component does not rely on the freecad package to exist, therefore can be installed via pip in any virtual environment without any issue.)
33
+
34
+
35
+ ## Development installation
36
+
37
+ Clone this repository, install the python module in development mode using `pip install -e .`. Create a symlink in your FreeCAD's Mod folder pointing to the directory of the cloned directory. With this setup, changes in the cloned repository folder will be effective immediately when restarting FreeCAD. Avoid using regular PyPi or addon manager installations in parallel with the development installation.
38
+
39
+
40
+ ## Getting started with examples
41
+
42
+ To get started, FCStd files and corresponding jupyter notebooks can be found the examples folder of this repository.
43
+
44
+
45
+ ### Gaussian beam point source and detector
46
+
47
+ [examples/1-source-and-detector](./examples/1-source-and-detector)
48
+
49
+ #### Ray-fan simulation mode
50
+
51
+ The ray-fan mode renders rays for cross-sections of the solid angle with a spacing matching the inverse power density of the light source. This mode renders fast and gives a good first impression where the optical power of your sources ends up.
52
+
53
+ ![ray-fan mode screenshot](./examples/1-source-and-detector/screenshot-ray-fan.png)
54
+
55
+
56
+ #### Monte-Carlo simulation mode
57
+
58
+ In the Monte-Carlo simulation mode, rays are placed randomly in the full solid angle according to the given power density of the light source. If the simulation is run in continuous mode, recorded ray hits will be stored to disk and can be loaded and further analyzed with the accompanying notebook in the example folder.
59
+
60
+ ![monte-carlo mode screenshot](./examples/1-source-and-detector/screenshot-monte-carlo.png)
61
+
62
+
63
+ ### Spherical lens and parabolic mirror
64
+
65
+ [examples/2-lens-and-mirror](./examples/2-lens-and-mirror)
66
+
67
+ Any geometric body in FreeCAD can become member of one of the `OpticalGroup`s to turn them into reflective, refractive, absorbing or ray-detecting objects. This example contains spherical lenses and slotted parabolic mirrors, transparent and absorbing detectors. When running the continuous simulation, folders for all objects that have set `Store Hits` to true will be generated.
68
+
69
+ ![lens and mirror screenshot](./examples/2-lens-and-mirror/screenshot.png)
70
+
71
+
72
+ ### Geometry parameter optimization
73
+
74
+ [examples/3-parameter-sweeps](./examples/3-parameter-sweeps)
75
+
76
+ All parameters of the FreeCAD model are accessible from an external python shell through the `jupyter_utils` submodule. The recommended workflow is to use a jupyter notebook for such edits (hence the module name). The example shows a simple spherical lens, the radius of which is optimized to minimize the spot size on a detector.
77
+
78
+
79
+ ## Troubleshooting
80
+
81
+ When things don't work as expected first make sure you are actually running want you intend to run and whether the same workbench version is installed on the python and the FreeCAD side. To check this, run
82
+
83
+ ```python
84
+ import optics_design_workbench
85
+ optics_design_workbench.versionInfo()
86
+ ```
87
+
88
+ in the FreeCAD python shell and
89
+
90
+ ```python
91
+ import optics_design_workbench
92
+ optics_design_workbench.versionInfo()
93
+ ```
94
+
95
+ in your regular python shell of choice.
96
+
97
+ Make sure that the workbench versions seen by FreeCAD and by python match and that all the displayed versions and paths match your expectations.
@@ -0,0 +1,70 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "from numpy import *\n",
10
+ "from matplotlib.pyplot import *\n",
11
+ "import pickle\n",
12
+ "import os"
13
+ ]
14
+ },
15
+ {
16
+ "cell_type": "markdown",
17
+ "metadata": {},
18
+ "source": [
19
+ "# Loading the data\n",
20
+ "\n",
21
+ "The simulation workers dump their results to disk every few seconds. To load all the results from a simulation, we have to unpickle all relevant pkl files. Here we assemble all found ray hit coordinates in the `allPoints` array:"
22
+ ]
23
+ },
24
+ {
25
+ "cell_type": "code",
26
+ "execution_count": null,
27
+ "metadata": {},
28
+ "outputs": [],
29
+ "source": [
30
+ "allPoints = None\n",
31
+ "for r, ds, fs in os.walk('main.opticalSimulationResults/run-0000-raw'):\n",
32
+ " for f in fs:\n",
33
+ " if f.endswith('.pkl'):\n",
34
+ " with open(f'{r}/{f}', 'rb') as _f:\n",
35
+ " blob = pickle.load(_f)\n",
36
+ " allPoints = concatenate([allPoints, blob['points']]) if allPoints is not None else blob['points']"
37
+ ]
38
+ },
39
+ {
40
+ "cell_type": "code",
41
+ "execution_count": null,
42
+ "metadata": {},
43
+ "outputs": [],
44
+ "source": [
45
+ "allPoints.shape"
46
+ ]
47
+ },
48
+ {
49
+ "cell_type": "markdown",
50
+ "metadata": {},
51
+ "source": [
52
+ "# Plot the results\n",
53
+ "\n",
54
+ "After loading the data, we can apply any data analysis tools to visualize or further analyze the data. For example we can plot a 2d histogram of the X and Y coordinates:"
55
+ ]
56
+ },
57
+ {
58
+ "cell_type": "code",
59
+ "execution_count": null,
60
+ "metadata": {},
61
+ "outputs": [],
62
+ "source": [
63
+ "hist2d(*allPoints[:,:2].T, bins=30);"
64
+ ]
65
+ }
66
+ ],
67
+ "metadata": {},
68
+ "nbformat": 4,
69
+ "nbformat_minor": 2
70
+ }