From f668025abe8e17d369af2bccf5c697f6a729539f Mon Sep 17 00:00:00 2001 From: Lukas Chrostowski Date: Sat, 2 Nov 2024 23:10:19 -0700 Subject: [PATCH 1/2] EBeam-Beta > spiral_paperclip: add vertical port option --- .../pcells_EBeam_Beta/spiral_paperclip.py | 89 ++++++++++++++----- 1 file changed, 68 insertions(+), 21 deletions(-) diff --git a/klayout/EBeam/pymacros/pcells_EBeam_Beta/spiral_paperclip.py b/klayout/EBeam/pymacros/pcells_EBeam_Beta/spiral_paperclip.py index df6bc6c9..853dcb70 100644 --- a/klayout/EBeam/pymacros/pcells_EBeam_Beta/spiral_paperclip.py +++ b/klayout/EBeam/pymacros/pcells_EBeam_Beta/spiral_paperclip.py @@ -19,7 +19,7 @@ import pya from pya import * from SiEPIC.utils import get_technology_by_name - +from pya import DPoint class spiral_paperclip(pya.PCellDeclarationHelper): def __init__(self): @@ -51,6 +51,12 @@ def __init__(self): "Waveguide ports on opposite sides", default=False, ) + self.param( + "port_vertical", + self.TypeBoolean, + "One waveguide port pointing vertically", + default=False, + ) self.param("loops", self.TypeInt, "Number of loops", default=2) self.minlength = 2 * float(self.waveguide_types[0]["radius"]) self.param( @@ -332,7 +338,8 @@ def produce_impl(self): ) ) points.append( - DPoint(-length0 - devrec * i, -radius * 2 + offset - devrec * i - extra) + DPoint(-length0 - devrec * i, + -radius * 2 + offset - devrec * i - extra) ) points.append( DPoint( @@ -340,7 +347,14 @@ def produce_impl(self): -radius * 2 + offset - devrec * i - extra, ) ) - if not self.ports_opposite: + if self.port_vertical: + points.pop(-1) + points.pop(-1) + points.append( + DPoint(-length0 - devrec * i, + 0) + ) + if not self.ports_opposite and not self.port_vertical: points.append( DPoint( length0 + devrec * (i + 1), @@ -381,38 +395,53 @@ def produce_impl(self): LayerPinRecN = self.layout.layer(self.TECHNOLOGY["PinRec"]) LayerDevRecN = self.layout.layer(self.TECHNOLOGY["DevRec"]) self.cell.clear(LayerPinRecN) - bbox = self.cell.bbox() self.cell.clear(LayerDevRecN) self.cell.clear(self.layout.layer(self.TECHNOLOGY["Waveguide"])) - self.cell.shapes(LayerDevRecN).insert(bbox) + devrec_box = self.cell.bbox() + if self.port_vertical: + devrec_box = (pya.Region(devrec_box) - pya.Region(pya.DBox(-length0 - devrec * (i+1), 0, -length0 - devrec * (i-0.5), -radius * 2 + offset - devrec * (i+3) - extra).to_itype(ly.dbu))).merged() + self.cell.shapes(LayerDevRecN).insert(devrec_box) # Create the pins on the input & output waveguides from SiEPIC.utils.layout import make_pin - if self.ports_opposite: + if self.port_vertical: make_pin( self.cell, "optA", [ - length0 + devrec * (i + 1), - -radius * 2 + offset - devrec * i - extra, + -length0 - devrec * (i), + 0, ], self.wg_width, LayerPinRecN, - 0, + 270, ) else: - make_pin( - self.cell, - "optA", - [ - -length0 - devrec * (i + 1), - radius * 2 - offset + devrec * (i + 1) + extra, - ], - self.wg_width, - LayerPinRecN, - 180, - ) + if self.ports_opposite: + make_pin( + self.cell, + "optA", + [ + length0 + devrec * (i + 1), + -radius * 2 + offset - devrec * i - extra, + ], + self.wg_width, + LayerPinRecN, + 0, + ) + else: + make_pin( + self.cell, + "optA", + [ + -length0 - devrec * (i + 1), + radius * 2 - offset + devrec * (i + 1) + extra, + ], + self.wg_width, + LayerPinRecN, + 180, + ) make_pin( self.cell, "optB", @@ -486,13 +515,30 @@ def __init__(self): from SiEPIC.utils import load_Waveguides_by_Tech waveguide_types = load_Waveguides_by_Tech(tech) + + # test vertical waveguide + pcell = ly.create_cell( + "spiral_paperclip", + library, + { + "waveguide_type": waveguide_types[-1]["name"], + "length": 100, + "loops": 1, + "flatten": True, + "port_vertical": True, + }, + ) + t = Trans(Trans.R0, -pcell.bbox().width(), 0) + inst = topcell.insert(CellInstArray(pcell.cell_index(), t)) + + # loop through many permutations xmax = 0 for ports_opposite in [True, False]: for flatten in [True, False]: y = 0 x = xmax for wg in waveguide_types: - print(wg) + # print(wg) pcell = ly.create_cell( "spiral_paperclip", library, @@ -509,6 +555,7 @@ def __init__(self): y += pcell.bbox().height() + 2000 xmax = max(xmax, x + inst.bbox().width()) + zoom_out(topcell) From ed3e24ada99a0d581ca4f6c7a3b139b056b99954 Mon Sep 17 00:00:00 2001 From: Lukas Chrostowski Date: Sat, 2 Nov 2024 23:16:40 -0700 Subject: [PATCH 2/2] Update spiral_paperclip.py --- .../pymacros/pcells_EBeam_Beta/spiral_paperclip.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/klayout/EBeam/pymacros/pcells_EBeam_Beta/spiral_paperclip.py b/klayout/EBeam/pymacros/pcells_EBeam_Beta/spiral_paperclip.py index 853dcb70..8066d47b 100644 --- a/klayout/EBeam/pymacros/pcells_EBeam_Beta/spiral_paperclip.py +++ b/klayout/EBeam/pymacros/pcells_EBeam_Beta/spiral_paperclip.py @@ -352,7 +352,7 @@ def produce_impl(self): points.pop(-1) points.append( DPoint(-length0 - devrec * i, - 0) + radius - offset + devrec * (i - 1) + extra) ) if not self.ports_opposite and not self.port_vertical: points.append( @@ -399,7 +399,11 @@ def produce_impl(self): self.cell.clear(self.layout.layer(self.TECHNOLOGY["Waveguide"])) devrec_box = self.cell.bbox() if self.port_vertical: - devrec_box = (pya.Region(devrec_box) - pya.Region(pya.DBox(-length0 - devrec * (i+1), 0, -length0 - devrec * (i-0.5), -radius * 2 + offset - devrec * (i+3) - extra).to_itype(ly.dbu))).merged() + devrec_box = (pya.Region(devrec_box) - pya.Region(pya.DBox( + -length0 - devrec * (i+1), + radius - offset + devrec * (i - 1) + extra, + -length0 - devrec * (i-0.5), + -radius * 2 + offset - devrec * (i+3) - extra).to_itype(self.layout.dbu))).merged() self.cell.shapes(LayerDevRecN).insert(devrec_box) # Create the pins on the input & output waveguides @@ -411,7 +415,7 @@ def produce_impl(self): "optA", [ -length0 - devrec * (i), - 0, + radius - offset + devrec * (i - 1) + extra, ], self.wg_width, LayerPinRecN,