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

Spiral paperclip, added vertical waveguide output option #314

Merged
merged 2 commits into from
Nov 3, 2024
Merged
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
93 changes: 72 additions & 21 deletions klayout/EBeam/pymacros/pcells_EBeam_Beta/spiral_paperclip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -332,15 +338,23 @@ 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(
length0 + devrec * (i + 1),
-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,
radius - offset + devrec * (i - 1) + extra)
)
if not self.ports_opposite and not self.port_vertical:
points.append(
DPoint(
length0 + devrec * (i + 1),
Expand Down Expand Up @@ -381,38 +395,57 @@ 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),
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
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),
radius - offset + devrec * (i - 1) + extra,
],
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",
Expand Down Expand Up @@ -486,13 +519,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,
Expand All @@ -509,6 +559,7 @@ def __init__(self):
y += pcell.bbox().height() + 2000
xmax = max(xmax, x + inst.bbox().width())


zoom_out(topcell)


Expand Down
Loading