Examples

Straight Waveguide

Build and export a straight waveguide with a slab and slab converters.

This example creates a WGStraight device with a 200 µm core, a wider slab, and converters at both ends. Placer inserts the device into the top-level cell while keeping the placement code independent from KLayout's low-level instance API.

Code

Run this snippet from the repository root after installing the workspace packages:

from pathlib import Path

import laylight
from laylight.render import export_layout_png, new_layout
from laylight.structure.wg import WGStraight


layout, top, tech = new_layout("STRAIGHT_WAVEGUIDE_EXAMPLE")
device = WGStraight(
    length=200,
    width=0.5,
    slab_enable=True,
    slab_width=8,
    slab_left_converter=True,
    slab_right_converter=True,
    layout=layout,
    tech=tech,
)

laylight.Placer(device).into(top)

output_dir = Path("build/examples")
output_dir.mkdir(parents=True, exist_ok=True)
layout.write(str(output_dir / "straight_waveguide.gds"))
export_layout_png(
    layout,
    output_dir / "straight_waveguide.png",
    cell=top,
    max_pixels=960,
)

The code writes both straight_waveguide.gds and straight_waveguide.png to build/examples.

Rendered layout

Rendered straight waveguide with slab converters

The wide hatched region is the slab. The narrower core is centered inside it, and the short end regions are the slab converters.

On this page