optimization.operand.ray
Ray Operands Module
This module provides a class that calculates various ray tracing values for an optical system. It is used in conjunction with the optimization module to optimize optical systems.
Kramer Harrison, 2024
Classes
A class that provides static methods for performing ray tracing |
- class RayOperand[source]
- A class that provides static methods for performing ray tracing
calculations on an optic.
- OPD_difference()[source]
Calculates the optical path difference (OPD) difference for a given ray distribution.
- static AOI(optic, surface_number, Hx, Hy, Px, Py, wavelength)[source]
Calculates the real ray angle of incidence in degrees at a specific surface. This angle is always positive, and it is the angle between the incident ray and the surface normal.
- Parameters:
optic – The optic object.
surface_number – The number of the surface.
Hx – The normalized x field coordinate.
Hy – The normalized y field coordinate.
Px – The normalized x pupil coordinate.
Py – The normalized y pupil coordinate.
wavelength – The wavelength of the ray.
- Returns:
The angle of incidence in degrees (always positive as in zemax).
- static L(optic, surface_number, Hx, Hy, Px, Py, wavelength)[source]
Calculates the direction cosine L of the ray on a specific surface.
- Parameters:
optic – The optic object.
surface_number – The number of the surface.
Hx – The normalized x field coordinate.
Hy – The normalized y field coordinate.
Px – The normalized x pupil coordinate.
Py – The normalized y pupil coordinate.
wavelength – The wavelength of the ray.
- Returns:
The direction cosine L of the ray.
- static M(optic, surface_number, Hx, Hy, Px, Py, wavelength)[source]
Calculates the direction cosine M of the ray on a specific surface.
- Parameters:
optic – The optic object.
surface_number – The number of the surface.
Hx – The normalized x field coordinate.
Hy – The normalized y field coordinate.
Px – The normalized x pupil coordinate.
Py – The normalized y pupil coordinate.
wavelength – The wavelength of the ray.
- Returns:
The direction cosine M of the ray.
- static N(optic, surface_number, Hx, Hy, Px, Py, wavelength)[source]
Calculates the direction cosine N of the ray on a specific surface.
- Parameters:
optic – The optic object.
surface_number – The number of the surface.
Hx – The normalized x field coordinate.
Hy – The normalized y field coordinate.
Px – The normalized x pupil coordinate.
Py – The normalized y pupil coordinate.
wavelength – The wavelength of the ray.
- Returns:
The direction cosine N of the ray.
- static OPD_difference(optic, Hx, Hy, num_rays, wavelength, distribution='gaussian_quad')[source]
- Calculates the mean optical path difference (OPD) difference for a
given ray distribution.
- Parameters:
optic – The optic object.
Hx – The normalized x field coordinate.
Hy – The normalized y field coordinate.
num_rays – The number of rays to trace.
wavelength – The wavelength of the rays.
distribution – The distribution of the rays. Default is ‘gaussian_quad’.
- Returns:
The OPD difference for the given ray distribution.
- static clearance(optic, line_ray_surface_idx, line_ray_field_coords, line_ray_pupil_coords, point_ray_surface_idx, point_ray_field_coords, point_ray_pupil_coords, wavelength)[source]
Computes the signed perpendicular distance in the YZ plane from a reference line (Line A) to a reference point (Point B).
Line A is defined by a ray (RA) traced at field FA, after it leaves surface SA. Point B is the intersection of a ray (RB) traced at field FB with surface SB.
This operand is useful for creating clearance or interference constraints, particularly in off-axis reflective systems.
The sign convention is such that for Line A propagating generally in the +Z direction (N direction cosine > 0), the signed distance is positive if Point B is on the +Y side of Line A. If Line A propagates generally in the -Z direction (N direction cosine < 0), this sign is flipped.
- Parameters:
optic – The optical system model.
line_ray_surface_idx – The index of the surface (SA) from which Line A originates (i.e., ray data is taken after this surface).
line_ray_field_coords – A tuple (Hx, Hy) representing the normalized field coordinates for the ray defining Line A (FA).
line_ray_pupil_coords – A tuple (Px, Py) representing the normalized pupil coordinates for the ray defining Line A (FA).
point_ray_surface_idx – The index of the surface (SB) with which the ray defining Point B intersects.
point_ray_field_coords – A tuple (Hx, Hy) representing the normalized field coordinates for the ray defining Point B (FB).
point_ray_pupil_coords – A tuple (Px, Py) representing the normalized pupil coordinates for the ray defining Point B (FB).
wavelength – The wavelength at which to trace the rays.
- Returns:
- The signed perpendicular distance in the YZ plane from
Line A to Point B. Returns 0.0 if Line A has zero length in the YZ plane (i.e., mA and nA are both zero).
- Return type:
float
- static rms_spot_size(optic, surface_number, Hx, Hy, num_rays, wavelength, distribution='hexapolar')[source]
Calculates the root mean square (RMS) spot size on a specific surface.
- Parameters:
optic – The optic object.
surface_number – The number of the surface.
Hx – The normalized x field coordinate.
Hy – The normalized y field coordinate.
num_rays – The number of rays to trace.
wavelength – The wavelength of the rays.
distribution – The distribution of the rays. Default is ‘hexapolar’.
- Returns:
The RMS spot size on the specified surface.
- static x_intercept(optic, surface_number, Hx, Hy, Px, Py, wavelength)[source]
- Calculates the x-coordinate of the intercept point on a specific
surface.
- Parameters:
optic – The optic object.
surface_number – The number of the surface.
Hx – The normalized x field coordinate.
Hy – The normalized y field coordinate.
Px – The normalized x pupil coordinate.
Py – The normalized y pupil coordinate.
wavelength – The wavelength of the ray.
- Returns:
The x-coordinate of the intercept point.
- static x_intercept_lcs(optic, surface_number, Hx, Hy, Px, Py, wavelength)[source]
- Calculates the x-coordinate of the intercept point on a specific
surface in its lcs, ie wrt to its vertex.
- Parameters:
optic – The optic object.
surface_number – The number of the surface.
Hx – The normalized x field coordinate.
Hy – The normalized y field coordinate.
Px – The normalized x pupil coordinate.
Py – The normalized y pupil coordinate.
wavelength – The wavelength of the ray.
- Returns:
The x-coordinate of the intercept point.
- static y_intercept(optic, surface_number, Hx, Hy, Px, Py, wavelength)[source]
- Calculates the y-coordinate of the intercept point on a specific
surface.
- Parameters:
optic – The optic object.
surface_number – The number of the surface.
Hx – The normalized x field coordinate.
Hy – The normalized y field coordinate.
Px – The normalized x pupil coordinate.
Py – The normalized y pupil coordinate.
wavelength – The wavelength of the ray.
- Returns:
The y-coordinate of the intercept point.
- static y_intercept_lcs(optic, surface_number, Hx, Hy, Px, Py, wavelength)[source]
- Calculates the y-coordinate of the intercept point on a specific
surface in its lcs, ie wrt to its vertex.
- Parameters:
optic – The optic object.
surface_number – The number of the surface.
Hx – The normalized x field coordinate.
Hy – The normalized y field coordinate.
Px – The normalized x pupil coordinate.
Py – The normalized y pupil coordinate.
wavelength – The wavelength of the ray.
- Returns:
The y-coordinate of the intercept point.
- static z_intercept(optic, surface_number, Hx, Hy, Px, Py, wavelength)[source]
- Calculates the z-coordinate of the intercept point on a specific
surface.
- Parameters:
optic – The optic object.
surface_number – The number of the surface.
Hx – The normalized x field coordinate.
Hy – The normalized y field coordinate.
Px – The normalized x pupil coordinate.
Py – The normalized y pupil coordinate.
wavelength – The wavelength of the ray.
- Returns:
The z-coordinate of the intercept point.
- static z_intercept_lcs(optic, surface_number, Hx, Hy, Px, Py, wavelength)[source]
- Calculates the z-coordinate of the intercept point on a specific
surface in its lcs, ie wrt to its vertex.
- Parameters:
optic – The optic object.
surface_number – The number of the surface.
Hx – The normalized x field coordinate.
Hy – The normalized y field coordinate.
Px – The normalized x pupil coordinate.
Py – The normalized y pupil coordinate.
wavelength – The wavelength of the ray.
- Returns:
The z-coordinate of the intercept point.