Skip to content

Commit

Permalink
fix mask
Browse files Browse the repository at this point in the history
  • Loading branch information
joamatab committed Aug 6, 2023
1 parent c08186c commit f50a54b
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 43 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ build:
docs:
jb build docs

mask:
python ubcpdk/samples/test_masks.py

.PHONY: drc doc docs install
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ classifiers = [
"Operating System :: OS Independent"
]
dependencies = [
"gdsfactory>=7.1.0,<7.2.0",
"gdsfactory>=7.1.1,<7.2.0",
"gplugins[tidy3d,sax,schematic]>=0.0.3,<0.1.0"
]
description = "ubcpdk pdk"
Expand Down
6 changes: 5 additions & 1 deletion ubcpdk/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,13 +769,15 @@ def add_label_electrical(component: Component, text: str, port_name: str = "e2")
def add_fiber_array_pads_rf(
component: ComponentSpec = "ring_single_heater",
username: str = CONFIG.username,
orientation: float = 0,
**kwargs,
) -> Component:
"""Returns fiber array with label and electrical pads.
Args:
component: to add fiber array and pads.
username: for the label.
orientation: for adding pads.
kwargs: for add_fiber_array.
"""
c0 = gf.get_component(component)
Expand All @@ -784,7 +786,9 @@ def add_fiber_array_pads_rf(
rename_ports_and_add_label = gf.compose(
add_label, gf.port.auto_rename_ports_electrical
)
c1 = add_pads_rf(component=c0, decorator=rename_ports_and_add_label)
c1 = add_pads_rf(
component=c0, decorator=rename_ports_and_add_label, orientation=orientation
)
return add_fiber_array(component=c1, **kwargs)


Expand Down
2 changes: 1 addition & 1 deletion ubcpdk/samples/test_masks.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_masks_2023_v1():
m13.test_mask4,
m13.test_mask5,
]:
m, tm = mask()
mask()

for gdspath in dirpath.glob("*.gds"):
shutil.copyfile(gdspath, dirpath_gds / f"{gdspath.name}")
Expand Down
10 changes: 6 additions & 4 deletions ubcpdk/samples/ubc_helge.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from pathlib import Path

import gdsfactory as gf

import ubcpdk
Expand All @@ -9,7 +11,7 @@
nm = 1e-3


def test_mask1():
def test_mask1() -> Path:
"""DBR filters."""

@gf.cell
Expand Down Expand Up @@ -53,7 +55,7 @@ def dbr_filter(n):
return write_mask_gds_with_metadata(m)


