pado.optical_element.DOE

class DOE(dim, pitch, material, wvl, device, height=None, phase_change=None, polar='non')[source]
Parameters:
__init__(dim, pitch, material, wvl, device, height=None, phase_change=None, polar='non')[source]

Diffractive optical element (DOE) that modifies incident light wavefront.

The wavefront modification is determined by the material height profile. Supports both height and phase change specifications.

Parameters:
  • dim (tuple) – Dimensions (B, 1, R, C) for batch size, channels, rows, columns

  • pitch (float) – Pixel pitch in meters

  • material (Material) – Material properties of the DOE

  • wvl (float) – Wavelength of light in meters

  • device (str) – Device to store wavefront (‘cpu’, ‘cuda:0’, etc.)

  • height (torch.Tensor, optional) – Height profile in meters

  • phase_change (torch.Tensor, optional) – Phase change profile

  • polar (str) – Polarization mode (‘non’: scalar, ‘polar’: vector)

Examples

>>> # Create DOE with specified height profile
>>> height = torch.ones((1,1,100,100)) * 500e-9  # 500nm height
>>> doe = DOE(height.shape, 2e-6, material, 500e-9, 'cpu', height=height)
>>> # Create DOE with specified phase profile
>>> phase = torch.ones((1,1,100,100)) * np.pi  # π phase
>>> doe = DOE(phase.shape, 2e-6, material, 500e-9, 'cpu', phase_change=phase)
visualize(b=0, c=0)[source]

Visualize the DOE wavefront modulation.

Displays amplitude change, phase change and height profile.

Parameters:
  • b (int) – Batch index to visualize, defaults to 0

  • c (int) – Channel index to visualize, defaults to 0

Return type:

None

Examples

>>> doe = DOE((1,1,100,100), 2e-6, material, 500e-9, 'cpu')
>>> doe.visualize()  # Shows modulation plots
>>> doe.visualize(b=1, c=0)  # Shows plots for batch index 1
set_diffraction_grating_1d(slit_width, minh, maxh)[source]

Set the wavefront modulation as a 1D diffraction grating.

Create alternating height regions to form a binary phase grating.

Parameters:
  • slit_width (float) – Width of each slit in meters

  • minh (float) – Minimum height in meters

  • maxh (float) – Maximum height in meters

Return type:

None

Examples

>>> doe = DOE((1,1,100,100), 2e-6, material, 500e-9, 'cpu')
>>> doe.set_diffraction_grating_1d(10e-6, 0, 500e-9)  # 10μm slits
>>> doe.visualize()  # Shows 1D grating pattern
set_diffraction_grating_2d(slit_width, minh, maxh)[source]

Set the wavefront modulation as a 2D diffraction grating.

Create a checkerboard pattern of alternating height regions.

Parameters:
  • slit_width (float) – Width of each slit in meters

  • minh (float) – Minimum height in meters

  • maxh (float) – Maximum height in meters

Return type:

None

Examples

>>> doe = DOE((1,1,100,100), 2e-6, material, 500e-9, 'cpu')
>>> doe.set_diffraction_grating_2d(10e-6, 0, 500e-9)  # 10μm slits
>>> doe.visualize()  # Shows 2D grating pattern
set_Fresnel_lens(focal_length, wvl, shift_x=0, shift_y=0)[source]

Set the wavefront modulation as a Fresnel lens.

Create a phase profile that focus light to a point.

Parameters:
  • focal_length (float) – Focal length in meters

  • wvl (float) – Wavelength in meters

  • shift_x (float) – Horizontal shift in meters. Defaults to 0

  • shift_y (float) – Vertical shift in meters. Defaults to 0

Return type:

None

Examples

>>> doe = DOE((1,1,1024,1024), 2e-6, material, 500e-9, 'cpu')
>>> doe.set_Fresnel_lens(0.1, 500e-9)  # f=10cm lens
>>> doe.set_Fresnel_lens(0.1, 500e-9, shift_x=50e-6)  # Shifted lens
set_Fresnel_zone_plate_lens(focal_length, wvl, shift_x=0, shift_y=0)[source]

