Examples
Directional Coupler
Build and export a two-waveguide directional coupler.
This example creates a two-channel DirectionalCoupler. The input paths bend toward one another, run in parallel through the coupling section, and then bend back out to the output ports.
Code
from pathlib import Path
import laylight
from laylight.render import export_layout_png, new_layout
from laylight.structure.coupler import DirectionalCoupler
layout, top, tech = new_layout("DIRECTIONAL_COUPLER_EXAMPLE")
device = DirectionalCoupler(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 / "directional_coupler.gds"))
export_layout_png(
layout,
output_dir / "directional_coupler.png",
cell=top,
max_pixels=960,
)The code writes directional_coupler.gds and directional_coupler.png to build/examples.
Rendered layout

The parallel center section is the coupling region. Change gap or coupling_length on DirectionalCoupler to explore the geometry parameters.