This notebook contains every code example of the paper
GDSFactory: a tutorial introduction to photonic integrated circuit design
in Python. The cells tagged with a label are embedded, together with their
output, in the paper. Run the notebook top to bottom.
The first (untagged) cell configures the notebook. The cell silences
warnings and makes components render as static, print-friendly images
(white background, ports drawn as arrows, scale bar). Without the cell,
Jupyter shows the default KLayout-based rendering of GDSFactory. Plots are
drawn by small helpers of the gf_photonics_paper package, so that the
examples show only the essential code.
import os
import warnings
os.environ.setdefault("JAX_PLATFORMS", "cpu")
os.environ.setdefault("KFACTORY_LOGFILTER_LEVEL", "CRITICAL")
warnings.filterwarnings("ignore")
%matplotlib inline
import jax # noqa: E402
import kfactory as kf # noqa: E402
import numpy as np # noqa: E402
from gf_photonics_paper import use_paper_display # noqa: E402
jax.config.update("jax_enable_x64", True) # needed by circulax
kf.config.logfilter.level = "CRITICAL" # keep the output clean
use_paper_display(rotate={"mzm": 90}) # draw the long MZM uprightimport gdsfactory as gf
from gdsfactory.gpdk import PDK
PDK.activate() # the generic process design kit
# strip width, slot width, slot gap, length in µm
w_I, w_II, g, L = 0.5, 0.8, 0.1, 3.0
# an empty component (a GDS cell with extras)
c = gf.Component()
c.add_polygon(
[(0, 0), (L, 0), (L, (w_II - g) / 2), (0, w_I)],
layer="WG", # layer name defined by the PDK
)
c # render the layout inline1.2 Reusing library components¶
# instantiate a parametric cell from the library
offset = 0.75 * w_II + 0.25 * g
taper = gf.components.taper(
length=L,
width1=2 * (offset - g - w_I),
width2=(w_II - g) / 2,
)
ref = c << taper # add a *reference* to c
ref.movey(offset) # references can be transformed
c1.3 Cross-sections¶
w_rail = (w_II - g) / 2 # width of a single rail
xs_slot = gf.CrossSection(sections=(
# hidden core section: defines the ports
gf.Section(width=w_II, layer="WG", hidden=True,
port_names=("o1", "o2")),
# the two silicon rails left and right of the slot
gf.Section(width=w_rail, layer="WG",
offset=+(w_rail + g) / 2),
gf.Section(width=w_rail, layer="WG",
offset=-(w_rail + g) / 2),
))
# extrude a path (straight + Euler bend) along it
path = gf.path.straight(2) + gf.path.euler(radius=3)
gf.path.extrude(path, cross_section=xs_slot)1.4 Parametric cells (PCells) and ports¶
@gf.cell # caches the result and names the cell
def strip_to_slot(
w_I: float = 0.5, w_II: float = 0.8,
g: float = 0.1, L: float = 3.0,
) -> gf.Component:
c = gf.Component()
c.add_polygon(
[(0, 0), (L, 0), (L, (w_II - g) / 2), (0, w_I)],
layer="WG",
)
offset = 0.75 * w_II + 0.25 * g
t = gf.components.taper(length=L,
width1=2 * (offset - g - w_I),
width2=(w_II - g) / 2)
c.add_ref(t).movey(offset)
# ports: position, direction, width, cross-section
c.add_port("o1", center=(0, w_I / 2), width=w_I,
orientation=180, cross_section="strip")
c.add_port("o2", center=(L, w_II / 2), width=w_II,
orientation=0, cross_section=xs_slot)
return c
strip_to_slot()The port layout of a component can be checked with pprint_ports:
strip_to_slot().pprint_ports()1.5 Connecting components by their ports¶
# slot + thin silicon slabs below the rails, reaching
# outwards below the electrodes (the slot stays open)
xs_pm = xs_slot.append_sections(sections=tuple(
gf.Section(width=5.1, offset=s * (w_II / 4 + 2.55),
layer="SLAB90") for s in (-1, 1)))
@gf.cell
def eo_phase_shifter(length: float = 100.0,
cross_section=xs_pm) -> gf.Component:
c = gf.Component()
slot = c << gf.components.straight(
length=length, cross_section=cross_section)
s2s_in = c << strip_to_slot()
s2s_out = c << strip_to_slot()
# move & rotate references until ports meet
s2s_in.connect("o2", slot.ports["o1"])
s2s_out.connect("o2", slot.ports["o2"])
# expose the outer ports of the converters
c.add_port("o1", port=s2s_in.ports["o1"])
c.add_port("o2", port=s2s_out.ports["o1"])
return c
eo_phase_shifter(length=10)1.6 Hierarchy: a Mach-Zehnder modulator¶
import numpy as np
def gsg(w_s, gap, w_g, **kw) -> gf.CrossSection:
"""Coplanar ground-signal-ground line on metal 3."""
o = (w_s + w_g) / 2 + gap # offset of the grounds
return gf.CrossSection(sections=( # names: for tapers
gf.Section(width=w_s, layer="M3", name="s",
port_names=("e1", "e2"),
port_types=("electrical",) * 2),
gf.Section(width=w_g, offset=+o, layer="M3", name="g1"),
gf.Section(width=w_g, offset=-o, layer="M3", name="g2"),
), **kw)
@gf.cell
def mzm(length: float = 300, gap: float = 4,
w_gnd: float = 20, offset: float = 0) -> gf.Component:
c = gf.Component()
# generic MZI, with our phase shifter in both arms
mzi = c << gf.components.mzi(
delta_length=0, length_x=length, length_y=0,
straight_x_top=eo_phase_shifter,
straight_x_bot=eo_phase_shifter,
cross_section_x_top=xs_pm,
cross_section_x_bot=xs_pm,
add_optical_ports_arms=True,
auto_rename_ports=False)
y = mzi.ports["top_o1"].y - mzi.ports["in_o1"].y
# GSG electrodes along the arms, with via stacks
# down to the slabs along the path
via = gf.components.via_stack_slab_m3(size=(3, 3))
vias = tuple(gf.ComponentAlongPath(component=via,
spacing=5, padding=2.5, # vias inside the path
offset=s * (y + d * (gap / 2 + 1.6)))
for s in (-1, 1) for d in (-1, 1))
xs = gsg(2 * y - gap, gap, w_gnd)
line = c << gf.components.straight(length,
cross_section=xs.copy(components_along_path=vias))
line.center = (mzi.x, mzi.ports["in_o1"].y)
# feed beyond the output: a taper into GSG probe pads
# at 100 µm pitch, sheared sideways by `offset`
xs_pad = gsg(80, 20, 80)
taper = gf.components.taper_cross_section(
xs, xs_pad, length=300, npoints=101)
shift = lambda x: offset / 2 * (1 - np.cos(np.pi * x / 300))
sheared = gf.Component()
for layer, polygons in taper.get_polygons_points(
by="tuple").items():
for pts in polygons:
sheared.add_polygon([(x, y + shift(x))
for x, y in pts], layer=layer)
sheared.add_ports(taper.ports)
sheared.ports["e2"].center = (300, offset)
feed = c << sheared
pads = c << gf.components.straight(
80, cross_section=xs_pad)
feed.connect("e1", line.ports["e2"])
pads.connect("e1", feed.ports["e2"])
c.add_port("o1", port=mzi.ports["in_o1"])
c.add_port("o2", port=mzi.ports["ou_o1"])
return c
mzm()1.7 Routing¶
A bank of add-drop ring filters picks wavelength channels off a bus (the drop ports are turned north).
@gf.cell
def ring_bank(lengths: tuple = (1, 1.06, 1.12, 1.18),
gap: float = 0.2,
pitch: float = 40) -> gf.Component:
"""Bus waveguide with one add-drop ring per length."""
c = gf.Component()
previous = c << gf.components.straight(10)
c.add_port("o1", port=previous.ports["o1"])
for i, length_x in enumerate(lengths):
# longer ring -> red-shifted resonance
ring = c << gf.components.ring_double(
gap=gap, length_x=length_x)
ring.x = 30 + i * pitch
bend = c << gf.components.bend_euler()
bend.connect("o1", ring.ports["o3"], mirror=True)
c.add_port(f"d{i + 1}", port=bend.ports["o2"])
# waveguide from the previous ring to this one
gf.routing.route_single(
c, previous.ports["o2"], ring.ports["o1"],
cross_section="strip")
previous = ring
c.add_port("o2", port=previous.ports["o2"])
return c
ring_bank()A flat-top CROW band filter in front of the ring banks splits the four channels into two bands of two channels each.
from functools import partial
def crow(gaps=(0.123, 0.153)) -> gf.Component:
"""Three racetracks of 90.87 µm circumference: FSR of
4 channels, pass band between channels 1 and 2."""
cs = [partial(gf.components.coupler_straight,
length=23.443, gap=g)
for g in (gaps[0], gaps[1], gaps[1], gaps[0])]
return gf.components.ring_crow_couplers(
radius=(7, 7, 7), couplers=tuple(cs))
@gf.cell
def wdm_demux(n: int = 4, dl: float = 0.06,
gap: float = 0.2,
pitch: float = 300) -> gf.Component:
"""CROW band splitter followed by two ring banks."""
c = gf.Component()
band = c << crow()
lx = tuple(1 + i * dl for i in range(n))
lo = c << ring_bank(lx[:n // 2], gap, pitch)
hi = c << ring_bank(lx[n // 2:], gap, pitch)
lo.mirror_x() # light runs west
# bank buses level with the CROW drop port, drops at
# one pitch, but inputs at least 30 µm beside the CROW
for bank in (lo, hi):
bank.movey(band.ports["o3"].y - bank.ports["o1"].y)
lo.movex(min(band.x - pitch / 2 - lo.ports["d1"].x,
band.xmin - 30 - lo.ports["o1"].x))
hi.movex(max(band.x + pitch / 2 - hi.ports["d1"].x,
band.xmax + 30 - hi.ports["o1"].x))
route = partial(gf.routing.route_single, c,
cross_section="strip")
route(band.ports["o3"], lo.ports["o1"]) # straight
route(band.ports["o2"], hi.ports["o1"], steps=[ # up
{"x": band.xmax + 10}, {"y": hi.ports["o1"].y}])
c.add_port("o1", port=band.ports["o1"])
c.add_port("o2", port=hi.ports["o2"])
for i in range(n // 2):
c.add_port(f"d{i + 1}", port=lo.ports[f"d{i + 1}"])
c.add_port(f"d{i + n // 2 + 1}",
port=hi.ports[f"d{i + 1}"])
return c
wdm_demux(pitch=150) # compact, for printThe transmitter lane: four upright modulators at a compact pitch, whose feeds fan out to probe pads at a wider pitch. The demultiplexer lies west and the multiplexer east of the modulators, so that no ring lies below the metal.
@gf.cell
def tx_lane(n: int = 4, pitch: float = 150,
pad_pitch: float = 350) -> gf.Component:
c = gf.Component()
mods = [c << mzm(offset=((n - 1) / 2 - i)
* (pad_pitch - pitch)) for i in range(n)]
for i, m in enumerate(mods): # upright, side by side
m.rotate(90)
m.movex(i * pitch - m.ports["o1"].x)
o1, o2 = mods[0].ports["o1"], mods[0].ports["o2"]
x_w = o1.x - pitch / 2 # west and east of the
x_e = mods[-1].ports["o1"].x + pitch / 2 # modulators
# filters beside the modulators, drops facing them
demux = c << wdm_demux(n=n, pitch=80)
demux.rotate(90)
demux.mirror_x()
mux = c << wdm_demux(n=n, pitch=80)
mux.rotate(90)
demux.xmax, mux.xmin = x_w - 60, x_e + 60
demux.y = mux.y = (o1.y + o2.y) / 2
# nested routes below and above the modulators
drops = sorted((demux.ports[f"d{i + 1}"]
for i in range(n)), key=lambda p: -p.y)
for k, (d, m) in enumerate(zip(drops, mods)):
s, t = 10 * k, 10 * (n - 1 - k)
gf.routing.route_single(c, d, m.ports["o1"],
cross_section="strip", steps=[{"x": x_w - s},
{"y": o1.y - 20 - s}, {"x": m.ports["o1"].x}])
gf.routing.route_single(c, m.ports["o2"],
mux.ports[d.name], cross_section="strip",
steps=[{"y": o2.y + 20 + t}, {"x": x_e + t},
{"y": mux.ports[d.name].y}])
c.add_port("o1", port=demux.ports["o1"])
c.add_port("o2", port=mux.ports["o1"])
return c
tx_lane()1.8 The receiver lane in YAML¶
The demultiplexer feeds germanium photodiodes directly. Both contacts leave the photodiode on the same side, so a tapered line of signal and one ground connects the contacts to GSG probe pads, whose two ground pads are joined behind the signal pad. Python PCells become available to YAML by registering them with the active PDK.
def gs(w: float, d: float) -> gf.CrossSection:
"""Signal line and one ground at distance d (east)."""
return gf.CrossSection(sections=(
gf.Section(width=w, layer="M3", name="s",
port_names=("e1", "s2"),
port_types=("electrical",) * 2),
gf.Section(width=w, offset=d, layer="M3", name="g",
port_names=("e2", "g2"),
port_types=("electrical",) * 2)))
@gf.cell
def gsg_pads(size: float = 80, pitch: float = 100,
length: float = 60) -> gf.Component:
"""GSG probe pads, fed by a tapered GS line from two
contacts 15 µm apart, grounds joined behind."""
c = gf.Component()
a, p, g, h = size / 2, pitch, pitch - size, length
feed = c << gf.components.taper_cross_section(
gs(10, 15), gs(size, pitch), length=length)
feed.rotate(90) # contacts at the bottom
c.add_polygon([(-a, h), (a, h), (a, h + size),
(-a, h + size)], layer="M3")
c.add_polygon([(-p - a, h), (-p + a, h),
(-p + a, h + size + g), (p - a, h + size + g),
(p - a, h), (p + a, h), (p + a, h + size + 2 * g),
(-p - a, h + size + 2 * g)], layer="M3")
c.add_ports([feed.ports["e1"], feed.ports["e2"]])
return c
PDK.register_cells(wdm_demux=wdm_demux, gsg_pads=gsg_pads)
@gf.cell
def rx_lane() -> gf.Component:
return gf.read.from_yaml("rx_lane.pic.yml")
rx_lane()2. Regression tests¶
Rev. 2 of the converter: to build a second device, a designer lengthens the
default taper of strip_to_slot from 3 µm to 5 µm (everything else is
unchanged). Defined here, but not yet used.
import pathlib
import tempfile
workdir = pathlib.Path(tempfile.mkdtemp()) # scratch directory for GDS files
@gf.cell
def strip_to_slot_rev2(
w_I: float = 0.5, w_II: float = 0.8,
g: float = 0.1, L: float = 5.0, # Rev. 2: L = 5 µm
) -> gf.Component:
c = gf.Component()
c.add_polygon(
[(0, 0), (L, 0), (L, (w_II - g) / 2), (0, w_I)],
layer="WG",
)
offset = 0.75 * w_II + 0.25 * g
t = gf.components.taper(length=L,
width1=2 * (offset - g - w_I), width2=(w_II - g) / 2)
c.add_ref(t).movey(offset)
c.add_port("o1", center=(0, w_I / 2), width=w_I,
orientation=180, cross_section="strip")
c.add_port("o2", center=(L, w_II / 2), width=w_II,
orientation=0, cross_section=xs_slot)
return c
strip_to_slot_rev1 = strip_to_slot# Rev. 1 was taped out: store its layout as reference
short = dict(length=2, cross_section=xs_slot) # compact
ref_gds = eo_phase_shifter(**short).write_gds(
workdir / "ref.gds")
strip_to_slot = strip_to_slot_rev2 # switch to Rev. 2
gf.clear_cache() # forget cells built with Rev. 1
run_gds = eo_phase_shifter(**short).write_gds(
workdir / "run.gds")
# compare: layout diff, then XOR of every layer
result = gf.diff(ref_gds, run_gds,
out_file=workdir / "diff.gds")
assert result # True: the layout has changed
# old (top), new (middle) and their XOR (bottom)
xor = gf.import_gds(workdir / "diff.gds", cellname="_xor")
old, new = gf.import_gds(ref_gds), gf.import_gds(run_gds)
gf.grid([xor, new, old], shape=(3, 1), spacing=(1, 1))Restore Rev. 1 for the rest of the notebook.
strip_to_slot = strip_to_slot_rev1
gf.clear_cache()from femwell.maxwell.waveguide import compute_modes
from femwell.mesh import mesh_from_OrderedDict
from skfem import Basis, ElementTriP0
from skfem.io.meshio import from_meshio
import shapely
from gf_photonics_paper import plot_mode, xs_to_polygons
# lateral geometry from the cross-section,
# heights and materials from the PDK layer stack
shapes, material = xs_to_polygons(
xs_pm, PDK.layer_stack, clad="polymer", xspan=12)
t = PDK.layer_stack.layers["core"].thickness
slot = {"slot": shapely.box(-g, 0, g, t)} # own region
cores = {k: v for k, v in shapes.items() if "core" in k}
shapes = cores | slot | shapes # rails take precedence
material["slot"] = "polymer"
mesh = from_meshio(mesh_from_OrderedDict(shapes,
{k: {"resolution": 0.01, "distance": 0.4}
for k in shapes if k.startswith("core")},
default_resolution_max=0.3))
basis = Basis(mesh, ElementTriP0())
n = {"si": 3.48, "sio2": 1.44, "polymer": 1.7}
eps = basis.zeros()
for name in shapes:
dofs = basis.get_dofs(elements=name)
eps[dofs] = n[material[name]] ** 2
mode = compute_modes(basis, eps, wavelength=1.55,
num_modes=1)[0]
# share of the mode in the slot, where the field is
gamma = mode.calculate_confinement_factor("slot").real
plot_mode(mode)---------------------------------------------------------------------------
OSError Traceback (most recent call last)
Cell In[16], line 2
1 from femwell.maxwell.waveguide import compute_modes
----> 2 from femwell.mesh import mesh_from_OrderedDict
3 from skfem import Basis, ElementTriP0
4 from skfem.io.meshio import from_meshio
5 import shapely
File ~/work/photonics_paper/photonics_paper/.venv/lib/python3.13/site-packages/femwell/mesh/__init__.py:1
----> 1 from femwell.mesh.mesh import mesh_from_Dict, mesh_from_OrderedDict
2 from femwell.mesh.meshtracker import MeshTracker
4 __all__ = [
5 "MeshTracker",
6 "mesh_from_OrderedDict",
7 "mesh_from_Dict",
8 ]
File ~/work/photonics_paper/photonics_paper/.venv/lib/python3.13/site-packages/femwell/mesh/mesh.py:5
2 from itertools import combinations, product
3 from typing import Dict, List, Optional, Tuple
----> 5 import gmsh
6 import numpy as np
7 import pygmsh
File ~/work/photonics_paper/photonics_paper/.venv/lib/python3.13/site-packages/gmsh.py:92
88 print("Warning: could not find Gmsh shared library " + libname +
89 " with ctypes.util.find_library() or in the following locations: " +
90 str(possible_libpaths))
91
---> 92 lib = CDLL(libpath)
93
94 try_numpy = True # set this to False to never use numpy
95
File ~/.local/share/uv/python/cpython-3.13.18-linux-x86_64-gnu/lib/python3.13/ctypes/__init__.py:361, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)
358 if name:
359 name = _os.fspath(name)
--> 361 self._handle = self._load_library(name, mode, handle, winmode)
File ~/.local/share/uv/python/cpython-3.13.18-linux-x86_64-gnu/lib/python3.13/ctypes/__init__.py:403, in CDLL._load_library(self, name, mode, handle, winmode)
401 if handle is not None:
402 return handle
--> 403 return _dlopen(name, mode)
OSError: libGLU.so.1: cannot open shared object file: No such file or directoryprint(f"n_eff = {mode.n_eff.real:.3f}, Γ_slot = {gamma:.3f}, "
f"Γ_polymer = {mode.calculate_confinement_factor('clad').real + gamma:.3f}")3.2 Circuit simulation with SAX¶
Compact models are plain Python functions returning S-parameters.
import jax.numpy as jnp
import sax
L_bend = gf.components.bend_euler().info["length"]
def straight(wl=1.55, length=10.0, **kw):
s = sax.models.straight(wl=wl, wl0=1.55, neff=2.44,
ng=4.2, length=length)
return sax.rename_ports(s, {"in0": "o1",
"out0": "o2"})
def bend_euler(wl=1.55, **kw):
return straight(wl, length=L_bend)
def coupler_ring(wl=1.55, gap=0.2, length_x=4.0, **kw):
k2 = 0.6 * jnp.exp(-gap / 0.12) # toy |kappa|^2(gap)
t, k = jnp.sqrt(1 - k2), 1j * jnp.sqrt(k2)
# phase from the coupling point to a ring port
# (one bend + half the straight = 1/4 of the ring)
q = straight(wl, L_bend + length_x / 2)["o1", "o2"]
return sax.reciprocal({
("o1", "o4"): t, ("o1", "o3"): k * q,
("o2", "o4"): k * q, ("o2", "o3"): t * q**2,
})
models = dict(straight=straight, bend_euler=bend_euler,
coupler_ring=coupler_ring)from gf_photonics_paper import plot_spectra
# netlist extracted from the layout (incl. hierarchy)
netlist = ring_bank().get_netlist(recursive=True)
circuit, _ = sax.circuit(netlist, models=models)
wl = jnp.linspace(1.546, 1.556, 2001)
S = circuit(wl=wl)
ports = ["o2", "d1", "d2", "d3", "d4"]
plot_spectra(wl, {p: jnp.abs(S["o1", p]) ** 2
for p in ports}, db=True)3.3 Gradient-based optimization¶
The circuit is differentiable: we tune the coupling gap of the rings so that the drop port reaches a 0.5 nm wide pass band.
from scipy.optimize import minimize
ring = gf.components.ring_double(gap=0.2, length_x=1)
sim, _ = sax.circuit(ring.get_netlist(recursive=True),
models=models)
wl = jnp.linspace(1.5475, 1.5515, 801)
def drop(gap): # drop-port spectrum vs. coupling gap
S = sim(wl=wl, coupler_ring={"gap": gap},
coupler_ring2={"gap": gap})
return jnp.abs(S["o1", "o3"]) ** 2
wl0 = wl[jnp.argmax(drop(0.2))] # resonance
target = 1 / (1 + ((wl - wl0) / 0.25e-3) ** 2)
@jax.jit
def loss(x): # mismatch to the target spectrum
return jnp.mean((drop(x[0]) - target) ** 2)
res = minimize(loss, x0=[0.2], bounds=[(0.1, 0.4)],
jac=jax.jit(jax.grad(loss)))
gap = round(float(res.x[0]), 3) # snap to the 1 nm grid
plot_spectra(wl - wl0, {"gap = 0.200 µm": drop(0.2),
f"gap = {gap:.3f} µm": drop(gap), "target": target},
detuning=True)The optimized value is fed straight back into the layout:
gf.components.ring_double(gap=gap, length_x=1)3.4 Synthesis of a flat-top CROW band filter¶
The CROW band filter of the demultiplexer (section 1.7). The netlist is extracted from the layout, and the gaps are optimized for a flat pass band over channels 1 and 2 and suppression of channels 3 and 4.
def coupler_straight(wl=1.55, gap=0.2, length=10.0, **kw):
kappa = 0.06 * jnp.exp(-(gap - 0.1) / 0.1) # toy
k2 = jnp.sin(kappa * length) ** 2
t, k = jnp.sqrt(1 - k2), 1j * jnp.sqrt(k2)
p = straight(wl, length)["o1", "o2"]
return sax.reciprocal({
("o1", "o4"): t * p, ("o2", "o3"): t * p,
("o1", "o3"): k * p, ("o2", "o4"): k * p})
def bend_circular(wl=1.55, radius=10.0, **kw):
return straight(wl, length=jnp.pi * radius / 2)
sim, _ = sax.circuit(crow((0.15, 0.3)).get_netlist(),
models={"coupler_straight": coupler_straight,
"bend_circular": bend_circular})
wl0 = 1.55028 # band center, between channels 1 and 2
wl = wl0 + jnp.linspace(-3.15e-3, 3.15e-3, 1261) # 1 FSR
dwl = (wl - wl0) * 1e3 # detuning in nm
def drop(x): # bus couplers: instances 1 and 2
bus, inner = {"gap": x[0]}, {"gap": x[1]}
S = sim(wl=wl, coupler_straight=bus,
coupler_straight2=bus,
coupler_straight3=inner,
coupler_straight4=inner)
return jnp.abs(S["o1", "o3"]) ** 2
# channels 1, 2 at ±0.79 nm pass, 3, 4 at ±2.36 nm
# are blocked, each with a margin of ±0.3 nm
inside, outside = abs(dwl) < 1.1, abs(dwl) > 2.05
loss = jax.jit(lambda x: (
jnp.mean((1 - drop(x)) ** 2, where=inside)
+ jnp.mean(drop(x) ** 2, where=outside)))
res = minimize(loss, x0=[0.15, 0.3],
bounds=[(0.1, 0.5)] * 2,
jac=jax.jit(jax.grad(loss)))
gaps = [round(float(x), 3) for x in res.x] # 1 nm grid
spectra = {"initial gaps": drop([0.15, 0.3]),
"optimized gaps": drop(gaps)}
layout = crow(gaps) # layout with optimized gaps
plot_spectra(wl - wl0, spectra, db=True, detuning=True)layoutprint("optimized gaps (µm):", gaps)
d = drop(gaps)
print(f"ripple {-10 * jnp.log10(d[inside].min()):.2f} dB, "
f"suppression {-10 * jnp.log10(d[outside].max()):.1f} dB")
pass_1dB = dwl[d > 10 ** -0.1]
at_ch34 = jnp.interp(jnp.array([-2.36, 2.36]), dwl, d)
print(f"1 dB pass band {pass_1dB.max() - pass_1dB.min():.2f} nm, "
f"channels 3 and 4 suppressed by "
f"{-10 * jnp.log10(at_ch34.max()):.1f} dB")
# the demultiplexer of section 1.7 uses these gaps
assert tuple(gaps) == crow.__defaults__[0], gapsThe complete demultiplexer of section 1.7 with the optimized CROW. The
recursive netlist descends into the two straights of coupler_straight;
these sub-netlists are replaced by the compact coupler model.
netlist = wdm_demux().get_netlist(recursive=True)
demux_models = dict(models, bend_circular=bend_circular)
for name in [k for k in netlist if k.startswith("coupler_straight")]:
del netlist[name]
demux_models[name] = coupler_straight
demux_sim, _ = sax.circuit(netlist, models=demux_models)
wl = jnp.linspace(1.546, 1.556, 4001)
S = demux_sim(wl=wl)
drops = [f"d{i}" for i in range(1, 5)]
T = {p: jnp.abs(S["o1", p]) ** 2 for p in drops}
channels = jnp.array([wl[jnp.argmax(T[p])] for p in drops])
print("channels (nm):", jnp.round(channels * 1e3, 2))
xt = jnp.array([[10 * jnp.log10(jnp.interp(ch, wl, T[p]))
for ch in channels] for p in drops])
print("transmission (dB), rows: drop port, columns: channel")
print(jnp.round(xt, 1))
same_band = [(0, 1), (1, 0), (2, 3), (3, 2)]
other = [(i, j) for i in range(4) for j in range(4)
if i // 2 != j // 2]
print(f"insertion loss <= {-xt.diagonal().min():.2f} dB, "
f"crosstalk within a band <= {max(xt[i, j] for i, j in same_band):.1f} dB, "
f"from the other band <= {max(xt[i, j] for i, j in other):.1f} dB")3.5 Time-domain simulation of the optical link¶
One wavelength channel of the transceiver, end to end, simulated with circulax:
laser - GC - demux ring - MZM - mux ring - GC - fiber - GC - RX ring - Ge PD - 50 Ω
|
PRBS driver - RC electrodesThe CROW band filters pass about 290 GHz and are omitted.
First, a few components: a waveguide with a true propagation delay, a lossy element (grating couplers, fiber, phase bias) and a photodiode.
from circulax import compile_circuit
from circulax.components import phase_shifter_factory
from circulax.components.base_component import Signals, component
from circulax.components.electronic import (
WAVE_PWL, Capacitor, Resistor, WaveformVoltageSource)
from circulax.components.photonic import DirectionalCoupler, OpticalSource
C_UM = 2.99792458e14 # speed of light in µm/s
def matched(s, a1, a2, T):
"""Reciprocal two-port with transmission T, matched at both ports.
a1, a2 are the incoming waves (possibly from an earlier time).
"""
b1, b2 = T * a2, T * a1
return {"p1": s.a1 - b1, "p2": s.a2 - b2,
"a1": s.p1 - s.a1 - b1, "a2": s.p2 - s.a2 - b2}, {}
@component(ports=("p1", "p2"), states=("a1", "a2"))
def Waveguide(signals: Signals, length_um: float = 10.0, loss_dB_cm: float = 2.0,
neff: float = 2.44, n_group: float = 4.2, wavelength_nm: float = 1550.0):
"""Phase, loss and the group delay L n_g / c."""
T = 10 ** (-loss_dB_cm * length_um / 2e5) * jnp.exp(
-2j * jnp.pi * neff * length_um * 1e3 / wavelength_nm)
past = signals.at_delay(length_um * n_group / C_UM)
return matched(signals, past.a1, past.a2, T)
@component(ports=("p1", "p2"), states=("a1", "a2"), holomorphic=True)
def Loss(signals: Signals, loss_dB: float = 3.0, phase: float = 0.0):
"""Grating coupler, fiber or phase bias (no delay)."""
T = 10 ** (-loss_dB / 20) * jnp.exp(1j * phase)
return matched(signals, signals.a1, signals.a2, T)
@component(ports=("optical", "anode", "cathode"), holomorphic=False)
def Photodiode(signals: Signals, responsivity: float = 0.8):
"""Absorbs the light, delivers R·P as photocurrent."""
i = responsivity * jnp.abs(signals.optical) ** 2
return {"optical": signals.optical, "anode": -i, "cathode": i}, {}The modulator parameters follow from the design: VπL from the slot width, the electro-optic coefficient of the polymer and the confinement factor of section 3.1; the RC time constant of one arm from the slot capacitance and the resistance of the doped slabs.
L_mod, w_slot, h = 300e-6, 0.1e-6, 0.22e-6 # m
n_eo, r33 = 1.7, 100e-12 # polymer: index, EO coeff.
vpil = 1.55e-6 * w_slot / (n_eo**3 * r33 * gamma)
C_arm = 8.854e-12 * 2.8 * h * L_mod / w_slot # eps 2.8
R_arm = 2 * 10e3 * 2.5e-6 / L_mod # slabs, 10 kΩ/sq
EOShifter = phase_shifter_factory( # Pockels effect
delta_neff=lambda v: 1.55e-6 / (2 * vpil) * v,
loss_dB_cm=2.0, name="EOShifter")
print(f"VπL = {vpil * 1e3:.2f} V mm\n"
f"Vπ = {vpil / L_mod:.1f} V\n"
f"RC = {R_arm * C_arm * 1e12:.1f} ps")The netlist uses the same structure as GDSFactory netlists. Each add-drop ring consists of two directional couplers and two delayed half-rings, with the circumference and the (optimized) coupling of the ring filters above.
L_ring = 2 * (2 * L_bend + 1 + 0.01) # ring_double(length_x=1)
kappa2 = float(0.6 * np.exp(-gap / 0.12)) # optimized gap
def add_ring(net, name, bus_in, drop):
"""Add-drop ring; unused ports end in matched loads."""
inst, conn = net["instances"], net["connections"]
for c_ in ("C1", "C2"):
inst[f"{name}_{c_}"] = {"component": "coupler", "settings": {"coupling": kappa2}}
for h_ in ("A", "B"):
inst[f"{name}_{h_}"] = {"component": "wg", "settings": {"length_um": L_ring / 2}}
conn.update({f"{name}_C1,p4": f"{name}_A,p1", f"{name}_A,p2": f"{name}_C2,p1",
f"{name}_C2,p3": f"{name}_B,p1", f"{name}_B,p2": f"{name}_C1,p2",
f"{name}_C1,p1": bus_in, f"{name}_C2,p4": drop})
for port in (f"{name}_C1,p3", f"{name}_C2,p2"): # through, add
load = port.replace(",", "_")
inst[load] = {"component": "R", "settings": {"R": 1.0}}
conn[port] = f"{load},p1"
conn[f"{load},p2"] = "GND,p1"
def prbs7(n_bits, baud, vpp, rise=0.25):
"""PRBS7 pattern as a piecewise-linear drive voltage."""
state, bits = 0x7F, []
for _ in range(n_bits):
bits.append(state & 1)
state = (state >> 1) | (((state ^ (state >> 1)) & 1) << 6)
levels = vpp * (np.array(bits) - 0.5)
t, v = [0.0], [levels[0]]
for k in range(1, n_bits):
if levels[k] != levels[k - 1]:
t += [k / baud, (k + rise) / baud]
v += [levels[k - 1], levels[k]]
t.append(n_bits / baud)
v.append(levels[-1])
return np.array(t), np.array(v)
def link_netlist(baud, n_bits=144):
vpp = 0.5 * vpil / L_mod # push-pull: π phase swing
t, v = prbs7(n_bits, baud, vpp)
gc = {"component": "loss", "settings": {"loss_dB": 3.0}}
R = lambda r: {"component": "R", "settings": {"R": r}} # noqa: E731
C = lambda c_: {"component": "C", "settings": {"C": c_}} # noqa: E731
arm = {"component": "eo", "settings": {"length_um": L_mod * 1e6}}
inst = {
"GND": {"component": "ground"},
"LASER": {"component": "laser", "settings": {"power": 10e-3}},
"GC_TX_IN": gc, "GC_TX_OUT": gc, "GC_RX": gc,
"FIBER": {"component": "loss", "settings": {"loss_dB": 2.0}},
"SPLIT": {"component": "coupler", "settings": {"coupling": 0.5}},
"COMB": {"component": "coupler", "settings": {"coupling": 0.5}},
"ARM_A": arm, "ARM_B": arm,
"BIAS": {"component": "loss", "settings": {"loss_dB": 0.0, "phase": -np.pi / 2}},
"DUMP1": R(1.0), "DUMP2": R(1.0),
"DRIVER": {"component": "vsrc", "settings": {
"kind": WAVE_PWL, "pwl_t": jnp.asarray(t), "pwl_v": jnp.asarray(v)}},
"R_DRV": R(50.0), "R_A": R(R_arm), "R_B": R(R_arm),
"C_A": C(C_arm), "C_B": C(C_arm),
"PD": {"component": "pd", "settings": {"responsivity": 0.8}},
"C_PD": C(15e-15), "R_LOAD": R(50.0),
}
conn = {
"LASER,p1": "GC_TX_IN,p1", "LASER,p2": "GND,p1",
"SPLIT,p3": "ARM_A,o1", "SPLIT,p4": "ARM_B,o1",
"ARM_A,o2": "COMB,p1", "ARM_B,o2": "BIAS,p1", "BIAS,p2": "COMB,p2",
"SPLIT,p2": "DUMP1,p1", "COMB,p4": "DUMP2,p1",
"DUMP1,p2": "GND,p1", "DUMP2,p2": "GND,p1",
"GC_TX_OUT,p2": "FIBER,p1", "FIBER,p2": "GC_RX,p1",
"DRIVER,p1": "R_DRV,p1", "DRIVER,p2": "GND,p1",
"R_DRV,p2": "R_A,p1", "R_B,p1": "R_DRV,p2",
"R_A,p2": "ARM_A,anode", "C_A,p1": "ARM_A,anode",
"R_B,p2": "ARM_B,cathode", "C_B,p1": "ARM_B,cathode",
"ARM_A,cathode": "GND,p1", "ARM_B,anode": "GND,p1",
"C_A,p2": "GND,p1", "C_B,p2": "GND,p1",
"PD,anode": "R_LOAD,p1", "C_PD,p1": "PD,anode",
"PD,cathode": "GND,p1", "R_LOAD,p2": "GND,p1", "C_PD,p2": "GND,p1",
}
net = {"instances": inst, "connections": conn, "ports": {"rx": "PD,anode"}}
add_ring(net, "DEMUX", bus_in="GC_TX_IN,p2", drop="SPLIT,p1")
add_ring(net, "MUX", bus_in="GC_TX_OUT,p1", drop="COMB,p3")
add_ring(net, "RX", bus_in="GC_RX,p2", drop="PD,optical")
return net
link_models = {"ground": lambda: 0, "laser": OpticalSource,
"coupler": DirectionalCoupler, "wg": Waveguide,
"loss": Loss, "eo": EOShifter, "pd": Photodiode,
"R": Resistor, "C": Capacitor, "vsrc": WaveformVoltageSource}
# carrier wavelength: a resonance of the rings, from the
# dispersive effective index of the strip waveguide
neff = lambda wl_nm: 2.44 - (wl_nm - 1550) * (4.2 - 2.44) / 1550 # noqa: E731
m = round(neff(1550) * L_ring / 1.55) # resonance order
wl_ch = float(4.2 * L_ring * 1e3 / (m + L_ring * 1e3 * (4.2 - 2.44) / 1550))
carrier = {"wavelength_nm": wl_ch, "neff": float(neff(wl_ch))}from gf_photonics_paper import plot_eye
baud, spu = 50e9, 16 # symbol rate, samples per UI
link = compile_circuit(link_netlist(baud), link_models,
is_complex=True)
y0 = link.dc(params=carrier) # operating point, t = 0
ts = jnp.arange(144 * spu + 1) / (baud * spu)
sol = link.transient(t0=0.0, t1=float(ts[-1]),
dt0=float(ts[1]) / 2, y0=y0, saveat=ts,
params=carrier, max_steps=40 * len(ts))
v_rx = link.port(sol.ys, "rx").real * 1e3 # mV
plot_eye(v_rx, samples_per_ui=spu)4. Process design kits¶
def slot(width: float = 0.8, gap: float = 0.1):
"""Slot waveguide cross-section factory."""
w_rail = (width - gap) / 2
return gf.CrossSection(sections=(
gf.Section(width=width, layer="WG", hidden=True,
port_names=("o1", "o2")),
*[gf.Section(width=w_rail, layer="WG",
offset=s * (w_rail + gap) / 2)
for s in (-1, 1)]))
tx_pdk = gf.Pdk(
name="transceiver",
layers=PDK.layers, # layer names <-> GDS numbers
layer_stack=PDK.layer_stack, # heights, materials
layer_views=PDK.layer_views, # colors, patterns
cross_sections=PDK.cross_sections | {"slot": slot},
cells=PDK.cells | {"strip_to_slot": strip_to_slot,
"eo_phase_shifter": eo_phase_shifter, "mzm": mzm,
"wdm_demux": wdm_demux, "tx_lane": tx_lane,
"rx_lane": rx_lane},
models=models, # compact models for SAX
)
tx_pdk.activate()
# PDK content is now addressable by name, e.g.
mod = gf.get_component("mzm", length=100)
xs = gf.get_cross_section("slot", gap=0.12)
# the layer stack: where each layer sits in 3D (µm)
for name in ["core", "slab90", "metal3"]:
lvl = tx_pdk.layer_stack.layers[name]
print(f"{name:6} z={lvl.zmin:4.2f} "
f"t={lvl.thickness:4.2f} {lvl.material}")import klayout.db as kdb
def drc(c, layer="WG", min_width=0.15, min_space=0.15):
"""Minimal width and spacing rules with KLayout."""
to_dbu = lambda x: round(x / c.kcl.dbu)
region = kdb.Region(
c.begin_shapes_rec(gf.get_layer(layer)))
errors = (region.width_check(to_dbu(min_width))
+ region.space_check(to_dbu(min_space)))
# copy the layout and draw the error markers
marked = gf.Component()
marked << c
marked.shapes(gf.get_layer("DRC_MARKER")).insert(
errors.polygons(to_dbu(0.03)))
return marked
drc(strip_to_slot())Collisions between waveguides, such as a route that runs over a ring.
from itertools import combinations
def collisions(c, layer="WG", skip=()):
"""Overlaps between the waveguides of different
instances, checked once in every cell below c."""
ly, li = c.kcl.layout, gf.get_layer(layer)
shapes = lambda ci: kdb.Region(
ly.cell(ci).begin_shapes_rec(li))
found = {}
for ci in (c.cell_index(), *c.kdb_cell.called_cells()):
if c.kcl[ci].function_name in skip:
continue
cell = ly.cell(ci)
parts = [kdb.Region(cell.shapes(li))] + [
shapes(i.cell_index).transformed(i.cplx_trans)
for i in cell.each_inst()]
found[ci] = kdb.Region()
for a, b in combinations(parts, 2):
if a.bbox().overlaps(b.bbox()):
found[ci] += a & b
# collect the overlaps in the coordinates of c
errors = found.get(c.cell_index(), kdb.Region())
it = kdb.RecursiveInstanceIterator(ly, c.kdb_cell)
while not it.at_end():
ci = it.inst_cell().cell_index()
if not found.get(ci, kdb.Region()).is_empty():
errors += found[ci].transformed(
it.trans() * it.inst_trans())
it.next()
return errors.merged()
# a route whose end lies too close beside its start
c = gf.Component()
band = c << crow()
bus = c << gf.components.straight(50)
bus.move((45, 75))
gf.routing.route_single(c, band.ports["o2"],
bus.ports["o1"], cross_section="strip",
start_straight_length=10)
c.shapes(gf.get_layer("DRC_MARKER")).insert(
collisions(c).sized(round(0.5 / c.kcl.dbu)))
c@gf.cell
def test_site(dut: str = "tx_lane",
measurement: str = "spectrum",
x_grating_offset: float = 0):
c = gf.Component()
# route the optical ports to grating couplers
c << gf.routing.add_fiber_array(
gf.get_component(dut), with_loopback=True,
straight_separation=10, # as the bundles
x_grating_offset=x_grating_offset)
# metadata for the measurement & analysis pipeline
c.info["doe"] = dut
c.info["measurement"] = measurement
return c
test_site("tx_lane")6.2 Test structures¶
# cut-back structures: 16, 48 and 80 short phase
# shifters in series, each one a test site
for rows in (1, 3, 5): # 16 devices per row
tx_pdk.register_cells(**{f"cutback_{16 * rows}":
partial(gf.components.cutback_component, cols=4,
rows=rows, component=eo_phase_shifter(length=2))})
cutbacks = [test_site(f"cutback_{n}", "insertion_loss")
for n in (16, 48, 80)]
# ring resonators with four coupling gaps
for n in (150, 200, 250, 300): # gap in nm
tx_pdk.register_cells(**{f"ring_{n}": partial(
gf.components.ring_single, gap=n / 1e3)})
rings = [test_site(f"ring_{n}", "spectrum")
for n in (150, 200, 250, 300)]
# process control monitors for each layer
layers = ("WG", "SLAB90", "M1", "M2", "M3")
process_control = [
*[gf.components.litho_steps(layer=layer) # resolution
for layer in layers],
*[gf.components.litho_calipers(layer1="WG", layer2=layer)
for layer in layers[1:]], # overlay with WG
*[gf.components.resistance_meander(name=layer, # sheet R
res_layer=layer, pad_layer=layer) for layer in layers[2:]],
gf.components.via_chain(), # via resistance M1/M2
gf.components.verniers(), # WG width and gap
gf.components.cdsem_all(), # WG widths for the SEM
gf.components.align_wafer(), # alignment mark
]
test_structures = cutbacks + rings + process_control
gf.pack(test_structures, spacing=20)[0] # an overview6.3 The complete chip¶
import klayout.db as kdb
def place_free(c, cells, spacing=20, closing=100):
"""Place cells, largest first, at the lowest free
spot between the existing structures of c."""
dbu = c.kcl.dbu
s, d = round(spacing / dbu), round(closing / dbu)
taken = kdb.Region()
for layer in c.kcl.layer_indexes():
taken += kdb.Region(c.begin_shapes_rec(layer))
taken = taken.sized(round(1 / dbu)).smoothed(round(0.5 / dbu))
# closing: gaps below 2 * closing count as taken
taken = taken.sized(d).sized(-d)
free = kdb.Region(c.ibbox()) - taken.sized(s)
taken = kdb.Region(c.ibbox().enlarged(c.ibbox().width())) - free
for cell in sorted(cells, key=lambda x: -x.ibbox().area()):
w, h = cell.ibbox().width(), cell.ibbox().height()
box = kdb.Box(-w // 2, -h // 2, w - w // 2, h - h // 2)
spots = free - taken.minkowski_sum(box) # centers
p = min((p for poly in spots.each()
for p in poly.each_point_hull()),
key=lambda p: (p.y, p.x))
ref = c << cell
ref.center = (p.x * dbu, p.y * dbu)
taken += kdb.Region(ref.ibbox()).sized(s)
@gf.cell
def transceiver_chip() -> gf.Component:
content = gf.Component()
tx = content << test_site("tx_lane")
rx = content << test_site("rx_lane", "photocurrent",
x_grating_offset=-200)
rx.xmin, rx.ymin = tx.xmax + 100, tx.ymin # side by side
name = gf.components.text("TRX-1", size=50, layer="WG")
place_free(content, [name, *test_structures])
chip = gf.Component()
die = chip << gf.components.die(die_name=None,
size=(content.xsize + 300, content.ysize + 300))
chip.add_ref(content).center = die.center
assert collisions(chip, skip=("align_wafer",)).is_empty()
return chip
chip = transceiver_chip()
chip.write_gds(workdir / "transceiver.gds")
gf.labels.write_test_manifest(
chip, workdir / "manifest.csv",
parameters=["doe", "measurement"])
chipimport pandas as pd
manifest = pd.read_csv(workdir / "manifest.csv")
columns = ["doe", "x", "y", "measurement"]
print(manifest[columns].round(1).to_string(index=False))6.4 Dummy fill¶
from gf_photonics_paper import show_zoom
c = gf.Component()
c << chip # the chip of the previous section
tile = gf.components.rectangle(size=(4, 4), layer="M3")
c.fill(tile, fill_layers=[("FLOORPLAN", -50)],
exclude_layers=[("M3", 10), ("WG", 8)],
x_space=4, y_space=4)
# inset: the last modulator and part of the multiplexer
show_zoom(c, center=(-420, -90), size=300)Appendix A. Thermal tuning of the ring filters¶
The heater cross-section of the generic PDK (strip_heater_metal), solved
with the femwell heat solver in micrometre units. The silicon substrate below
the 3 µm buried oxide acts as a heat sink at constant temperature.
from collections import OrderedDict
import shapely
from femwell.thermal import solve_thermal
from gf_photonics_paper import plot_field
shapes, material = xs_to_polygons("strip_heater_metal",
PDK.layer_stack, xspan=40, zspan=(-3, 3))
sink = shapely.LineString([(-20, -3), (20, -3)])
mesh = from_meshio(mesh_from_OrderedDict(
OrderedDict(sink=sink, **shapes), {},
default_resolution_max=0.4))
basis0 = Basis(mesh, ElementTriP0())
kappa = {"si": 148, "sio2": 1.38, "TiN": 28} # W/(m K)
k = basis0.zeros()
for name, mat in material.items(): # W/(µm K)
k[basis0.get_dofs(elements=name)] = kappa[mat] * 1e-6
p = 1e-5 # heater power per length: 10 mW/mm, in W/µm
q = p / shapes["heater_1"].area # W/µm³
basis, T = solve_thermal(basis0, k,
specific_conductivity={"heater_1": 1.0},
current_densities={"heater_1": np.sqrt(q)},
fixed_boundaries={"sink": 0.0})
plot_field(basis, T, "ΔT (K)", width=16)dT = (basis.probes(np.array([[0.0], [0.11]])) @ T)[0]
P_pi = 1.55 * p / (2 * 1.8e-4 * dT) * 1e3 # mW, dn/dT = 1.8e-4/K
tuning = 1550 * 1.8e-4 * dT / 4.2 / (p * 1e3 * L_ring) # nm/mW
print(f"ΔT(core) = {dT:.2f} K at 10 mW/mm, P_π = {P_pi:.1f} mW, "
f"ring tuning {tuning:.2f} nm/mW ({1.6 / tuning:.1f} mW per 1.6 nm)")