Skip to content

Commit

Permalink
expose gc port name fiber
Browse files Browse the repository at this point in the history
  • Loading branch information
joamatab committed Apr 30, 2024
1 parent c74fe15 commit c4a23f3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
5 changes: 3 additions & 2 deletions gdsfactory/components/straight_heater_metal.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,9 @@ def test_ports() -> None:

# c = straight_heater_metal_undercut(length=200, straight="straight")
# n = c.get_netlist()
# c = straight_heater_metal(length=20)
c = straight_heater_metal_simple(length=20)
c = straight_heater_metal(length=20)
print(c.get_netlist(allow_multiple=True))
# c = straight_heater_metal_simple(length=20)
c.show(show_ports=False)
# scene = c.to_3d()
# scene.show()
2 changes: 2 additions & 0 deletions gdsfactory/routing/add_fiber_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def add_fiber_array(
component: ComponentSpec = straight_function,
grating_coupler: ComponentSpecOrList = grating_coupler_te,
gc_port_name: str = "o1",
gc_port_name_fiber: str = "o2",
gc_port_labels: tuple[str, ...] | None = None,
io_rotation: int | None = None,
component_name: str | None = None,
Expand Down Expand Up @@ -171,6 +172,7 @@ def add_fiber_array(
component=component,
grating_coupler=grating_coupler,
gc_port_name=gc_port_name,
gc_port_name_fiber=gc_port_name_fiber,
component_name=component_name,
cross_section=cross_section,
select_ports=select_ports,
Expand Down
9 changes: 8 additions & 1 deletion gdsfactory/routing/route_fiber_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def route_fiber_array(
grating_indices: list[int] | None = None,
route_filter: Callable = get_route_from_waypoints,
gc_port_name: str = "o1",
gc_port_name_fiber: str = "o2",
gc_rotation: int = -90,
layer_label: LayerSpec | None = None,
layer_label_loopback: LayerSpec | None = None,
Expand Down Expand Up @@ -305,6 +306,12 @@ def has_p(side) -> bool:
gr_coupler_y_sep = snap_to_grid(gr_coupler_y_sep)
io_gratings_lines = [] # [[gr11, gr12, gr13...], [gr21, gr22, gr23...] ...]

fiber_port_name = (
gc_port_name_fiber
if gc_port_name_fiber in grating_coupler.ports
else gc_port_name
)

if grating_indices is None:
grating_indices = list(range(nb_ports_per_line))
else:
Expand All @@ -324,7 +331,7 @@ def has_p(side) -> bool:
]

io_gratings_lines += [io_gratings[:]]
ports += [grating.ports[gc_port_name] for grating in io_gratings]
ports += [grating.ports[fiber_port_name] for grating in io_gratings]

if optical_routing_type == 0:
"""Basic optical routing, typically fine for small components No
Expand Down
7 changes: 4 additions & 3 deletions tests/test_label_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ def test_label_fiber_array_custom(
component_name=CUSTOM_LABEL,
cross_section=cross_section,
layer_label=None,
decorator=gf.add_labels.add_labels_to_ports,
)
cte._locked = False
cte = gf.add_labels.add_labels_to_ports(cte)
assert len(cte.labels) == 2, len(cte.labels)
l0 = cte.labels[0].text
l1 = cte.labels[1].text
assert l0 == "o1", l0
assert l1 == "o2", l1
assert l0 == "o2", l0
assert l1 == "o1", l1

0 comments on commit c4a23f3

Please sign in to comment.