Introduction to pyOpTools¶
What is pyOpTools¶
The pyOpTools package is composed by a set of python modules that allow to simulate the behavior of optical systems. Initially it was only oriented to the ray tracing, but currently in the development version it has some tools which can be used to simulate optical fields and their propagation.
This tutorial will introduce the simulation of optical systems by ray tracing in a Jupiter notebook.
In the following video there is a small demo of an old version of pyOpTools
[1]:
from IPython.lib.display import YouTubeVideo
YouTubeVideo("DB8sfm7pVPI", width=640, height=480)
[1]:
Some basic characteristics of pyOpTools¶
It is an open source development
It is being developed by the technological development group of Combustión Ingenieros S.A.S, and the applied optics group of the Universidad Nacional de Colombia.
It is written using the object oriented programming paradigm
It can perform non-sequential ray-tracing of complex 3D systems.
It can be used as a module to develop programs to simulate optical systems.
It can be used in a Jupyter Notebook to perform interactive simulation tasks
There is a FreeCAD workbench under development, to simplify its applications to optical design tasks. This development is being hosted in https://github.com/cihologramas/freecad-pyoptools
A basic introduction¶
Importing pyoptools¶
The fist step to simulate an optical system in pyOpTools, is to import the package. The most simple way to perform this task is to import the pyoptools.all subpackage:
[2]:
from pyoptools.all import *
After the module is imported, a simulation can be performed. In the following example we will create a simple system composer by a lens, a detector, and a light source.
As a first step we will create a lens from the Edmund Scientific catalog (reference 32475), we will create a CCD-like sensor with 20 mm X 20 mm size, and a parallel ray source with cartesian beam distribution.
Note: In pyOpTools (unless noted) the units are in millimeters.
[3]:
L = library.Edmund["32475"]
SEN = CCD(size=(20, 20)) # c.rotateZ(D[2])
# c.rotateY(D[1])
# c.rotateX(D[0])
R = parallel_beam_c(
origin=(0.0, 0.0, 0.0),
direction=(0.0, 0.0, 0.0),
size=(10, 10),
num_rays=(5, 5),
wavelength=0.58929,
)
with this components created, we will create a system, where the lens is placed at the position (0,0,50) , and the CCD is placed at the position (0,0,150). At the end the Plot3D command will be used to show the resulting system.
Note: The plot obtained with the Plot3D command is interactive. Meaning you can rotate it (left click), zoom it (scroll wheel), and drag it (right click), by clicking on it and moving the mouse.
[4]:
S = System(complist=[(L, (0, 0, 50), (0, 0, 0)), (SEN, (0, 0, 150), (0, 0, 0))], n=1)
Plot3D(S)
[4]:
After the system is created, we can add the raysource and propagate the system.
[5]:
S.ray_add(R)
S.propagate()
Plot3D(S)
[5]:
More Information
- Surfaces in pyOpTools
- Creating components with pyOpTools
- pyOpTools predefined components
- Simple RayTraces
- Creation of a simple one-lens system.
- Different examples of raytracing of a 2 lens system
- Prism spectroscope ray tracing
- Another prism spectroscope
- Placing diaphragms
- Example with total internal reflection
- Multiple ray sources
- System made with a couple catalog doubletes
- Aspheric lens
- Mis-aligned lenses
- System with multiple beam splitters
- Ray-tracing example: Autocolimator
- Ray-tracing example: Binocular
[ ]: