geometries.toroidal
Toroidal Geometry
This module defines a toroidal surface geometry based on the Zemax definition: A base curve in the YZ plane (conic + polynomials) is rotated around an axis parallel to Y, offset by the radius of rotation R along Z.
z_y = yz_sag(y) = (c*y^2)/(1 + sqrt(1-(1+k)*c^2*y^2)) + sum(alpha_i * y^(2i+2)) z(x,y) = R - sqrt((R - z_y)^2 - x^2)
where: - R is the radius of rotation (X-Z curvature radius at vertex) - R_y = 1/c is the Y-Z curvature radius at vertex - k is the conic constant for the YZ curve - alpha_i are polynomial coefficients for the YZ curve (powers y^2, y^4, …)
Last Corrected by Manuel Fragata Mendes, July 2025
Classes
|
Represents a simplified toroidal geometry (no Zernike terms as in zemax - - may be added later if necessary). |
- class ToroidalGeometry(coordinate_system: CoordinateSystem, radius_x: float, radius_y: float, conic: float = 0.0, coeffs_poly_y: list[float] = None, tol: float = 1e-10, max_iter: int = 100)[source]
Represents a simplified toroidal geometry (no Zernike terms as in zemax - - may be added later if necessary).
- Parameters:
coordinate_system (CoordinateSystem) – The coordinate system.
radius_x (float) – Radius of rotation R (X-Z radius).
radius_y (float) – Base Y-Z radius R_y.
conic (float, optional) – Conic constant k for the Y-Z curve. Defaults to 0.0.
coeffs_poly_y (list[float], optional) – Polynomial coefficients alpha_i for the Y-Z curve, where coeffs_poly_y[i] corresponds to the coefficient for y^(2*(i+1)). Defaults to an empty list.
tol (float, optional) – Tolerance for Newton-Raphson iteration. Defaults to 1e-10.
max_iter (int, optional) – Maximum iterations for Newton-Raphson. Defaults to 100.
- R_rot
Radius of rotation R (X-Z radius).
- Type:
be.ndarray
- R_yz
Base Y-Z radius R_y.
- Type:
be.ndarray
- k_yz
Conic constant k for the Y-Z curve.
- Type:
be.ndarray
- coeffs_poly_y
Polynomial coefficients alpha_i for the Y-Z curve.
- Type:
be.ndarray
- c_yz
Curvature of the Y-Z profile (1/R_yz).
- Type:
be.ndarray or float
- eps
Small epsilon value for safe division.
- Type:
float
- distance(rays)
Calculates the distance from the ray origin to the surface intersection using a robust Newton-Raphson method. This version uses the base conic intersection as a strong initial guess.
- Parameters:
rays (RealRays) – The rays used for calculating distance.
- Returns:
An array of propagation distances ‘t’ from each ray’s current position to its intersection point with the geometry.
- Return type:
be.ndarray
- flip()[source]
Flip the geometry.
Changes the sign of the radius of rotation (R_rot) and the base Y-Z radius (R_yz). Updates the Y-Z curvature (c_yz) accordingly.
- classmethod from_dict(data: dict) ToroidalGeometry[source]
Creates a ToroidalGeometry from a dictionary representation.
- Parameters:
data (dict) – Dictionary containing toroidal geometry parameters.
- Returns:
An instance of ToroidalGeometry.
- Return type:
- globalize(rays)
Convert rays from the local coordinate system to the global coordinate system.
- Parameters:
rays (RealRays) – The rays to convert.
- localize(rays)
Convert rays from the global coordinate system to the local coordinate system.
- Parameters:
rays (RealRays) – The rays to convert.
- sag(x: float, y: float) float[source]
Calculate the sag z(x, y) of the toroidal surface.
- Parameters:
x (float or be.ndarray) – X-coordinate(s).
y (float or be.ndarray) – Y-coordinate(s).
- Returns:
Sag value(s) of the toroidal surface.
- Return type:
float or be.ndarray
- scale(scale_factor: float)[source]
Scale the geometry parameters.
- Parameters:
scale_factor (float) – The factor by which to scale the geometry.
- set_radius(value: float) None
Set the radius of curvature.
- Parameters:
value (float) – The new radius of curvature.
- surface_normal(rays)
Calculates the surface normal of the geometry at the given rays.
- Parameters:
rays (RealRays) – The rays, positioned at the surface, for which to calculate the surface normal.
- Returns:
The surface normal components (nx, ny, nz).
- Return type:
tuple[be.ndarray, be.ndarray, be.ndarray]
- to_dict() dict[source]
Converts the geometry to a dictionary.
- Returns:
A dictionary representation of the toroidal geometry.
- Return type:
dict
- update_normalization(semi_aperture: float) None
Update the normalization attributes of the geometry based on its defined normalization_mode (‘auto’ or ‘manual’). Base geometry generally does not maintain a normalization radius.
- Parameters:
semi_aperture (float) – The current semi-aperture of the surface.