How to use the gdspy.FlexPath function in gdspy

To help you get started, we’ve selected a few gdspy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heitzmann / gdspy / tests / flexpath.py View on Github external
def test_flexpath1(target):
    cell = gdspy.Cell("test", True)
    fp = gdspy.FlexPath([(0, 0), (1, 1)], 0.1, layer=[1], gdsii_path=True)
    cell.add(fp)
    fp = gdspy.FlexPath(
        [(1, 0), (2, 1)],
        0.1,
        [-0.1, 0.1],
        tolerance=1e-5,
        ends=["round", "extended"],
        layer=[2, 3],
        max_points=6,
    )
    cell.add(fp)
    fp = gdspy.FlexPath(
        [(2, 0), (3, 1)], [0.1, 0.2], 0.2, ends=(0.2, 0.1), layer=4, datatype=[1, 1]
    )
    cell.add(fp)
    fp = gdspy.FlexPath(
        [(3, 0), (4, 1)],
        [0.1, 0.2, 0.1],
github heitzmann / gdspy / tests / flexpath.py View on Github external
fp = gdspy.FlexPath([(-5, 6)], 0.8, layer=21, ends="extended", tolerance=1e-4)
    fp.segment((1, 1), 0.1, relative=True)
    cell.add(fp)
    fp = gdspy.FlexPath([(-5, 6)], 0.8, layer=22, ends=(0.1, 0.2), tolerance=1e-4)
    fp.segment((1, 1), 0.1, relative=True)
    cell.add(fp)
    fp = gdspy.FlexPath([(-5, 6)], 0.8, layer=23, ends="smooth", tolerance=1e-4)
    fp.segment((1, 1), 0.1, relative=True)
    cell.add(fp)
    fp = gdspy.FlexPath(
        [(-3, 6)], 0.8, layer=10, corners="round", ends="round", tolerance=1e-5
    )
    fp.segment((1, 0), 0.1, relative=True)
    fp.segment((0, 1), 0.8, relative=True)
    cell.add(fp)
    fp = gdspy.FlexPath(
        [(-3, 6)], 0.8, layer=11, corners="smooth", ends="extended", tolerance=1e-5
    )
    fp.segment((1, 0), 0.1, relative=True)
    fp.segment((0, 1), 0.8, relative=True)
    cell.add(fp)
    fp = gdspy.FlexPath(
        [(-3, 6)], 0.8, layer=12, corners="smooth", ends="smooth", tolerance=1e-5
    )
    fp.segment((1, 0), 0.1, relative=True)
    fp.segment((0, 1), 0.8, relative=True)
    cell.add(fp)
    fp = gdspy.FlexPath(
        [(-3, 8)], 0.1, layer=13, corners="round", ends="round", tolerance=1e-5
    )
    fp.segment((1, 0), 0.8, relative=True)
    fp.segment((0, 1), 0.1, relative=True)
github heitzmann / gdspy / tests / flexpath.py View on Github external
fp.segment((1, 0), 0.8, relative=True)
    fp.segment((0, 1), 0.1, relative=True)
    cell.add(fp)
    fp = gdspy.FlexPath(
        [(-3, 8)], 0.1, layer=14, corners="smooth", ends=(0.2, 0.2), tolerance=1e-5
    )
    fp.segment((1, 0), 0.8, relative=True)
    fp.segment((0, 1), 0.1, relative=True)
    cell.add(fp)
    fp = gdspy.FlexPath(
        [(-3, 8)], 0.1, layer=15, corners="round", ends="smooth", tolerance=1e-5
    )
    fp.segment((1, 0), 0.8, relative=True)
    fp.segment((0, 1), 0.1, relative=True)
    cell.add(fp)
    fp = gdspy.FlexPath([(5, 2)], [0.05, 0.1, 0.2], [-0.2, 0, 0.4], layer=[4, 5, 6])
    fp.parametric(lambda u: numpy.array((5.5 + 3 * u, 2 + 3 * u ** 2)), relative=False)
    fp.segment((0, 1), relative=True)
    fp.parametric(
        lambda u: numpy.array(
            (2 * numpy.cos(0.5 * numpy.pi * u) - 2, 3 * numpy.sin(0.5 * numpy.pi * u))
        ),
        [0.2, 0.1, 0.05],
        [-0.3, 0, 0.3],
    )
    fp.parametric(lambda u: numpy.array((-2 * u, 0)), 0.1, 0.2)
    fp.bezier([(-3, 0), (-2, -3), (0, -4), (0, -5)], offset=[-0.2, 0, 0.2])
    fp.bezier(
        [(5, 0), (1, -1), (1, 5), (3, 2), (5, 2)],
        [0.05, 0.1, 0.2],
        [-0.2, 0, 0.4],
        relative=False,
github heitzmann / gdspy / tests / flexpath.py View on Github external
def test_flexpath_togds(tmpdir):
    cell = gdspy.Cell("flexpath")
    fp = gdspy.FlexPath([(0, 0), (0.5, 0.5), (1, 1)], 0.1, layer=[1], gdsii_path=True)
    cell.add(fp)
    fp = gdspy.FlexPath([(3, 0), (3.5, 0.5), (4, 1)], 0.1, layer=[21])
    cell.add(fp)
    fp = gdspy.FlexPath(
        [(1, 0), (2, 1)],
        0.1,
        [-0.1, 0.1],
        max_points=6,
        ends=["round", "extended"],
        layer=[2, 3],
        gdsii_path=True,
    )
    cell.add(fp)
    fp = gdspy.FlexPath(
        [(2, 0), (3, 1)],
        [0.1, 0.2],
github heitzmann / gdspy / tools / maketestgds.py View on Github external
(2, -2),
        (0, -1),
        (1, -2),
        (1, -3),
    ]
)
fp = gdspy.FlexPath(
    pts + numpy.array((0, 5)),
    [0.1, 0.1, 0.1],
    0.15,
    layer=[1, 2, 3],
    corners=["natural", "miter", "bevel"],
    ends=(0.5, 0),
)
cell.add(fp)
fp = gdspy.FlexPath(
    pts + numpy.array((5, 0)),
    [0.1, 0.1, 0.1],
    0.15,
    layer=[4, 5, 6],
    corners=["round", "smooth", broken],
    ends=[pointy, "smooth", (0, 0.5)],
)
cell.add(fp)

cell = lib.new_cell("FlexPath4")

fp = gdspy.FlexPath(
    [(0, 0)],
    [0.1, 0.2, 0.1],
    0.15,
    layer=[1, 2, 3],
github heitzmann / gdspy / tests / flexpath.py View on Github external
def test_flexpath_togds(tmpdir):
    cell = gdspy.Cell("flexpath")
    fp = gdspy.FlexPath([(0, 0), (0.5, 0.5), (1, 1)], 0.1, layer=[1], gdsii_path=True)
    cell.add(fp)
    fp = gdspy.FlexPath([(3, 0), (3.5, 0.5), (4, 1)], 0.1, layer=[21])
    cell.add(fp)
    fp = gdspy.FlexPath(
        [(1, 0), (2, 1)],
        0.1,
        [-0.1, 0.1],
        max_points=6,
        ends=["round", "extended"],
        layer=[2, 3],
        gdsii_path=True,
    )
    cell.add(fp)
    fp = gdspy.FlexPath(
        [(2, 0), (3, 1)],
        [0.1, 0.2],
        0.2,
        ends=(0.2, 0.1),
github heitzmann / gdspy / docs / makeimages.py View on Github external
[(0, 0), (0, 1)],
        [0.1, 0.3, 0.5],
        offset=[-0.2, 0, 0.4],
        layer=[0, 1, 2],
        corners=broken,
        ends=pointy,
    )
    sp3.segment((3, 3), offset=[-0.5, -0.1, 0.5])
    sp3.segment((4, 1), width=[0.2, 0.2, 0.2], offset=[-0.2, 0, 0.2])
    sp3.segment((0, -1), relative=True)
    draw(gdspy.Cell("flexible_paths_1").add(sp3))

    # Flexible Paths 2
    # Path created with automatic bends of radius 5
    points = [(0, 0), (0, 10), (20, 0), (18, 15), (8, 15)]
    sp4 = gdspy.FlexPath(
        points, 0.5, corners="circular bend", bend_radius=5, gdsii_path=True
    )

    # Same path, generated with natural corners, for comparison
    sp5 = gdspy.FlexPath(points, 0.5, layer=1, gdsii_path=True)
    draw(gdspy.Cell("flexible_paths_2").add([sp4, sp5]))

    # Robust Paths
    # Create 4 parallel paths in different layers
    lp = gdspy.RobustPath(
        (50, 0),
        [2, 0.5, 1, 1],
        [0, 0, -1, 1],
        ends=["extended", "round", "flush", "flush"],
        layer=[0, 2, 1, 1],
    )
github heitzmann / gdspy / docs / _static / photonics.py View on Github external
(0, 0),
            "+y",
            1.55,
            numpy.sin(numpy.pi * 8 / 180),
            21.5,
            width,
            tolerance=0.001,
        )
    )

    taper = gdspy.Cell("NTaper")
    taper.add(gdspy.Path(0.12, (0, 0)).segment(taper_len, "+y", final_width=width))

    c = gdspy.Cell("Negative")
    for i, gap in enumerate(ring_gaps):
        path = gdspy.FlexPath(
            [(input_gap * i, taper_len)],
            width=width,
            corners="circular bend",
            bend_radius=bend_radius,
            gdsii_path=True,
        )
        path.segment((0, 600 - wg_gap * i), relative=True)
        path.segment((io_gap, 0), relative=True)
        path.segment((0, 300 + wg_gap * i), relative=True)
        c.add(path)
        c.add(gdspy.CellReference(ring, (input_gap * i + width / 2 + gap, 300)))
    c.add(gdspy.CellArray(taper, len(ring_gaps), 1, (input_gap, 0), (0, 0)))
    c.add(
        gdspy.CellArray(
            grat, len(ring_gaps), 1, (input_gap, 0), (io_gap, 900 + taper_len)
        )
github heitzmann / gdspy / docs / _static / photonics.py View on Github external
1.55,
            numpy.sin(numpy.pi * 8 / 180),
            21.5,
            tolerance=0.001,
        )
    )

    p = gdspy.Path(big_margin, (0, 0), number_of_paths=2, distance=big_margin + 0.12)
    p.segment(
        taper_len, "+y", final_width=small_margin, final_distance=small_margin + width
    )
    taper = gdspy.Cell("PTaper").add(p)

    c = gdspy.Cell("Positive")
    for i, gap in enumerate(ring_gaps):
        path = gdspy.FlexPath(
            [(input_gap * i, taper_len + bus_len)],
            width=[small_margin, small_margin],
            offset=small_margin + width,
            gdsii_path=True,
        )
        path.segment((0, 600 - bus_len - bend_radius - wg_gap * i), relative=True)
        path.turn(bend_radius, "r")
        path.segment((io_gap - 2 * bend_radius, 0), relative=True)
        path.turn(bend_radius, "l")
        path.segment((0, 300 - bend_radius + wg_gap * i), relative=True)
        c.add(path)
        dx = width / 2 + gap
        c.add(
            gdspy.boolean(
                gdspy.boolean(
                    ring_bus, gdspy.copy(ring_margin, dx, 300), "or", precision=1e-4