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) – Shape (N, 3, 3) transport matrices mapping Cartesian launch fields into the current output frame. Includes Jones amplitude effects, but excludes launch power and scalar losses.
Note
Private
_i0is retained scalar power: launch intensity multiplied by accumulated scalar attenuation, zeroed by clipping. It is not an immutable launch-intensity snapshot. Useattenuateandcliprather than writing it orito apply persistent loss. Evaluating another polarization state updatesiwithout modifying_i0.- 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.
- attenuate(factor: ScalarOrArray) None[source]#
Apply scalar intensity loss to current and retained ray power.
- Parameters:
factor – Scalar or shape (N,) intensity factor, as in
RealRays.attenuate. Exit-field amplitudes subsequently include its square root; the transport matrix is unchanged.
A state blocked by a polarizer can have zero current intensity while retaining power for another state. This operation preserves that distinction; only zero retained scalar power permanently stays dark.
- clip(condition: BEArray) None[source]#
Keep rejected rays dark for all later source-state evaluations.
- Parameters:
condition – Scalar or shape (N,) mask; nonzero entries extinguish both current intensity and retained scalar power.
- get_exit_fields(state: PolarizationState | None) list[numpy.ndarray, torch.Tensor][source]#
Compute output fields including launch power and scalar losses.
- Parameters:
state (PolarizationState | None) – Incident state in each ray’s transverse launch basis. None denotes unpolarized light.
- Returns:
A list of shape (N, 3) fields in the current output frame. 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). Launch intensity and all retained scalar losses scale amplitudes by their square root. Sum the squared field norms to obtain the intensity for this source state; do not apply the scalar losses again. This method does not change
i.- 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]#
Transport a Cartesian launch field into the current ray frame.
- Parameters:
E (be.ndarray) – Input Cartesian fields, shape (N, 3), expressed in the fixed launch frame, using the active backend.
- Returns:
Shape (N, 3) fields including Jones effects but without launch-intensity or scalar-attenuation scaling. Rays with zero retained scalar power return zero. Use
get_exit_fieldsfor power-scaled fields for a source polarization state.- 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) None[source]#
Rotate ray coordinates and output electric fields about x.
- rotate_y(ry: ScalarOrArray) None[source]#
Rotate ray coordinates and output electric fields about y.
- rotate_z(rz: ScalarOrArray) None[source]#
Rotate ray coordinates and output electric fields about z.
- 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.
Recomputes
ifrom the transport matrix and retained scalar power. Repeated calls do not compound loss. Assigningidirectly changes only the current evaluation and is overwritten by this method.