Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

158 #39

Merged
merged 3 commits into from
May 9, 2022
Merged

158 #39

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ubcpdk/tests/test_components.gds/gds_diff/
*.sqlite3
*.png
*.db
*.pkl
.idea/
poetry.lock
Pipfile
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ update:
pre-commit autoupdate --bleeding-edge

watch:
gf yaml watch
gf yaml watch ubcpdk

link:
lygadgets_link lygadgets
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
-e .==null
lygadgets==0.1.31
gdsfactory[full]==5.5.1
gdsfactory[full]==5.6.1
modes==1.0.6
178 changes: 4 additions & 174 deletions ubcpdk/components/add_fiber_array.py
Original file line number Diff line number Diff line change
@@ -1,183 +1,13 @@
from typing import Callable, List, Optional, Tuple

from phidl import device_layout as pd
from phidl.device_layout import Label
import gdsfactory as gf
from gdsfactory.add_labels import get_input_label
from gdsfactory.cell import cell
from gdsfactory.component import Component
from gdsfactory.port import Port
from gdsfactory.types import ComponentReference, ComponentSpec, CrossSectionSpec

from ubcpdk.config import CONFIG
from ubcpdk.tech import LAYER

from gdsfactory.dft.siepic import add_fiber_array_siepic
from ubcpdk.components.grating_couplers import gc_te1550
from ubcpdk.components.cells import bend_euler, straight


def get_input_label_text(
port: Port,
gc: ComponentReference,
gc_index: Optional[int] = None,
component_name: Optional[str] = None,
) -> str:
"""Return label for port and a grating coupler.

Args:
port: component port.
gc: grating coupler reference.
gc_index: grating coupler index
component_name: optional component name.
"""
polarization = gc.info.get("polarization")
wavelength = gc.info.get("wavelength")

assert polarization.upper() in [
"TE",
"TM",
], f"Not valid polarization {polarization.upper()} in [TE, TM]"
assert (
isinstance(wavelength, (int, float)) and 1.0 < wavelength < 2.0
), f"{wavelength} is Not valid 1000 < wavelength < 2000"

name = component_name or port.parent.metadata_child.get("name")
# name = component_name
# elif type(port.parent) == Component:
# name = port.parent.name
# else:
# name = port.parent.ref_cell.name
# name = name.replace("_", "-")

label = (
f"opt_in_{polarization.upper()}_{int(wavelength*1e3)}_device_"
f"{CONFIG.username}_({name})-{gc_index}-{port.name}"
)
return label


def get_input_labels_all(
io_gratings,
ordered_ports,
component_name,
layer_label=LAYER.LABEL,
gc_port_name: str = "o1",
) -> List[Label]:
"""Return list of labels 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(
io_gratings: List[ComponentReference],
ordered_ports: List[Port],
component_name: str,
layer_label: Tuple[int, int] = LAYER.LABEL,
gc_port_name: str = "o1",
port_index: int = 1,
get_input_label_text_function: Callable = get_input_label_text,
) -> List[Label]:
"""Return list of labels for all component ports."""
if port_index == -1:
return get_input_labels_all(
io_gratings=io_gratings,
ordered_ports=ordered_ports,
component_name=component_name,
layer_label=layer_label,
gc_port_name=gc_port_name,
)
gc = io_gratings[port_index]
port = ordered_ports[1]

text = get_input_label_text(
port=port, gc=gc, gc_index=port_index, component_name=component_name
)
layer, texttype = pd._parse_layer(layer_label)
label = pd.Label(
text=text,
position=gc.ports[gc_port_name].midpoint,
anchor="o",
layer=layer,
texttype=texttype,
)
return [label]


@cell
def add_fiber_array(
component: ComponentSpec = straight,
component_name: Optional[str] = None,
gc_port_name: str = "opt1",
get_input_labels_function: Callable = get_input_labels,
with_loopback: bool = False,
optical_routing_type: int = 0,
fanout_length: float = 0.0,
grating_coupler: ComponentSpec = gc_te1550,
cross_section: CrossSectionSpec = "strip",
**kwargs,
) -> Component:
"""Returns component with grating couplers and labels on each port.

Routes all component ports south.
Can add align_ports loopback reference structure on the edges.

Args:
component: to connect
component_name: for the label
gc_port_name: grating coupler input port name 'o1'
get_input_labels_function: function to get input labels for grating couplers
with_loopback: True, adds loopback structures
optical_routing_type: None: autoselection, 0: no extension
fanout_length: None # if None, automatic calculation of fanout length
taper_length: length of the taper
grating_coupler: grating coupler instance, function or list of functions
optical_io_spacing: SPACING_GC
"""
c = gf.Component()

component = gf.routing.add_fiber_array(
component=component,
component_name=component_name,
grating_coupler=grating_coupler,
gc_port_name=gc_port_name,
get_input_labels_function=get_input_labels_function,
with_loopback=with_loopback,
optical_routing_type=optical_routing_type,
layer_label=LAYER.LABEL,
fanout_length=fanout_length,
cross_section=cross_section,
bend=bend_euler,
**kwargs,
)
ref = c << component
ref.rotate(-90)
c.add_ports(ref.ports)
c.copy_child_info(component)
return c
add_fiber_array = gf.partial(
add_fiber_array_siepic, gc_port_name="opt1", grating_coupler=gc_te1550
)


if __name__ == "__main__":
# import ubcpdk.components as pdk
# c = gc_te1550()

# c = straight_no_pins()
# c = add_fiber_array(component=c)
# c = gc_tm1550()
# print(c.get_ports_array())
# print(c.ports.keys())
# c = pdk.straight()
# c = pdk.mzi()
# c = add_fiber_array(component=c)
c = add_fiber_array()
c.show()
14 changes: 10 additions & 4 deletions ubcpdk/components/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ def y_splitter() -> Component:
add_siepic_labels, label_layer=LAYER.DEVREC, library="Design Kits/ebeam"
)

straight = gf.partial(gf.components.straight, cross_section="strip", decorator=add_siepic_labels)
bend_euler = gf.partial(gf.components.bend_euler, cross_section="strip", decorator=add_siepic_labels)
bend_s = gf.partial(gf.components.bend_s, cross_section="strip", decorator=add_siepic_labels)
straight = gf.partial(
gf.components.straight, cross_section="strip", decorator=add_siepic_labels
)
bend_euler = gf.partial(
gf.components.bend_euler, cross_section="strip", decorator=add_siepic_labels
)
bend_s = gf.partial(
gf.components.bend_s, cross_section="strip", decorator=add_siepic_labels
)


dc_broadband_te = gf.partial(
Expand Down Expand Up @@ -189,5 +195,5 @@ def ebeam_dc_halfring_straight(
c = ring_with_crossing()

c = mzi()
#c = ebeam_dc_te1550()
# c = ebeam_dc_te1550()
c.show()
2 changes: 1 addition & 1 deletion ubcpdk/klayout/tech/drc/ELEC463 Doping.lydrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Chip1 process:
- partial etch on layer Si
- oxide
- metal heater

Process Layers
- Si 1/0
- Si N++: 24/0
Expand Down
2 changes: 1 addition & 1 deletion ubcpdk/klayout/tech/drc/ELEC463 Metal Heater.lydrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Chip1 process:
- partial etch on layer Si
- oxide
- metal heater

Process Layers
- Si 1/0
- M Heater: 47/0
Expand Down
Loading