optiland.rays.ray_aiming.iterative
Iterative Ray Aiming Module
This module implements the iterative ray aiming algorithm with robust derivative calculation for wide-angle systems.
Kramer Harrison, 2025
Classes
|
Iterative ray aiming strategy using Modified Newton-Raphson. |
- class IterativeRayAimer(optic: Optic, max_iter: int = 20, tol: float = 1e-08, **kwargs: Any)[source]
Iterative ray aiming strategy using Modified Newton-Raphson.
This class implements an iterative ray aiming algorithm that solves for the initial ray coordinates (x, y) or directions (L, M) required to hit a specific target on the stop surface. It uses a Modified Newton-Raphson method with a paraxial Jacobian estimate and Broyden rank-1 updates to achieve fast super-linear convergence without expensive finite-difference recalculations.
- max_iter
Maximum number of iterations allowed.
- Type:
int
- tol
Convergence tolerance for ray aiming error.
- Type:
float
- _paraxial_aimer
Helper to generate initial guesses.
- Type:
- aim_rays(fields: tuple, wavelengths: Any, pupil_coords: tuple, initial_guess: tuple | None = None) tuple[source]
Calculate ray starting coordinates using iterative aiming.
This method solves the inverse ray tracing problem to find the starting coordinates (on the object surface) or directions (for finite objects) such that the ray passes through the specified pupil coordinates on the stop surface.
- Parameters:
fields (tuple) – Field coordinates (Hy, Hx) or (angle_x, angle_y).
wavelengths (Any) – Wavelengths of the rays in microns.
pupil_coords (tuple) – Normalized pupil coordinates (Px, Py).
initial_guess (tuple | None, optional) – Optional starting guess (x, y, z, L, M, N). If None, a paraxial guess is used.
- Returns:
A tuple containing the solved ray parameters (x, y, z, L, M, N).
- Return type:
tuple
- Raises:
ValueError – If initial guess produces NaNs or if the solver fails to converge within max_iter.