Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
length1=20.0,
length2=50.0,
length3=30.0,
wg_sep=1.0,
input_wg_sep=3.0,
output_wg_sep=3.0,
dw=0.1,
**ac.portlist["output_bot"]
)
tk.add(top, ac2)
for p in ac.portlist.keys():
print(str(p) + ": " + str(ac.portlist[p]["port"]))
gdspy.LayoutViewer()
gdspy.write_gds("ac.gds", unit=1.0e-6, precision=1.0e-9)
trans_cell.add(label1)
trans_cell.add(label2)
# Reflection across a line defined by 2 points allows the mirroring of
# a polygon over an arbitrary axis:
rect4 = gdspy.Rectangle((80, 0), (81, 1), 3)
rect4.mirror((80, 2), (79, 0))
trans_cell.add(rect4)
# ------------------------------------------------------------------ #
# OUTPUT
# ------------------------------------------------------------------ #
# Output the layout to a GDSII file (default to all created cells).
# Set the units we used to micrometers and the precision to nanometers.
gdspy.write_gds('tutorial.gds', unit=1.0e-6, precision=1.0e-9)
# ------------------------------------------------------------------ #
# IMPORT
# ------------------------------------------------------------------ #
# Import the file we just created, and extract the cell 'POLYGONS'. To
# avoid naming conflict, we will rename all cells.
gdsii = gdspy.GdsLibrary()
gdsii.read_gds('tutorial.gds',
rename={'POLYGONS': 'IMPORT_POLY',
'PATHS': 'IMPORT_PATHS',
'OPERATIONS': 'IMPORT_OPER',
'SLICE': 'IMPORT_SLICE',
'REFS': 'IMPORT_REFS',
'TRANS': 'IMPORT_TRANS'},
layers={1: 7, 2: 8, 3: 9})
period=1.0,
dutycycle=0.7,
port=(mmi2.portlist["input"]["port"][0] + 100, mmi2.portlist["input"]["port"][1]),
direction="EAST",
)
tk.add(top, gc2)
wg_gc2 = Waveguide(
[mmi2.portlist["input"]["port"], gc2.portlist["output"]["port"]], wgt
)
tk.add(top, wg_gc2)
tk.build_mask(top, wgt, final_layer=3, final_datatype=0)
gdspy.LayoutViewer()
gdspy.write_gds("tutorial2.gds", unit=1.0e-6, precision=1.0e-9)
design_region = gdspy.Rectangle((-grating_len / 2, -wg_width / 2),
(grating_len / 2, wg_width / 2),
LAYER_SILICON_ETCHED)
# Generate the foreground and background GDS files.
gds_fg = gdspy.Cell("FOREGROUND", exclude_from_current=True)
gds_fg.add(waveguide_top)
gds_fg.add(waveguide_bottom)
gds_fg.add(design_region)
gds_bg = gdspy.Cell("BACKGROUND", exclude_from_current=True)
gds_bg.add(waveguide_top)
gds_bg.add(waveguide_bottom)
gdspy.write_gds(gds_fg_name, [gds_fg], unit=1e-9, precision=1e-9)
gdspy.write_gds(gds_bg_name, [gds_bg], unit=1e-9, precision=1e-9)
if visualize:
gdspy.LayoutViewer(cells=[gds_fg])
gdspy.LayoutViewer(cells=[gds_bg])
# The BOX layer/silicon device interface is set at `z = 0`.
#
# Describe materials in each layer.
# We actually have four material layers:
# 1) Silicon substrate
# 2) Silicon oxide BOX layer
# 3) Bottom part of grating that is not etched
# 4) Top part of grating that can be etched.
#
# The last two layers put together properly describe a partial etch.
#
period=1.0,
dutycycle=0.6,
ridge=True,
teeth_list=teeth_list,
**wg1.portlist["input"]
)
tk.add(top, gc2)
# gc1 = GratingCouplerStraight(wgt, width=20, length=50, taper_length=20, period=1.0, dutycycle=0.7, **wg1.portlist["output"])
# tk.add(top, gc1)
#
# gc2 = GratingCouplerFocusing(wgt, focus_distance=20.0, width=20, length=50, period=1.0, dutycycle=0.7, **wg1.portlist["input"])
# tk.add(top,gc2)
# gdspy.LayoutViewer()
gdspy.write_gds("gratingcoupler.gds", unit=1.0e-6, precision=1.0e-9)
if plan.transformations[-1].parametrization.inverted:
coords = np.insert(coords, 0, 0, axis=0)
coords = np.insert(coords, -1, grating_len, axis=0)
# `coords` now contains the location of the grating edges. Now draw a
# series of rectangles to represent the grating.
grating_poly = []
for i in range(0, len(coords), 2):
grating_poly.append(
((coords[i], -wg_width / 2), (coords[i], wg_width / 2),
(coords[i + 1], wg_width / 2), (coords[i + 1], -wg_width / 2)))
# Save the grating to `grating.gds`.
grating = gdspy.Cell("GRATING", exclude_from_current=True)
grating.add(gdspy.PolygonSet(grating_poly, 100))
gdspy.write_gds(os.path.join(save_folder, "grating.gds"), [grating],
unit=1.0e-9,
precision=1.0e-9)
[poly],
"xor",
precision=0.1 * tolerance,
max_points=0,
).polygons[0]
i -= 1
xmax = max(xmax, poly[:, 0].max())
polys.append(poly)
return polys
if __name__ == "__main__":
fp = FontProperties(family="serif", style="italic")
text = gdspy.PolygonSet(render_text("Text rendering", 10, font_prop=fp), layer=1)
gdspy.Cell("TXT").add(text)
gdspy.write_gds("fonts.gds")
gdspy.LayoutViewer()