A simple ray tracing and visualization tool for freespace optics.
Project description
Optable — Ray tracing on an Optical table
A simple ray tracing and visualization tool for freespace optics.
dedicated to phys students working with freespace optics.
For documentation see online documentation on Read The Docs.
For examples of use check Examples.
Installation
pip install -r requirements.txt
Example
Gaussian beam tracing
import numpy as np, sys, matplotlib.pyplot as plt
sys.path.append("../optable/")
from optical_component import *
from optical_table import OpticalTable
from component_group import GlassSlab
if __name__ == "__main__":
fig, ax0 = plt.subplots(1, 1, figsize=(12, 6))
wl = 780e-9
w0 = 10e-6
r0 = [
Ray([-10, 0, 0], [1, 0, 0], wavelength=wl, w0=w0),
Ray([-10, 2, 0], [1, 0, 0], wavelength=wl, w0=w0),
Ray([-10, 4, 0], [1, 0, 0], wavelength=wl, w0=w0),
Ray([-10, 6, 0], [1, 0, 0], wavelength=wl, w0=w0),
Ray([-10, 9, 0], [1, 0, 0], wavelength=wl, w0=w0),
Ray([-10, 21, 0], [1, 0, 0], wavelength=wl, w0=w0).RotZ(-np.pi / 4),
]
m0 = Mirror([0, 0, 0]).RotZ(np.pi / 6)
l0 = Lens([0, 2, 0], radius=0.8, focal_length=5)
l1 = Lens([0, 4, 0], radius=0.8, focal_length=10)
l2 = Lens([0, 6.5, 0], radius=0.8, focal_length=10)
slab0 = GlassSlab([0, 9, 0], n1=1, n2=2, thickness=5)
m1 = Mirror([0, 11, 0]).RotZ(-np.pi / 2)
# Summary, rays, components, monitors
rays = r0
components = [m0, l0, l1, l2, slab0, m1]
monitors = []
table = OpticalTable()
table.add_components(components)
table.add_monitors(monitors)
table.ray_tracing(rays)
# ax0.annotate(mon0.ndata, (mon0.origin[0], mon0.origin[1]), fontsize=15, color="black")
table.render(
ax0,
type="Z",
gaussian_beam=True,
spot_size_scale=1,
roi=[-15, 30, -10, 20],
)
if __name__ == "__main__":
# plt.axis("off")
plt.savefig("../docs/gaussian_beam.png", dpi=300, bbox_inches="tight")
plt.show()
Result
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file optical_table-1.0.0.tar.gz.
File metadata
- Download URL: optical_table-1.0.0.tar.gz
- Upload date:
- Size: 51.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c70402caf3e4cb0166683fb423fd8b612e309067a320cbd0a30953693867d2e6
|
|
| MD5 |
ab33bd1e91ae390cd09a61226ab2483a
|
|
| BLAKE2b-256 |
91e8d14424191c230539079784ffcd92ee54327e6bf5e078a5ae1c1f80f94d22
|
File details
Details for the file optical_table-1.0.0-py3-none-any.whl.
File metadata
- Download URL: optical_table-1.0.0-py3-none-any.whl
- Upload date:
- Size: 54.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2681c6b365ea414912d61fa970f5f3b3f9bc62a50ee4c62496048ee8f38d15d8
|
|
| MD5 |
43383722fdc4182c4fec7d348d00ef7b
|
|
| BLAKE2b-256 |
a0bf1f25a33fb8114aa1c485ec4daa67c9dc8a31e4f1296807d80fab43e08c4a
|