Physical Optics#
Scalar physical-optics field models and propagation algorithms.
- class ScalarField(data: BEArrayT, dx: float, wavelength: float, dy: float | None = None, refractive_index: float = 1.0)[source]#
Bases:
Generic[BEArrayT]A sampled two-dimensional complex scalar optical field.
The last array dimension is the x-axis and the first is the y-axis. All spatial quantities, including
dx,dy, andwavelength, must use the same unit.- Parameters:
data – Two-dimensional NumPy array or PyTorch tensor containing the sampled complex amplitude. Real arrays are promoted to complex without changing their device or floating-point precision.
dx – Sample spacing along x.
wavelength – Vacuum wavelength in the same unit as
dx.dy – Sample spacing along y. Defaults to
dx.refractive_index – Homogeneous-medium refractive index. Defaults to 1.
- Raises:
TypeError – If
datadoes not belong to the active backend.ValueError – If the field or physical parameters are invalid.
- coordinates() tuple[BEArrayT, BEArrayT][source]#
Return centered one-dimensional x and y coordinate arrays.
- property intensity: BEArrayT#
Return sampled intensity,
abs(data) ** 2.
- property power: ScalarOrArrayT#
Return the sampled intensity integral over the field plane.
- propagate(distance: float | ScalarOrArrayT, evanescent: Literal['discard', 'decay'] = 'discard') ScalarField[BEArrayT][source]#
Propagate the field through a homogeneous medium.
- Parameters:
distance – Signed propagation distance in the field’s spatial unit.
evanescent –
"discard"filters evanescent content even at zero distance."decay"preserves the complete field at zero, up to FFT roundoff. Seeangular_spectrum()for distance-gradient behavior.
- Returns:
Propagated field on the same sampling grid.
- Return type:
- angular_spectrum(field: ScalarField[BEArrayT], distance: float | ScalarOrArrayT, evanescent: EvanescentPolicy = 'discard') ScalarField[BEArrayT][source]#
Propagate a scalar field with the angular spectrum method.
The input and output use the same rectangular sampling grid. Consequently, the usual discrete-Fourier periodic-boundary assumption applies; callers should provide enough zero padding to prevent wraparound for expanding fields.
- Parameters:
field – Input scalar field.
distance – Signed propagation distance. It must use the same unit as the field spacing and wavelength. A backend scalar is accepted so that PyTorch can differentiate with respect to distance, including at zero for propagating components.
evanescent – Handling of spatial frequencies above the propagating cutoff.
"discard"removes them at every distance, including zero, so zero-distance propagation is an identity only for fields without evanescent content."decay"attenuates them exponentially withabs(distance)and preserves the complete field at zero, up to FFT roundoff. With evanescent content, this absolute-value decay has no two-sided distance derivative at zero; PyTorch uses a zero subgradient for the absolute-value factor there.
- Returns:
Propagated field on the original sampling grid.
- Return type:
- Raises:
TypeError – If
distanceis not scalar.ValueError – If the distance or evanescent policy is invalid.
- gaussian_field(shape: tuple[int, int], dx: float, wavelength: float, waist_radius: float, dy: float | None = None, refractive_index: float = 1.0, amplitude: complex | ScalarOrArrayT = 1.0) ScalarField[source]#
Create a fundamental Gaussian beam sampled at its waist.
waist_radiusis the conventional 1/e field-amplitude radius, or equivalently the 1/e-squared intensity radius.- Parameters:
shape – Number of samples as
(ny, nx).dx – Sample spacing along x.
wavelength – Vacuum wavelength.
waist_radius – Gaussian beam waist radius.
dy – Sample spacing along y. Defaults to
dx.refractive_index – Homogeneous-medium refractive index. Defaults to 1.
amplitude – On-axis complex-field amplitude. Defaults to 1.
- Returns:
Gaussian field at its waist plane.
- Return type: