Examples

The example notebooks illustrate the modules with examples whose physics is easy to follow, and compare the numerics with analytic results wherever an analytic solution exists. They are shown here with their stored outputs; to run them yourself, see Running the notebooks.

Propagation and diffraction

Beams, modes and paraxial optics

Interfaces, thin films and polarization

Imaging, aberrations and ray tracing

Measurement, phase retrieval and beam shaping

Microscopy

Lithography

Running the notebooks

You need an installation of pyoptics as described in the main README, plus matplotlib, Jupyter and (for notebook 12) ipywidgets, all contained in the notebooks extra:

pip install -e ".[notebooks]"
jupyter lab notebooks/

The widgets of notebook 12 only work with a running kernel; static viewers such as GitHub show the static figures stored below each interactive cell.

Run times on an ordinary laptop range from a few seconds to about a minute per notebook (longest: 01 and 05), with these exceptions:

  • about 5 minutes: 32 (lithography toolbox, many focus-exposure matrices and through-pitch series), 41 (telecentricity, some 200 polarization ray traces over the slit)

  • about 3 minutes: 21 (rays to waves, angular spectrum propagation to many planes), 28 (phase retrieval, many HIO runs), 47 (rays and waves, propagation to many planes and sums of 7 800 Gaussian beamlets)

  • about 2 minutes: 20 (polarization ray trace), 33 (lens aberrations, ray traces over the slit and Zernike sensitivities)

  • about 2.5 minutes: 52 (Abbe image formation, partially coherent images summed over thousands of source points)

  • about 3 minutes: 56 (Gaussian beam decomposition, sums of 9 000 beamlets over the pinhole plane)

  • about 1.5 minutes: 09 (mode analysis, basis fits and large LG expansions), 25 (Shack-Hartmann vs. phase diversity), 26 (holography, many refocusing runs on 1024² padded grids), 31 (vectorial imaging lithography), 37 (mask models, RCWA over a grid of pitches and duty cycles), 45 (Zernike gallery, fifteen lenses tuned, traced and propagated through focus), 53 (phase contrast and DIC), 55 (Fourier ptychography, many reconstructions)

Notebooks 14 (coated laser mirror), 24 (radius interferometer), 27 (holographic microscopy), 34 (Hopkins/SOCS), 35 (resist), 36 (rigorous mask), 38 (Jones pupils) and 54 (confocal microscopy) take 20 to 30 seconds, 39 (source optimization) and 40 (OPC) about 10 seconds; 57 (FDTD basics) takes about a minute.

The FFTs (pyoptics.fft) use all CPU cores; FFT-heavy notebooks such as 04 (chirp-z transform) and 26 (holography) run about 30 to 45 % faster than with single threaded FFTs. Set pyoptics.fft.workers = 1 to use a single core.

To re-execute all notebooks and store their outputs:

jupyter nbconvert --to notebook --execute --inplace notebooks/*.ipynb