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

PolarizedRays(x, y, z, L, M, N, intensity, ...)

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.

x

The x-coordinates of the rays.

Type:

ndarray

y

The y-coordinates of the rays.

Type:

ndarray

z

The z-coordinates of the rays.

Type:

ndarray

L

The x-components of the direction vectors of the rays.

Type:

ndarray

M

The y-components of the direction vectors of the rays.

Type:

ndarray

N

The z-components of the direction vectors of the rays.

Type:

ndarray

i

The intensity of the rays.

Type:

ndarray

w

The wavelength of the rays.

Type:

ndarray

opd

The optical path length of the rays.

Type:

ndarray

p

Array of polarization matrices of the rays.

Type:

be.ndarray

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[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:

tuple

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.

trace_on_surface(surface: Surface) RealRays

Dispatch to the surface’s real ray trace kernel.

Parameters:

surface (Surface) – The surface to trace through.

Returns:

The traced real rays.

Return type:

RealRays

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.