def test_mask2():
def test_mask2() -> Path:
"""Ring with different couplings."""
e = [
add_gc(ubcpdk.components.straight(), component_name=f"straight_{i}")
Expand All @@ -80,5 +82,5 @@ def test_mask2():


if __name__ == "__main__":
m, _ = test_mask2()
m.show()
m = test_mask1()
gf.show(m)
36 changes: 19 additions & 17 deletions ubcpdk/samples/ubc_joaquin_matres1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Sample mask for the edx course Q1 2023."""

from pathlib import Path

import gdsfactory as gf

import ubcpdk
Expand All @@ -10,7 +12,7 @@
from ubcpdk.tech import LAYER


def test_mask1():
def test_mask1() -> Path:
"""Add DBR cavities."""
e = [add_gc(ubcpdk.components.straight())]
e += [add_gc(gf.components.mzi(delta_length=dl)) for dl in [9.32, 93.19]]
Expand Down Expand Up @@ -39,7 +41,7 @@ def test_mask1():
return write_mask_gds_with_metadata(m)


def test_mask2():
def test_mask2() -> Path:
"""spirals for extracting straight waveguide loss"""
N = 12
radius = 10
Expand Down Expand Up @@ -75,7 +77,7 @@ def test_mask2():
return write_mask_gds_with_metadata(m)


def test_mask3():
def test_mask3() -> Path:
"""contains mirror cavities and structures inside a resonator"""
e = []
e += [add_gc(ubcpdk.components.ebeam_crossing4())]
Expand All @@ -94,15 +96,16 @@ def test_mask3():
return write_mask_gds_with_metadata(m)


def test_mask4():
def test_mask4() -> Path:
"""MZI interferometers."""
mzi = gf.partial(gf.components.mzi, splitter=ubcpdk.components.ebeam_y_1550)
mzis = [mzi(delta_length=delta_length) for delta_length in [10, 40, 100]]
mzis_gc = [pdk.add_fiber_array(mzi) for mzi in mzis]

mzis = [pdk.mzi_heater(delta_length=delta_length) for delta_length in [40]]
mzis_heater_gc = [
pdk.add_fiber_array_pads_rf(mzi, optical_routing_type=2) for mzi in mzis
pdk.add_fiber_array_pads_rf(mzi, orientation=90, optical_routing_type=2)
for mzi in mzis
]

c = pack(mzis_gc + mzis_heater_gc)
Expand All @@ -112,7 +115,7 @@ def test_mask4():
return write_mask_gds_with_metadata(m)


def test_mask5():
def test_mask5() -> Path:
"""Ring resonators."""
rings = [pdk.ring_single_heater(length_x=length_x) for length_x in [4, 6]]
rings = [gf.functions.rotate180(ring) for ring in rings]
Expand All @@ -125,7 +128,7 @@ def test_mask5():
return write_mask_gds_with_metadata(m)


def test_mask6():
def test_mask6() -> Path:
"""Splitters 1x2."""
mmis = []
mmis += [
Expand All @@ -143,7 +146,7 @@ def test_mask6():
return write_mask_gds_with_metadata(m)


def test_mask7():
def test_mask7() -> Path:
"""Splitters 2x2."""
# mmi2x2_with_sbend = partial(
# gf.components.mmi2x2_with_sbend,
Expand Down Expand Up @@ -174,15 +177,14 @@ def test_mask7():


if __name__ == "__main__":
# gf.clear_cache()
# m, tm = test_mask1() # dbr and mzi
# m, tm = test_mask2() # spirals
# m, tm = test_mask3() # coupler and crossing
m, tm = test_mask4() # heated mzis
# m, tm = test_mask5() # heated rings
# m, tm = test_mask6() # 1x2 mmis
# m, tm = test_mask7() # 2x2mmis
m.show()
# m = test_mask1() # dbr and mzi
# m = test_mask2() # spirals
# m = test_mask3() # coupler and crossing
# m = test_mask4() # heated mzis
# m = test_mask5() # heated rings
# m = test_mask6() # 1x2 mmis
m = test_mask7() # 2x2mmis
gf.show(m)
# c = partial(
# gf.components.mmi2x2_with_sbend,
# decorator=tech.add_pins_bbox_siepic_remove_layers,
Expand Down
33 changes: 17 additions & 16 deletions ubcpdk/samples/ubc_simon.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Sample mask for the edx course Q1 2023."""

from pathlib import Path

import gdsfactory as gf
from gdsfactory.components.bend_euler import bend_euler
Expand Down Expand Up @@ -133,7 +134,7 @@ def rings_proximity(
num_rings=5,
sep_resonators=2,
radius=10.0,
):
) -> gf.Component:
"""A sequence of multiple rings, with the first one having a heater."""
c = gf.Component()
gap = 0.2 # TODO: make variable
Expand Down Expand Up @@ -164,7 +165,7 @@ def disks_proximity(
num_rings=5,
sep_resonators=5,
radius=10.0,
):
) -> gf.Component:
c = gf.Component()
gap = 0.2
width = 0.5
Expand Down Expand Up @@ -194,7 +195,7 @@ def disks_proximity(
def bend_gc_array(
gc_spec: ComponentSpec = pdk.gc_te1550(),
bend_spec: ComponentSpec = gf.components.bend_euler(),
):
) -> gf.Component:
"""Two gc's with opposite bends.
Not completely needed, was originally intended to make routing easier.
Expand All @@ -221,7 +222,7 @@ def resonator_proximity_io(
grating_buffer=50.0,
waveguide_buffer=2.5,
gc_bus_buffer=10,
):
) -> gf.Component:
"""Resonator proximity experiment with fiber array.
Arguments:
Expand Down Expand Up @@ -287,7 +288,7 @@ def resonator_proximity_io(
return c


def needs_fixing():
def needs_fixing() -> Path:
"""Ring resonators with thermal cross-talk.
Old cell; does not pass verification
Expand Down Expand Up @@ -327,7 +328,7 @@ def needs_fixing():
return write_mask_gds_with_metadata(c)


def test_mask1():
def test_mask1() -> Path:
"""Ring resonators with thermal cross-talk.
Old cell; does not pass verification
Expand Down Expand Up @@ -371,7 +372,7 @@ def crosstalk_experiment_parametrized_mask(
fill_margin=2,
fill_size=(0.5, 0.5),
padding=20,
):
) -> gf.Component:
"""Ring resonators with thermal cross-talk.
name: for labels
Expand Down Expand Up @@ -539,7 +540,7 @@ def crosstalk_experiment_parametrized_mask(
return m


def test_mask3():
def test_mask3() -> Path:
"""Rings with thermal crosstalk, close rings"""
m = crosstalk_experiment_parametrized_mask(
name="EBeam_JoaquinMatres_Simon_1",
Expand All @@ -550,7 +551,7 @@ def test_mask3():
return write_mask_gds_with_metadata(m)


def test_mask4():
def test_mask4() -> Path:
"""Rings with thermal crosstalk, far rings"""
m = crosstalk_experiment_parametrized_mask(
name="EBeam_JoaquinMatres_Simon_2",
Expand All @@ -561,7 +562,7 @@ def test_mask4():
return write_mask_gds_with_metadata(m)


def test_mask5():
def test_mask5() -> Path:
"""Rings with thermal crosstalk, metal fill"""
m = crosstalk_experiment_parametrized_mask(
name="EBeam_JoaquinMatres_Simon_3",
Expand All @@ -573,7 +574,7 @@ def test_mask5():
return write_mask_gds_with_metadata(m)


def test_mask6():
def test_mask6() -> Path:
"""Rings with thermal crosstalk, silicon fill"""
m = crosstalk_experiment_parametrized_mask(
name="EBeam_JoaquinMatres_Simon_4",
Expand All @@ -588,8 +589,8 @@ def test_mask6():


if __name__ == "__main__":
# m, _ = test_mask1()
# m, _ = test_mask3()
# m, _ = test_mask4()
m, _ = test_mask5()
m.show()
# m = test_mask1()
# m = test_mask3()
# m = test_mask4()
m = test_mask5()
gf.show(m)
6 changes: 3 additions & 3 deletions ubcpdk/samples/write_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
)


def write_mask_gds_with_metadata(m) -> tuple[Path, Path]:
def write_mask_gds_with_metadata(m) -> Path:
"""Returns"""
gdspath = PATH.mask / f"{m.name}.gds"
m.write_gds_with_metadata(gdspath=gdspath)
metadata_path = gdspath.with_suffix(".yml")
tm = OmegaConf.load(metadata_path)
OmegaConf.load(metadata_path)
gf.labels.write_labels.write_labels_gdstk(
gdspath=gdspath, layer_label=LAYER.LABEL, debug=True
)
Expand All @@ -31,4 +31,4 @@ def write_mask_gds_with_metadata(m) -> tuple[Path, Path]:
# labels_path=labels_path, mask_metadata=mask_metadata
# )
# test_metadata_path.write_text(OmegaConf.to_yaml(tm))
return m, tm
return gdspath

0 comments on commit f50a54b

Please sign in to comment.