Set binary Fresnel zone plate pattern.

Creates alternating opaque and transparent zones that focus light.

Parameters:
  • focal_length (float) – Focal length in meters

  • wvl (float) – Wavelength in meters

  • shift_x (float) – Horizontal shift in meters. Defaults to 0

  • shift_y (float) – Vertical shift in meters. Defaults to 0

Return type:

None

Examples

>>> doe = DOE((1,1,1024,1024), 2e-6, material, 500e-9, 'cpu')
>>> doe.set_Fresnel_zone_plate_lens(0.1, 500e-9)  # f=10cm lens
>>> doe.set_Fresnel_zone_plate_lens(0.1, 500e-9, shift_x=50e-6)  # Shifted lens
change_wvl(wvl)[source]

Change the wavelength and update phase change.

Parameters:

wvl (float) – New wavelength in meters

Return type:

None

Examples

>>> doe = DOE((1,1,100,100), 2e-6, material, 500e-9, 'cpu')
>>> doe.change_wvl(633e-9)  # Change to 633nm wavelength
sync_height_with_phase()[source]

Synchronize height profile with current phase profile. :rtype: None

Examples

>>> doe = DOE((1,1,100,100), 2e-6, material, 500e-9, 'cpu')
>>> doe.set_phase_change(phase, sync_height=False)
>>> doe.sync_height_with_phase()  # Update height to match phase
Return type:

None

sync_phase_with_height()[source]

Synchronize phase profile with current height profile. :rtype: None

Examples

>>> doe = DOE((1,1,100,100), 2e-6, material, 500e-9, 'cpu')
>>> doe.set_height(height, sync_phase=False)
>>> doe.sync_phase_with_height()  # Update phase to match height
Return type:

None

resize(target_pitch)[source]

Resize DOE with a new pixel pitch.

Resize field from which DOE height is recomputed.

Parameters:

target_pitch (float) – New pixel pitch in meters

Return type:

None

Examples

>>> doe = DOE((1,1,100,100), 2e-6, material, 500e-9, 'cpu')
>>> doe.resize(1e-6)  # Change pitch to 1μm
get_height()[source]

Return the height map of the DOE.

Returns:

Height map in meters

Return type:

torch.Tensor

Examples

>>> doe = DOE((1,1,100,100), 2e-6, material, 500e-9, 'cpu')
>>> height = doe.get_height()  # Get current height profile
set_phase_change(phase_change, sync_height=True)[source]

Set phase change induced by the DOE.

Parameters:
  • phase_change (torch.Tensor) – Phase change profile

  • sync_height (bool) – If True, syncs height profile

Return type:

None

Examples

>>> doe = DOE((1,1,100,100), 2e-6, material, 500e-9, 'cpu')
>>> phase = torch.ones((1,1,100,100)) * np.pi
>>> doe.set_phase_change(phase, sync_height=True)
set_field_change(field_change, sync_height=True)[source]

Change the field change of the DOE.

Parameters:
  • field_change (torch.Tensor) – Complex field change tensor

  • sync_height (bool) – If True, syncs height profile

Return type:

None

Examples

>>> doe = DOE((1,1,100,100), 2e-6, material, 500e-9, 'cpu')
>>> field = torch.exp(1j * torch.ones((1,1,100,100)))
>>> doe.set_field_change(field, sync_height=True)
set_height(height, sync_phase=True)[source]

Set the height map of the DOE.

Parameters:
  • height (torch.Tensor) – Height map in meters

  • sync_phase (bool) – If True, syncs phase profile

Return type:

None

Examples

>>> doe = DOE((1,1,100,100), 2e-6, material, 500e-9, 'cpu')
>>> height = torch.ones((1,1,100,100)) * 500e-9
>>> doe.set_height(height, sync_phase=True)