Examples

Mach–Zehnder Interferometer

Build and export a 1x2 Mach-Zehnder interferometer.

The MZI example uses the default_1x2_mzi helper to assemble a splitter, two waveguide arms, S-bends, and a combiner. The resulting device exposes one input and two output ports.

Code

from pathlib import Path

import laylight
from laylight.render import export_layout_png, new_layout
from laylight.structure.mzi import default_1x2_mzi


layout, top, tech = new_layout("MZI_EXAMPLE")
device = default_1x2_mzi(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 / "mzi.gds"))
export_layout_png(
    layout,
    output_dir / "mzi.png",
    cell=top,
    max_pixels=960,
)

The code writes mzi.gds and mzi.png to build/examples.

Rendered layout

Rendered Mach-Zehnder interferometer

The two arms connect the input MMI to the output side. For a tunable version, construct MZI directly with heater_enable=True and configure the heater parameters.

On this page