Route Bundle (GDSFactory)
Imports
import gdsfactory as gf
from gdsfactory.gpdk import PDK
import doroutes as dr
PDK.activate()
import numpy as np
Visualize Routes
c = gf.Component()
ref = c << dr.pcells.routing_frame()
c.add_ports(ref)
spacing = 1.0 # µm
radius = 5.0 # µm
starts = np.array(
sorted(
[p.center for p in c.ports if str(p.name).startswith("in")], key=lambda p: p[1]
)
)
stops = np.array(
sorted(
[p.center for p in c.ports if str(p.name).startswith("out")], key=lambda p: p[1]
)
)
kwargs = {
"component": c,
"straight": "straight",
"bend": {"component": "bend_euler", "settings": {"radius": 5}},
}
num_links = len(starts)
above = ((starts[:, 1] - stops[:, 1]) > 0).sum()
below = num_links - above
for i, (start, stop) in enumerate(zip(starts, stops, strict=False)):
dr.add_route_manual(
start=start,
stop=stop,
steps=[
{"dx": radius + max((below - i - 1), (i - below)) * spacing},
{"y": dr.util.to_um(c.kcl, stop[1])},
],
**kwargs,
)
c.show()
dr.util.show_cell(c)
c = gf.Component()
ref = c << dr.pcells.routing_frame()
c.add_ports(ref)
starts = sorted(
[p for p in c.ports if str(p.name).startswith("in")], key=lambda p: p.center
)
stops = sorted(
[p for p in c.ports if str(p.name).startswith("out")], key=lambda p: p.center
)
xs = gf.get_cross_section("strip").copy()
xs.__dict__["radius"] = 5
gf.routing.route_bundle(
c,
starts,
stops,
cross_section=xs,
straight="straight",
bend={"component": "bend_euler", "settings": {"radius": 5}},
)
dr.util.show_cell(c)