From f50a54bb42c35f182f3985fcf680a7f6c92cac29 Mon Sep 17 00:00:00 2001 From: Joaquin Matres <4514346+joamatab@users.noreply.github.com> Date: Sun, 6 Aug 2023 16:13:23 -0700 Subject: [PATCH] fix mask --- Makefile | 3 +++ pyproject.toml | 2 +- ubcpdk/components.py | 6 ++++- ubcpdk/samples/test_masks.py | 2 +- ubcpdk/samples/ubc_helge.py | 10 +++++--- ubcpdk/samples/ubc_joaquin_matres1.py | 36 ++++++++++++++------------- ubcpdk/samples/ubc_simon.py | 33 ++++++++++++------------ ubcpdk/samples/write_mask.py | 6 ++--- 8 files changed, 55 insertions(+), 43 deletions(-) diff --git a/Makefile b/Makefile index 5cffcd72..1537c384 100644 --- a/Makefile +++ b/Makefile @@ -35,4 +35,7 @@ build: docs: jb build docs +mask: + python ubcpdk/samples/test_masks.py + .PHONY: drc doc docs install diff --git a/pyproject.toml b/pyproject.toml index 65d05222..07737b7b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/ubcpdk/components.py b/ubcpdk/components.py index 9e1f8114..acf7cdbc 100644 --- a/ubcpdk/components.py +++ b/ubcpdk/components.py @@ -769,6 +769,7 @@ 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. @@ -776,6 +777,7 @@ def add_fiber_array_pads_rf( 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) @@ -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) diff --git a/ubcpdk/samples/test_masks.py b/ubcpdk/samples/test_masks.py index 28c77d78..1b7d4310 100644 --- a/ubcpdk/samples/test_masks.py +++ b/ubcpdk/samples/test_masks.py @@ -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}") diff --git a/ubcpdk/samples/ubc_helge.py b/ubcpdk/samples/ubc_helge.py index 7b714968..13b1fb8f 100644 --- a/ubcpdk/samples/ubc_helge.py +++ b/ubcpdk/samples/ubc_helge.py @@ -1,3 +1,5 @@ +from pathlib import Path + import gdsfactory as gf import ubcpdk @@ -9,7 +11,7 @@ nm = 1e-3 -def test_mask1(): +def test_mask1() -> Path: """DBR filters.""" @gf.cell @@ -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}") @@ -80,5 +82,5 @@ def test_mask2(): if __name__ == "__main__": - m, _ = test_mask2() - m.show() + m = test_mask1() + gf.show(m) diff --git a/ubcpdk/samples/ubc_joaquin_matres1.py b/ubcpdk/samples/ubc_joaquin_matres1.py index 0007b09b..d155d9a4 100644 --- a/ubcpdk/samples/ubc_joaquin_matres1.py +++ b/ubcpdk/samples/ubc_joaquin_matres1.py @@ -1,5 +1,7 @@ """Sample mask for the edx course Q1 2023.""" +from pathlib import Path + import gdsfactory as gf import ubcpdk @@ -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]] @@ -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 @@ -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())] @@ -94,7 +96,7 @@ 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]] @@ -102,7 +104,8 @@ def test_mask4(): 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) @@ -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] @@ -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 += [ @@ -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, @@ -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, diff --git a/ubcpdk/samples/ubc_simon.py b/ubcpdk/samples/ubc_simon.py index 91f34d64..5b8a0c1e 100644 --- a/ubcpdk/samples/ubc_simon.py +++ b/ubcpdk/samples/ubc_simon.py @@ -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 @@ -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 @@ -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 @@ -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. @@ -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: @@ -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 @@ -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 @@ -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 @@ -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", @@ -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", @@ -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", @@ -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", @@ -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) diff --git a/ubcpdk/samples/write_mask.py b/ubcpdk/samples/write_mask.py index 8582479a..b21d8160 100644 --- a/ubcpdk/samples/write_mask.py +++ b/ubcpdk/samples/write_mask.py @@ -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 ) @@ -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