Skip to Content
DocsTutorialsTutorials

Tutorials

Step-by-step examples that solve a concrete problem with SVETlANNa.

Every tutorial contains complete, runnable code. We recommend following along in a Jupyter notebook or a Python script.

Contents


Difficulty

TutorialLevelKey concepts
Beam focusingBeginnerThinLens, FreeSpace, Wavefront
4f systemIntermediateFourier optics, spatial filtering
Phase grating on an SLMIntermediateSpatialLightModulator, diffraction orders, quantisation
Laguerre–Gaussian beamIntermediateCustom wavefronts, vortex beams, free-space propagation
Phase retrievalAdvancedIterative algorithms, Gerchberg–Saxton

Suggested order

Beam focusing

The basics: focusing a Gaussian beam with a lens. Introduces Wavefront, ThinLens and FreeSpace.

4f system

A classical 4f setup for optical filtering — Fourier optics put to work.

Phase grating on an SLM

A sinusoidal phase grating displayed on a SpatialLightModulator; the diffraction orders are compared with the Bessel-function prediction.

Laguerre–Gaussian beam

Building a vortex mode from scratch on the simulation grid and propagating it through free space, validated against the analytical solution.

Phase retrieval

The Gerchberg–Saxton algorithm: recovering phase from intensity measurements.


Prerequisites

Before you start we suggest reading:


Running the examples

# minimal template used throughout the tutorials import torch from svetlanna import SimulationParameters, Wavefront from svetlanna.units import ureg params = SimulationParameters.from_ranges( x_range=(-2*ureg.mm, 2*ureg.mm), x_points=512, y_range=(-2*ureg.mm, 2*ureg.mm), y_points=512, wavelength=632.8*ureg.nm ) wf = Wavefront.gaussian_beam(params, waist_radius=0.5*ureg.mm) print(f"Ready. Field shape: {wf.shape}")

To run on a GPU, install the CUDA build of PyTorch and call params.to('cuda') before creating any elements.