Examples

Examples

Runnable photonic layout examples with source code and rendered layouts.

These examples show the complete path from a laylight device to a layout file and a PNG preview. Each example has the same building blocks:

  1. Create a layout, top-level cell, and technology definition.
  2. Construct a device with parameters.
  3. Place the device into the top-level cell with laylight.Placer.
  4. Export the layout to GDS and PNG.

Available examples

Straight waveguide

Create a straight waveguide with a slab and slab converters.

Rendered straight waveguide with slab converters

See Straight Waveguide for the complete code.

Ring coupler

Create a coupled ring resonator with an integrated heater.

Rendered ring coupler with heater pads

See Ring Coupler for the complete code.

MMI splitter

Create a 1×2 multimode interference splitter with two output ports.

Rendered 1x2 MMI splitter

See MMI Splitter for the complete code.

Directional coupler

Bring two waveguides together for a defined coupling length, then separate them again.

Rendered directional coupler

See Directional Coupler for the complete code.

Spiral delay

Pack a long optical path into a compact spiral footprint.

Rendered spiral delay line

See Spiral Delay for the complete code.

Mach–Zehnder interferometer

Assemble a 1×2 MZI from MMI splitters, S-bends, and waveguide arms.

Rendered Mach-Zehnder interferometer

See Mach–Zehnder Interferometer for the complete code.

Run the package examples

The repository also includes a small command-line package that writes all six GDS examples to a directory:

uv run --package laylight-examples laylight-examples --output-dir build/examples

The page-specific snippets additionally export a PNG preview, which is useful when checking the result without opening KLayout.

On this page