Skip to main content

Physically accurate forward ray tracing for optics simulation and optimization with FreeCAD workbench frontend

Project description

Optics Design Workbench

This workbench was inspired by the OpticsWorkbench and aims to extend its functionality towards design and optimization of optical assemblies.

Feel free to ask any question in the forum thread.

Prerequisites

FreeCAD version >=0.21, python packages numpy, scipy, matplotlib, atomicwrites. A jupyter notebook installation is recommended.

Installation

To make the Optics Design Workbench available in FreeCAD, install it using FreeCAD's built in addon manager.

To be able to use the workbench as a regular python module run

pip3 install freecad.optics_design_workbench

Manual/offline installation without 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:

..../Mod/freecad.optics_design_workbench-1.2.3/freecad/optics_design_workbench/init_gui.py

Development installation

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.

Getting started with examples

To get started, FCStd files and corresponding jupyter notebooks can be found the examples folder of this repository.

Gaussian beam point source and detector

examples/1-source-and-detector

Ray-fan simulation mode

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.

ray-fan mode screenshot

Monte-Carlo simulation mode

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.

monte-carlo mode screenshot

Spherical lens and parabolic mirror

examples/2-lens-and-mirror

Any geometric body in FreeCAD can become member of one of the OpticalGroups 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.

lens and mirror screenshot

Troubleshooting

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

import freecad.optics_design_workbench
freecad.optics_design_workbench.versionInfo()

in the FreeCAD python shell and

import freecad_.optics_design_workbench
freecad_.optics_design_workbench.versionInfo()

in your regular python shell of choice.

Make sure that the workbench versions seen by FreeCAD and by python match and that all the displayed versions and paths match your expectations.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

freecad_optics_design_workbench-0.1.5.tar.gz (312.2 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file freecad_optics_design_workbench-0.1.5.tar.gz.

File metadata

File hashes

Hashes for freecad_optics_design_workbench-0.1.5.tar.gz
Algorithm Hash digest
SHA256 601ea97a772a5855b60e5173b4ef07c7db2fbbeaa09943f3e5caeff6c5b93d2f
MD5 6b23d0fee2eebd24e00ee1ed41e828bb
BLAKE2b-256 6f3272ea4bd60c982f9e3eed9874a5c305649b3e7338091b091530a6f91496b8

See more details on using hashes here.

File details

Details for the file freecad.optics_design_workbench-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for freecad.optics_design_workbench-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 293426d07d3f32a663cd4760307ea7f6db0a00d675754fcf663f084ccb154846
MD5 9bfca4423279654d25e3e7acb8ce7115
BLAKE2b-256 05256fadca3015db3128f44c9eabe215723572364e4df383fe69cbb0c247ee9b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page