Beispiel #1
0
    unit.add(gdstk.cross((0, 0), 1, 0.2))

    main = gdstk.Cell("Main")

    # Create repeating pattern using references
    d = 2
    main.add(gdstk.Reference(unit, columns=11, rows=6,
                             spacing=(d, d * 3**0.5)))
    main.add(
        gdstk.Reference(
            unit,
            (d / 2, d * 3**0.5 / 2),
            columns=10,
            rows=5,
            spacing=(d, d * 3**0.5),
        ))
    main.flatten()

    hole = gdstk.text("PY", 8 * d, (0.5 * d, 0), layer=1)
    test = gdstk.inside([pol.points for pol in main.polygons], hole, "any")
    for pol, inside in zip(main.polygons, test):
        if inside:
            main.remove(pol)

    main.add(*hole)

    gdstk.Library().add(main).write_gds(path / "pos_filtering.gds")

    main.name = "pos_filtering"
    draw(main, path / "how-tos")
Beispiel #2
0
def make_proof_lib():
    outfile = pathlib.Path(__file__).parent / "proof_lib.gds"
    if outfile.exists():
        raise RuntimeError("Test library %s already exists." % outfile)
    lib = gdstk.Library("Test Library", unit=1e-6, precision=1e-12)

    cell = lib.new_cell("Polygon.fillet")
    p1 = gdstk.Polygon([(0, 0), (1.2, 0), (1.2, 0.3), (1, 0.3), (1.5, 1),
                        (0, 1.5)])
    p2 = p1.copy().translate(2, 0)
    cell.add(p1.fillet(0.3, tolerance=1e-3))
    cell.add(p2.fillet([0.3, 0, 0.1, 0, 0.5, 10], tolerance=1e-3))

    for scale_width in [True, False]:
        cell = lib.new_cell(f"FlexPath: scale_width {scale_width}")
        path0 = gdstk.FlexPath(
            (0j, 1j, 0.5 + 1j),
            [0.1, 0.2],
            0.3,
            tolerance=1e-4,
            scale_width=scale_width,
        )
        path0.turn(0.4, -numpy.pi, [0.2, 0.1]).segment((-0.2, 0),
                                                       relative=True)
        path1 = path0.copy().mirror((1.5, 0))
        path1.set_layers(1, 1)
        path2 = path0.copy().mirror((1.5, 0), (1.5, 1))
        path2.set_layers(2, 2)
        path3 = path0.copy().scale(2, (3, 0))
        path3.set_layers(3, 3)
        path4 = path0.copy().scale(-2, (-1, 0))
        path4.set_layers(4, 4)
        path5 = path0.copy().rotate(numpy.pi / 2, (2, 1)).translate(0.2, -0.3)
        path5.set_layers(5, 5)
        cell.add(path0, path1, path2, path3, path4, path5)

    for scale_width in [True, False]:
        cell = lib.new_cell(f"RobustPath: scale_width {scale_width}")
        path0 = gdstk.RobustPath(
            0j,
            [0.1, 0.2],
            0.3,
            tolerance=1e-4,
            scale_width=scale_width,
        )
        path0.vertical(1).horizontal(0.5).turn(0.4, -numpy.pi,
                                               [0.2, 0.1]).segment(
                                                   (-0.2, 0), relative=True)
        path1 = path0.copy().mirror((1.5, 0))
        path1.set_layers(1, 1)
        path2 = path0.copy().mirror((1.5, 0), (1.5, 1))
        path2.set_layers(2, 2)
        path3 = path0.copy().scale(2, (3, 0))
        path3.set_layers(3, 3)
        path4 = path0.copy().scale(-2, (-1, 0))
        path4.set_layers(4, 4)
        path5 = path0.copy().rotate(numpy.pi / 2, (2, 1)).translate(0.2, -0.3)
        path5.set_layers(5, 5)
        cell.add(path0, path1, path2, path3, path4, path5)

    ref_cell1 = gdstk.Cell("Reference 1")
    ref_cell1.add(*gdstk.text("F.", 10, (0, 0)))
    ref_cell1.add(gdstk.Label("LaBeL", (2.4, 8.7), "s"))
    ref_cell1.add(gdstk.FlexPath(8 + 4j, 1, layer=3).arc(2, 0, numpy.pi / 2))
    ref_cell1.add(
        gdstk.RobustPath(7.5 + 7j, 1,
                         layer=4).bezier([-2 + 1j, -2 + 3j, 4j, 6j, -3 + 6j],
                                         relative=True))

    ref_cell2 = gdstk.Cell("Reference 2")
    ref_cell2.add(*gdstk.text("^", 10, (0, 5), layer=1))
    ref_cell2.add(gdstk.Reference(ref_cell1))

    cell = gdstk.Cell("Original cell")
    cell.add(gdstk.rectangle((-1, -0.5), (1, 0.5), layer=2))
    cell.add(gdstk.Reference(ref_cell2))
    cell.add(gdstk.Reference(ref_cell1, (10, 7), numpy.pi / 4, 0.5, True))
    cell.add(
        gdstk.Reference(ref_cell1, (-7, 15), -numpy.pi / 3, 0.5, True, 3, 2,
                        (5, 4)))
    cell.add(
        gdstk.Reference(ref_cell2, (-7, 23), numpy.pi / 3, 0.5, True, 3, 2,
                        (5, 8)))

    lib.add(
        cell.copy("Cell.copy", (-10, -10), numpy.pi / 2, 2, True).flatten())

    lib.write_gds(outfile)
    print("Test library saved as %s" % outfile)
Beispiel #3
0
    points[:, 1] *= -1
    arm2 = gdstk.FlexPath(points,
                          0.5,
                          bend_radius=15,
                          gdsii_path=True,
                          layer=1)
    points = numpy.array([(25, 20), (25, 40), (55, 40), (55, 20)])
    heater1 = gdstk.FlexPath(points,
                             2,
                             bend_radius=15,
                             gdsii_path=True,
                             layer=10)
    points[:, 1] *= -1
    heater2 = gdstk.FlexPath(points,
                             2,
                             bend_radius=15,
                             gdsii_path=True,
                             layer=10)
    #cell.add(arm1, arm2, heater1, heater2)


if __name__ == "__main__":
    lib = gdstk.Library("Photonics")

    alignment_mark(lib)
    directional_coupler(lib)
    mach_zehnder_interferometer(lib)

    path = pathlib.Path(__file__).parent.absolute()
    lib.write_gds(path / "photonics.gds")
Beispiel #4
0
    Return:
        gdstk.Cell
    """
    result = gdstk.Cell(cell_name)
    x = width / 2
    w = period * fill_frac
    result.add(
        gdstk.rectangle((-x, y * period), (x, y * period + w),
                        layer=layer,
                        datatype=datatype)
        for y in range(int(length / period)))
    return result


if __name__ == "__main__":
    lib = gdstk.Library()

    length = 20
    grat1 = grating(3.5, length=length, layer=1, cell_name="Grating 1")
    grat2 = grating(3.0, length=length, layer=1, cell_name="Grating 2")
    lib.add(grat1, grat2)

    main = lib.new_cell("Main")
    main.add(gdstk.rectangle((0, -10), (150, 10)))
    main.add(gdstk.Reference(grat1, (length, 0), rotation=numpy.pi / 2))
    main.add(gdstk.Reference(grat2, (150 - length, 0), rotation=-numpy.pi / 2))

    path = pathlib.Path(__file__).parent.absolute()
    lib.write_gds(path / "pcell.gds")

    main.name = "parametric_cell"