OptSys -- Optical systems simulator
Simulate ray-tracing of optical system with first order approximation. This will be a handy tool to get an intial estimate for various components for your optical system.
The following components can be used:
-
Lens: Convex/concave lens with finite aperture. Uses lens maker's formula for computing output ray
-
SphericalMirror: Concave/convex mirror with finite aperture. Uses lens maker's formula for computing output ray
-
Mirror: Flat mirror with finite aperture.
-
Grating: Diffraction grating with set number of groves and finite aperture. As of now, only fixed order is supported.
-
DMD: Digital Micromirror device with zero pitch size and finite aperture.
-
Sensor: Image sensor which halts all ray propagation. Use it as image plane.
Apart from placement and viewing of optical elements and rays, you can also:
-
Compute the light throughput of the system
-
Compute vingetting for the scene for a given system
-
Simulate system for different wavelengths
Broadly, simulation consists of two parts
- Components: A (python) list of various optical components with component specific paramenter, position, aperture and angle w.r.t y-axis. An example:
import raytracing as rt
components = []
components.append(rt.Lens(f=100,
aperture=25.4,
pos=[0,0],
theta=0))
- Rays: A (python) list of 3-tuple of rays with x-coordinate, y-coordinate and angle w.r.t x-axis. An example:
import raytracing as rt
rays = []
rays.append([-10, 0, -np.pi/6])
Once you configure your system with components and rays, you can propagate the rays using the following command:
ray_bundles = propagate_rays(components, rays)
In order to view the output, you create a canvas and draw the components and rays.
import visualize as vis
# Color for the rays
colors = 'r'
# Create a new canvas
canvas = vis.Canvas([-200, 600], [-100, 100])
# Draw the components
canvas.draw_components(components)
# Draw the rays
canvas.draw_rays(ray_bundles, colors)
# Show the system
canvas.show()
# Save a copy
canvas.save('example.png')
See examples folder for more information.
lf_2d.py : Includes several functions for simulation of 2D lightfields
lf_4d.py: Includes several functions for manipulating 4D lightfields
- Redo all examples with updated functions
- Implement convex/concave mirror
- Implement thin prism
- Implement image plane computation
- Implement field lens optimization
- Replace numpy commands with pytorch to enable SGD-based optimization
Authors:
- Vishwanath Saragadam (Postdoc, Rice University)
- Aswin Sankaranarayanan (Professor, ECE, Carnegie Mellon University)