Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
**self.wg_spec
)
)
""" And add the 'fins' if self.fins==True """
if self.fins:
num_fins = self.wgt.wg_width // (2 * self.fin_size[1])
x0, y0 = (
0,
-num_fins * (2 * self.fin_size[1]) / 2.0 + self.fin_size[1] / 2.0,
)
xend = 2 * self.taper_length + self.length
for i in range(int(num_fins)):
y = y0 + i * 2 * self.fin_size[1]
block_list.append(
gdspy.Rectangle(
(x0, y),
(x0 + self.fin_size[0], y + self.fin_size[1]),
**self.fin_spec
)
)
block_list.append(
gdspy.Rectangle(
(xend - self.fin_size[0], y),
(xend, y + self.fin_size[1]),
**self.fin_spec
)
)
for block in block_list:
self.add(block)
p6 = gdspy.Polygon(c6.get_points())
draw(gdspy.Cell("curves_2").add([p4, p5, p6]))
# Transformations
poly = gdspy.Rectangle((-2, -2), (2, 2))
poly.rotate(numpy.pi / 4)
poly.scale(1, 0.5)
draw(gdspy.Cell("transformations").add(poly))
# Layer and Datatype
# Layer/datatype definitions for each step in the fabrication
ld_fulletch = {"layer": 1, "datatype": 3}
ld_partetch = {"layer": 2, "datatype": 3}
ld_liftoff = {"layer": 0, "datatype": 7}
p1 = gdspy.Rectangle((-3, -3), (3, 3), **ld_fulletch)
p2 = gdspy.Rectangle((-5, -3), (-3, 3), **ld_partetch)
p3 = gdspy.Rectangle((5, -3), (3, 3), **ld_partetch)
p4 = gdspy.Round((0, 0), 2.5, number_of_points=6, **ld_liftoff)
draw(gdspy.Cell("layer_and_datatype").add([p1, p2, p3, p4]))
# References
# Create a cell with a component that is used repeatedly
contact = gdspy.Cell("CONTACT")
contact.add([p1, p2, p3, p4])
# Create a cell with the complete device
device = gdspy.Cell("DEVICE")
device.add(cutout)
# Add 2 references to the component changing size and orientation
ref1 = gdspy.CellReference(contact, (3.5, 1), magnification=0.25)
ref2 = gdspy.CellReference(contact, (1, 3.5), magnification=0.25, rotation=90)
l1path = gdspy.L1Path((-1, -11), '+y', 0.5, lengths, turns,
number_of_paths=3, distance=0.7, layer=6)
path_cell.add(l1path)
# ------------------------------------------------------------------ #
# POLYGON OPERATIONS
# ------------------------------------------------------------------ #
# Boolean operations can be executed with either gdspy polygons or
# point lists). The operations are union, intersection, subtraction,
# symmetric subtracion (respectively 'or', 'and', 'not', 'xor').
oper_cell = gdspy.Cell('OPERATIONS')
# Here we subtract the previously created spiral from a rectangle with
# the 'not' operation.
oper_cell.add(gdspy.boolean(gdspy.Rectangle((10, -4), (17, 4)), path3, 'not', layer=1))
# Polygon offset (inset and outset) can be used, for instance, to
# define safety margins around shapes.
spec = {'layer': 7}
path4 = gdspy.Path(0.5, (21, -5)).segment(3, '+x', **spec).turn(4, 'r', **spec).turn(4, 'rr', **spec).segment(3, **spec)
oper_cell.add(path4)
# Merge all parts into a single polygon.
merged = gdspy.boolean(path4, None, 'or', max_points=0)
# Offset the path shape by 0.5 and add it to the cell.
oper_cell.add(gdspy.offset(merged, 1, layer=8))
# ------------------------------------------------------------------ #
# SLICING POLYGONS
layer=self.layer,
datatype=self.datatype,
)
)
# Add little cross arms
self.add(
gdspy.Rectangle(
(x0 - self.cross_width / 2.0, y0 - self.small_cross_width / 2.0),
(x0 + self.cross_width / 2.0, y0 + self.small_cross_width / 2.0),
layer=self.layer,
datatype=self.datatype,
)
)
self.add(
gdspy.Rectangle(
(x0 - self.small_cross_width / 2.0, y0 - self.cross_width / 2.0),
(x0 + self.small_cross_width / 2.0, y0 + self.cross_width / 2.0),
layer=self.layer,
datatype=self.datatype,
)
from picwriter.components import *
top = gdspy.Cell("top")
wgt = WaveguideTemplate(
wg_width=0.45,
clad_width=10.0,
bend_radius=100,
resist="+",
fab="ETCH",
wg_layer=1,
wg_datatype=0,
clad_layer=2,
clad_datatype=0,
)
top.add(gdspy.Rectangle((0, 0), (1000, 1000), layer=100, datatype=0))
wg = Waveguide([(25, 25), (975, 25), (975, 500), (25, 500), (25, 975), (975, 975)], wgt)
tk.add(top, wg)
tk.build_mask(top, wgt, final_layer=3, final_datatype=0)
gdspy.LayoutViewer()
gdspy.write_gds("tutorial1.gds", unit=1.0e-6, precision=1.0e-9)
import gdspy
from picwriter import toolkit as tk
import picwriter.components as pc
top = gdspy.Cell("top")
top.add(gdspy.Rectangle((0, 0), (1000, 1000), layer=100, datatype=0))
wgt = pc.WaveguideTemplate(
wg_width=0.45,
clad_width=10.0,
bend_radius=100,
resist="+",
fab="ETCH",
wg_layer=1,
wg_datatype=0,
clad_layer=2,
clad_datatype=0,
)
wg = pc.Waveguide(
[(25, 25), (975, 25), (975, 500), (25, 500), (25, 975), (975, 975)], wgt
)
def __build_cell(self):
# Sequentially build all the geometric shapes using gdspy path functions
# for waveguide, then add it to the Cell
w, l, c = self.width, self.length, self.mt.clad_width
self.add(gdspy.Rectangle((0, -w / 2.0), (l, w / 2.0), **self.spec))
self.add(
gdspy.Rectangle((-c, -w / 2.0 - c), (l + c, w / 2.0 + c), **self.clad_spec)
)
def add_rect(self,
point1,
point2,
layer,
):
print("in add_rect")
asdf = gdspy.Rectangle(point1, point2, layer)
print(asdf)
self.primitive_shapes.append(asdf)
print(self.primitive_shapes)
block_list.append(
gdspy.Rectangle(
(x0, y - disty),
(x0 + self.fin_size[0], y - disty + self.fin_size[1]),
**self.fin_spec
)
)
block_list.append(
gdspy.Rectangle(
(x0 + distx - self.fin_size[0], y),
(x0 + distx, y + self.fin_size[1]),
**self.fin_spec
)
)
block_list.append(
gdspy.Rectangle(
(x0 + distx - self.fin_size[0], y - disty),
(x0 + distx, y - disty + self.fin_size[1]),
**self.fin_spec
)
)
self.portlist_input_straight = (0, 0)
self.portlist_output_straight = (distx, 0)
self.portlist_output_cross = (distx, -disty)
self.portlist_input_cross = (0, -disty)
if self.w_phc_bot <= 1e-6: # Unconnected bottom SWG waveguides (2 paths)
self.add(wg_bot2)
if self.apodization_top:
self.add(wg_apod)
self.add(wg_top)