raytrace.real_ray_tracer#
Real Ray Tracer Module
This module contains the RealRayTracer class, which is responsible for tracing real rays through an optical system. It uses the RayGenerator class to create rays and the surface group of the optical system to trace them.
Kramer Harrison, 2025
Classes
|
Class to trace real rays through an optical system |
- class RealRayTracer(optic)[source]#
Class to trace real rays through an optical system
This class is responsible for building rays (via a ray generator) and tracing these through an optical system (via the surface group).
- Parameters:
optic (Optic) – The optical system to be traced.
- set_aiming(mode: str, max_iter: int = 10, tol: float = 1e-06, **kwargs)[source]#
Configure the ray aiming strategy.
- Parameters:
mode – The aiming mode (“paraxial”, “iterative”, “robust”).
max_iter – Maximum iterations for iterative solvers.
tol – Convergence tolerance for iterative solvers.
**kwargs – Additional configuration parameters.
- trace(Hx, Hy, wavelength, num_rays: int | None = 100, distribution: DistributionType | BaseDistribution | None = 'hexapolar', record: bool = True, *, retain_launch: bool = False)[source]#
Trace a distribution of rays through the optical system.
- Parameters:
Hx (float or numpy.ndarray) – The normalized x field coordinate.
Hy (float or numpy.ndarray) – The normalized y field coordinate.
wavelength (float) – The wavelength of the rays.
num_rays (int, optional) – The sampling parameter that determines the number of rays in the pupil. Its meaning depends on the value of distribution. Defaults to 100.
distribution (str or Distribution, optional) – The distribution of the rays. Defaults to ‘hexapolar’.
record (bool, optional) – Whether to store per-surface snapshots of the traced rays for later analysis. Pass False to cut peak memory roughly in half when only the returned rays are needed (e.g. large GPU traces). Defaults to True.
retain_launch – Whether to retain the generated ray state for an analysis. Defaults to False.
- Returns:
The RealRays object containing the traced rays.”
- Return type:
Notes
The interpretation of the num_rays argument depends on the value of distribution. For example, if distribution is hexapolar, num_rays specifies the number of rings, whereas when distribution is uniform, it specifies the total number of rays per axis.
- trace_generic(Hx, Hy, Px, Py, wavelength, record: bool = True, *, retain_launch: bool = False)[source]#
Trace generic rays through the optical system.
- Parameters:
Hx (float or numpy.ndarray) – The normalized x field coordinate.
Hy (float or numpy.ndarray) – The normalized y field coordinate.
Px (float or numpy.ndarray) – The normalized x pupil coordinate.
Py (float or numpy.ndarray) – The normalized y pupil coordinate
wavelength (float) – The wavelength of the rays.
record (bool, optional) – Whether to store per-surface snapshots of the traced rays. Defaults to True.
retain_launch – Whether to retain the generated ray state for an analysis. Defaults to False.