Propagation#
TorchOptics simulates free-space propagation using Fourier optics. Two numerical methods are available: the angular spectrum method (ASM) and the direct integration method (DIM). Each can use either the exact Rayleigh–Sommerfeld diffraction model or the Fresnel approximation.
Automatic Method Selection#
By default (propagation_method="AUTO"), TorchOptics selects the optimal method by computing
a critical distance \(z_c\) and comparing it to the propagation distance
\(|\Delta z|\):
where \(|x_\text{max}|\) denotes, for each transverse dimension (x and y), the maximum coordinate separation along that dimension between any grid point in the input plane and any grid point in the propagation plane; \(\Delta\) is the grid spacing in that dimension, and \(\lambda\) is the wavelength.
\(|\Delta z| < z_c\) in at least one dimension → ASM (short-distance regime).
Otherwise → DIM (long-distance regime).
Override the selection explicitly:
field.propagate_to_z(0.1, propagation_method="ASM")
field.propagate_to_z(2.0, propagation_method="DIM")
Angular Spectrum Method (ASM)#
ASM propagates in the frequency domain by multiplying the field’s Fourier transform by a transfer function:
Rayleigh–Sommerfeld transfer function (default):
Fresnel approximation ("ASM_FRESNEL"):
Padding. ASM zero-pads the field before the FFT to suppress periodic boundary artifacts.
The default pad is twice the field size; override with asm_pad:
field.propagate_to_z(0.1, asm_pad=(300, 300)) # custom padding
field.propagate_to_z(0.1, asm_pad=(0, 0)) # no padding (faster)
Direct Integration Method (DIM)#
DIM computes propagation as a convolution with the free-space impulse response:
Rayleigh–Sommerfeld impulse response (default):
Fresnel approximation ("DIM_FRESNEL"):
The convolution is computed via conv2d_fft().
Method Summary#
String |
Algorithm |
Physical Model |
|---|---|---|
|
Auto-select ASM or DIM |
Rayleigh–Sommerfeld |
|
Auto-select ASM or DIM |
Fresnel approximation |
|
Angular spectrum method |
Rayleigh–Sommerfeld |
|
Angular spectrum method |
Fresnel approximation |
|
Direct integration method |
Rayleigh–Sommerfeld |
|
Direct integration method |
Fresnel approximation |
When to Use Which#
ASM — best for short-distance propagation where the output grid has similar spatial extent to the input. Fast (FFT-based) but requires padding.
DIM — best for long-distance propagation or when the output grid has very different spacing or offset. Can change grid geometry without interpolation artifacts.
Fresnel variants (
"ASM_FRESNEL","DIM_FRESNEL","AUTO_FRESNEL") — use when the paraxial approximation holds (\(\theta \ll 1\) rad) and you need faster computation or match a specific physical model. For high-NA systems or large propagation angles, the default Rayleigh–Sommerfeld is more accurate.
For most use cases, "AUTO" works well.
Interpolation#
When the output plane has different spacing or offset from the propagation plane,
TorchOptics resamples the result. Control this with interpolation_mode:
output = field.propagate(
shape=512, z=0.5, spacing=5e-6,
interpolation_mode="bilinear",
)
Available modes: "nearest" (default), "bilinear", "bicubic", "none".
Debug Logging#
Enable debug logging to inspect method selection and plane geometries:
import logging
logging.getLogger("torchoptics").setLevel(logging.DEBUG)
field.propagate_to_z(0.5)