def get_input_labels( io_gratings: List[ComponentReference], ordered_ports: List[Port], component_name: str, layer_label: ListConfig, gc_port_name: str, ) -> List[Label]: elements = [] for i, g in enumerate(io_gratings): label = get_input_label( port=ordered_ports[i], gc=g, gc_index=i, component_name=component_name, layer_label=layer_label, gc_port_name=gc_port_name, ) elements += [label] return elements
def loss_deembedding_ch13_24( io_sep=127.0, R=10.0, grating_coupler_function=grating_coupler_te, input_port_indexes=(0, 1), ): gc = grating_coupler_function() c = pp.Component() dx = io_sep gcs = [ gc.ref(position=(i * dx, 0), port_id="W0", rotation=-90) for i in range(4) ] gc_ports = [g.ports["W0"] for g in gcs] c.add(gcs) c.add( connect_strip(gc_ports[0], gc_ports[2], start_straight=40.0, taper_factory=None)) gsi = gc.size_info p1 = gc_ports[1] p3 = gc_ports[3] a = R + 5.0 # 0.5 b = max(2 * a, io_sep / 2) y_bot_align_route = -gsi.width - 5.0 c.add(connect_loop_back(p1, p3, a, b, R, y_bot_align_route)) for i, index in enumerate(input_port_indexes): label = get_input_label(gc_ports[index], gc, i, component_name=inspect.stack()[0][3]) label.position = gc_ports[index].position c.add(label) return c
def get_input_labels_all( io_gratings, ordered_ports, component_name, layer_label=layer_label, gc_port_name=gc_port_name, ): """ get labels for all component ports """ elements = [] for i, g in enumerate(io_gratings): label = get_input_label( port=ordered_ports[i], gc=g, gc_index=i, component_name=component_name, layer_label=layer_label, gc_port_name=gc_port_name, ) elements += [label] return elements
def get_input_labels_all( io_gratings, ordered_ports, component_name, layer_label=LAYER.LABEL, gc_port_name: str = "W0", ): """Return labels (elements list) for all component ports.""" elements = [] for i, g in enumerate(io_gratings): label = get_input_label( port=ordered_ports[i], gc=g, gc_index=i, component_name=component_name, layer_label=layer_label, gc_port_name=gc_port_name, ) elements += [label] return elements
def loss_deembedding_ch12_34( io_sep=127.0, R=10.0, grating_coupler_function=grating_coupler_te, input_port_indexes=[0, 2], ): gc = grating_coupler_function() c = pp.Component() dx = io_sep gcs = [ gc.ref(position=(i * dx, 0), port_id="W0", rotation=-90) for i in range(4) ] gc_ports = [g.ports["W0"] for g in gcs] c.add(gcs) c.add( connect_strip(gc_ports[0], gc_ports[1], start_straight=40.0, taper_factory=None)) c.add( connect_strip(gc_ports[2], gc_ports[3], start_straight=40.0, taper_factory=None)) for i, index in enumerate(input_port_indexes): label = get_input_label(gc_ports[index], gc, i, component_name=inspect.stack()[0][3]) label.position = gc_ports[index].position c.add(label) return c
def loss_deembedding_ch14_23( io_sep: float = 127.0, R: float = 10.0, grating_coupler_function: Callable = grating_coupler_te, input_port_indexes: Iterable[int] = (0, 1), ) -> Component: gc = grating_coupler_function() c = pp.Component() dx = io_sep gcs = [ gc.ref(position=(i * dx, 0), port_id="W0", rotation=-90) for i in range(4) ] gc_ports = [g.ports["W0"] for g in gcs] c.add(gcs) c.add( connect_strip(gc_ports[0], gc_ports[3], start_straight=40.0, taper_factory=None)["references"]) c.add( connect_strip(gc_ports[1], gc_ports[2], start_straight=30.0, taper_factory=None)["references"]) for i, index in enumerate(input_port_indexes): label = get_input_label(gc_ports[index], gc, i, component_name=inspect.stack()[0][3]) label.position = gc_ports[index].position c.add(label) return c
def add_gratings_and_loop_back( component, grating_coupler=grating_coupler_te, excluded_ports=[], grating_separation=127.0, bend_radius_align_ports=10.0, gc_port_name=None, gc_rotation=-90, waveguide_separation=5.0, bend_factory=bend_circular, waveguide_factory=waveguide, layer_label=pp.LAYER.LABEL, component_name=None, with_loopback=True, ): """ returns a component with grating_couplers and loopback """ gc = pp.call_if_func(grating_coupler) direction = "S" component_name = component_name or component.name name = f"{component.name}_{gc.polarization}" c = pp.Component(name=name) c.add_ref(component) # Find grating port name if not specified if gc_port_name is None: gc_port_name = list(gc.ports.values())[0].name # List the optical ports to connect optical_ports = component.get_ports_list(port_type="optical") optical_ports = [p for p in optical_ports if p.name not in excluded_ports] optical_ports = direction_ports_from_list_ports(optical_ports)[direction] # Check if the ports are equally spaced grating_separation_extracted = check_ports_have_equal_spacing( optical_ports) if grating_separation_extracted != grating_separation: raise ValueError("Grating separation must be {}. Got {}".format( grating_separation, grating_separation_extracted)) # Add grating couplers couplers = [] for port in optical_ports: coupler_ref = c.add_ref(gc) coupler_ref.connect(list(coupler_ref.ports.values())[0].name, port) couplers += [coupler_ref] # add labels for i, optical_port in enumerate(optical_ports): label = get_input_label( optical_port, couplers[i], i, component_name=component_name, layer_label=layer_label, ) c.add(label) if with_loopback: y0 = couplers[0].ports[gc_port_name].y xs = [p.x for p in optical_ports] x0 = min(xs) - grating_separation x1 = max(xs) + grating_separation gca1, gca2 = [ gc.ref(position=(x, y0), rotation=gc_rotation, port_id=gc_port_name) for x in [x0, x1] ] gsi = gc.size_info p0 = gca1.ports[gc_port_name].position p1 = gca2.ports[gc_port_name].position a = bend_radius_align_ports + 0.5 b = max(2 * a, grating_separation / 2) y_bot_align_route = -gsi.width - waveguide_separation route = [ p0, p0 + (0, a), p0 + (b, a), p0 + (b, y_bot_align_route), p1 + (-b, y_bot_align_route), p1 + (-b, a), p1 + (0, a), p1, ] bend90 = bend_factory(radius=bend_radius_align_ports) loop_back = round_corners(route, bend90, waveguide_factory) elements = [gca1, gca2, loop_back] c.add(elements) return c