optiland.rays.polarized_rays#
Polarized Rays
This module contains the PolarizedRays class, which represents a class for polarized rays in three-dimensional space. The class inherits from the RealRays class.
Kramer Harrison, 2024
Classes
|
Represents a class for polarized rays in three-dimensional space. |
- class PolarizedRays(x, y, z, L, M, N, intensity, wavelength)[source]#
Represents a class for polarized rays in three-dimensional space.
Inherits from the RealRays class.
- Variables:
x (ndarray) – The x-coordinates of the rays.
y (ndarray) – The y-coordinates of the rays.
z (ndarray) – The z-coordinates of the rays.
L (ndarray) – The x-components of the direction vectors of the rays.
M (ndarray) – The y-components of the direction vectors of the rays.
N (ndarray) – The z-components of the direction vectors of the rays.
i (ndarray) – The intensity of the rays.
w (ndarray) – The wavelength of the rays.
opd (ndarray) – The optical path length of the rays.
p (be.ndarray) – Array of polarization matrices of the rays.
- Methods:
get_output_field(E – be.ndarray) -> be.ndarray: Compute the output electric field given the input electric field.
update_intensity(state – PolarizationState): Update the ray intensity based on the polarization state.
update(jones_matrix – be.ndarray = None): Update the polarization matrices after interaction with a surface.
_get_3d_electric_field(state – PolarizationState) -> be.ndarray: Get the 3D electric fields given the polarization state and initial rays.
- clip(condition: BEArray)#
Clip the rays based on a condition.
- get_exit_fields(state: PolarizationState | None) list[numpy.ndarray, torch.Tensor][source]#
Compute the exit electric field(s) for the rays.
- Parameters:
state (PolarizationState | None) – The polarization state.
- Returns:
A list of 3D electric field arrays. For polarized light, the list contains a single array. For unpolarized light, the list contains two orthogonal, incoherently superimposed arrays, each scaled down by 1/sqrt(2).
- Return type:
list[be.ndarray]
- static get_local_basis(k0: be.ndarray, k1: be.ndarray) tuple[be.ndarray, be.ndarray, be.ndarray, be.ndarray][source]#
Get the local s, p0, p1 vectors and transforming matrices.
- Parameters:
k0 – (N, 3) array of pre-interaction ray directions.
k1 – (N, 3) array of post-interaction ray directions.
- Returns:
(s, p0, p1, o_in, o_out) where s, p0, p1 are (N, 3) vectors and o_in, o_out are the projection matrices.
- Return type:
- get_output_field(E: be.ndarray) be.ndarray[source]#
Compute the output electric field given the input electric field.
- Parameters:
E (be.ndarray) – The input electric field as a numpy array.
- Returns:
The computed output electric field as a numpy array.
- Return type:
be.ndarray
- gratingdiffract(nx: float, ny: float, nz: float, fx: float, fy: float, fz: float, m: int, d: float, n1: float, n2: float, is_reflective: bool)#
Diffract the rays on a surface with a grating.
- Parameters:
nx – The x-component of the surface normal.
ny – The y-component of the surface normal.
nz – The z-component of the surface normal.
fx – The x-component of the grating vector.
fy – The y-component of the grating vector.
fz – The z-component of the grating vector.
d – The grating spacing
m – The grating diffraction order
n1 – IOR of the pre surface material
n2 – IOR of the post surface material
is_reflective – Wether the surface is reflective or not
- normalize()#
Normalize the direction vectors of the rays.
- record_on_surface(surface: Surface) None#
Dispatch to the surface’s real ray record method.
- Parameters:
surface (Surface) – The surface to record onto.
- reflect(nx: float, ny: float, nz: float)#
Reflects the rays on the surface.
- Parameters:
nx – The x-component of the surface normal.
ny – The y-component of the surface normal.
nz – The z-component of the surface normal.
- refract(nx: float, ny: float, nz: float, n1: float, n2: float)#
Refract rays on the surface.
- Parameters:
nx – The x-component of the surface normals.
ny – The y-component of the surface normals.
nz – The z-component of the surface normals.
- rotate_x(rx: ScalarOrArray)#
Rotate the rays about the x-axis.
- Parameters:
rx – Rotation angle around x-axis in radians.
- rotate_y(ry: ScalarOrArray)#
Rotate the rays about the y-axis.
- Parameters:
ry – Rotation angle around y-axis in radians.
- rotate_z(rz: ScalarOrArray)#
Rotate the rays about the z-axis.
- Parameters:
rz – Rotation angle around z-axis in radians.
- translate(dx: ArrayLike, dy: ArrayLike, dz: ArrayLike)#
Shifts the rays in the x, y, and z directions.
- Parameters:
dx – The amount to shift the rays in the x direction.
dy – The amount to shift the rays in the y direction.
dz – The amount to shift the rays in the z direction.
- update(jones_matrix: be.ndarray = None)[source]#
Update polarization matrices after interaction with surface.
- Parameters:
jones_matrix (be.ndarray, optional) – Jones matrix representing the interaction with the surface. If not provided, the polarization matrix is computed assuming an identity matrix.
- update_intensity(state: PolarizationState)[source]#
Update ray intensity based on polarization state.
- Parameters:
state (PolarizationState) – The polarization state of the ray.