How to use the gdspy.Path 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 / docs / _static / photonics.py View on Github external
small_margin = 5.0
    taper_len = 50.0
    bus_len = 400.0
    input_gap = 150.0
    io_gap = 500.0
    wg_gap = 20.0
    ring_gaps = [0.06 + 0.02 * i for i in range(8)]

    ring_margin = gdspy.Rectangle(
        (0, -ring_radius - big_margin),
        (2 * ring_radius + big_margin, ring_radius + big_margin),
    )
    ring_hole = gdspy.Round(
        (ring_radius, 0), ring_radius, ring_radius - width, tolerance=0.001
    )
    ring_bus = gdspy.Path(
        small_margin, (0, taper_len), number_of_paths=2, distance=small_margin + width
    )
    ring_bus.segment(bus_len, "+y")

    p = gdspy.Path(
        small_margin, (0, 0), number_of_paths=2, distance=small_margin + width
    )
    p.segment(21.5, "+y", final_distance=small_margin + 19)
    grat = gdspy.Cell("PGrat").add(p)
    grat.add(
        grating(
            0.626,
            28,
            0.5,
            19,
            (0, 0),
github DerekK88 / PICwriter / picwriter / components / mmi1x2.py View on Github external
tp = Taper(
                self.wgt,
                self.taper_length,
                self.taper_width,
                port=(x, y),
                direction="EAST",
            )
            self.add(tp)
            x, y = tp.portlist["output"]["port"]

        #
        #        path1 = gdspy.Path(self.wgt.wg_width, (0,0))
        #        path1.segment(self.taper_length, direction='+x', final_width=self.taper_width, **self.wg_spec)
        #
        """ Add the MMI region """
        mmi = gdspy.Path(self.width, (x, y))
        mmi.segment(self.length, direction="+x", **self.wg_spec)
        self.add(mmi)

        clad_pts = [
            (0.0, -self.wgt.wg_width / 2.0 - self.wgt.clad_width),
            (self.taper_length, -self.width / 2.0 - self.wgt.clad_width),
            (self.taper_length + self.length, -self.width / 2.0 - self.wgt.clad_width),
            (
                2 * self.taper_length + self.length,
                -self.wg_sep / 2.0 - self.wgt.wg_width / 2.0 - self.wgt.clad_width,
            ),
            (
                2 * self.taper_length + self.length,
                self.wg_sep / 2.0 + self.wgt.wg_width / 2.0 + self.wgt.clad_width,
            ),
            (self.taper_length + self.length, self.width / 2.0 + self.wgt.clad_width),
github DerekK88 / PICwriter / picwriter / components / mmi2x2.py View on Github external
clad_path1 = gdspy.Path(self.wgt.wg_width + 2 * self.wgt.clad_width, (0, 0))
        clad_path1.turn(
            self.wgt.bend_radius,
            -self.angle,
            number_of_points=self.wgt.get_num_points_wg(self.angle),
            **self.clad_spec
        )
        clad_path1.turn(
            self.wgt.bend_radius,
            self.angle,
            number_of_points=self.wgt.get_num_points_wg(self.angle),
            final_width=self.taper_width + 2 * self.wgt.clad_width,
            **self.clad_spec
        )
        # Bottom input
        clad_path2 = gdspy.Path(
            self.wgt.wg_width + 2 * self.wgt.clad_width,
            (0, -self.wg_sep - 2 * angle_y_dist),
        )
        clad_path2.turn(
            self.wgt.bend_radius,
            self.angle,
            number_of_points=self.wgt.get_num_points_wg(self.angle),
            **self.clad_spec
        )
        clad_path2.turn(
            self.wgt.bend_radius,
            -self.angle,
            number_of_points=self.wgt.get_num_points_wg(self.angle),
            final_width=self.taper_width + 2 * self.wgt.clad_width,
            **self.clad_spec
        )
github DerekK88 / PICwriter / picwriter / components / contradc.py View on Github external
wg_bot.segment(self.length, **self.wg_spec)
        wg_bot.turn(
            self.wgt.bend_radius,
            -self.angle,
            number_of_points=self.wgt.get_num_points_wg(self.angle),
            final_width=self.wgt.wg_width,
            **self.wg_spec
        )
        wg_bot.turn(
            self.wgt.bend_radius,
            self.angle,
            number_of_points=self.wgt.get_num_points_wg(self.angle),
            **self.wg_spec
        )

        wg_bot_clad = gdspy.Path(
            2 * self.wgt.clad_width + self.wgt.wg_width, (x02, y02)
        )
        wg_bot_clad.turn(
            self.wgt.bend_radius,
            self.angle,
            number_of_points=self.wgt.get_num_points_wg(self.angle),
            **self.clad_spec
        )
        wg_bot_clad.turn(
            self.wgt.bend_radius,
            -self.angle,
            number_of_points=self.wgt.get_num_points_wg(self.angle),
            final_width=2 * self.wgt.clad_width + self.width_bot,
            **self.clad_spec
        )
        wg_bot_clad.segment(self.length, **self.clad_spec)
github DerekK88 / PICwriter / picwriter / components / fullcoupler.py View on Github external
)
        wg_bot.turn(
            self.wgt.bend_radius,
            -p * self.angle,
            number_of_points=self.wgt.get_num_points_wg(self.angle),
            **self.wg_spec
        )
        wg_bot.turn(
            self.wgt.bend_radius,
            +p * self.angle,
            number_of_points=self.wgt.get_num_points_wg(self.angle),
            final_width=self.wgt.wg_width,
            **self.wg_spec
        )

        wg_bot_clad = gdspy.Path(2 * self.wgt.clad_width + self.wgt.wg_width, (x1, y1))
        wg_bot_clad.turn(
            self.wgt.bend_radius,
            +p * self.angle,
            number_of_points=self.wgt.get_num_points_wg(self.angle),
            **self.clad_spec
        )
        wg_bot_clad.turn(
            self.wgt.bend_radius,
            -p * self.angle,
            number_of_points=self.wgt.get_num_points_wg(self.angle),
            final_width=self.wgt.wg_width + 2 * self.wgt.clad_width,
            **self.clad_spec
        )
        wg_bot_clad.segment(self.length, **self.clad_spec)
        wg_bot_clad.turn(
            self.wgt.bend_radius,
github DerekK88 / PICwriter / picwriter / components / stripslotmmiconverter.py View on Github external
def __build_cell(self):
        # Sequentially build all the geometric shapes using gdspy path functions
        # for waveguide, then add it to the Cell

        # Add MMI region
        path_mmi = gdspy.Path(self.w_mmi, (0, 0))
        path_mmi.segment(self.l_mmi, direction=0, **self.wg_spec)

        print("path_mmi_coords = " + str((path_mmi.x, path_mmi.y)))

        # Add slot tapered region
        path_taper = gdspy.Path(
            (self.w_mmi - self.wgt_slot.slot) / 2.0,
            initial_point=(path_mmi.x, path_mmi.y),
            number_of_paths=2,
            distance=(self.w_mmi + self.wgt_slot.slot) / 2.0,
        )
        path_taper.segment(
            self.length - self.l_mmi,
            final_width=self.wgt_slot.rail,
            final_distance=self.wgt_slot.rail_dist,
            direction=0,
github DerekK88 / PICwriter / picwriter / components / waveguide.py View on Github external
)
                        prev_dl = dl

                    path2.segment(
                        tk.dist(self.trace[-2], self.trace[-1]) - prev_dl,
                        direction=next_angle,
                        **cur_spec
                    )
                self.add(path2)

        else:
            """ Strip and slot waveguide generation below
            """
            if len(self.trace) == 2:
                if self.wgt.wg_type == "strip":
                    path = gdspy.Path(self.wgt.wg_width, self.trace[0])
                    path.segment(
                        tk.dist(self.trace[0], self.trace[1]),
                        direction=tk.get_exact_angle(self.trace[0], self.trace[1]),
                        **self.wg_spec
                    )
                elif self.wgt.wg_type == "slot":
                    path = gdspy.Path(
                        self.wgt.rail,
                        self.trace[0],
                        number_of_paths=2,
                        distance=self.wgt.rail_dist,
                    )
                    path.segment(
                        tk.dist(self.trace[0], self.trace[1]),
                        direction=tk.get_exact_angle(self.trace[0], self.trace[1]),
                        **self.wg_spec
github DerekK88 / PICwriter / picwriter / components / electrical.py View on Github external
)
                prior_direction = direction
            if tk.dist(self.trace[-2], self.trace[-1]) < 2 * br:
                path.segment(tk.dist(self.trace[-2], self.trace[-1]) - br, **self.spec)
                path2.segment(
                    tk.dist(self.trace[-2], self.trace[-1]) - br, **self.clad_spec
                )
            else:
                path.segment(br, **self.spec)
                path2.segment(br, **self.clad_spec)

            if (
                len(self.trace) == 2
                and tk.dist(self.trace[1], self.trace[0]) <= self.mt.bend_radius
            ):
                path = gdspy.Path(self.mt.width, self.trace[0])
                path.segment(
                    tk.dist(self.trace[0], self.trace[1]),
                    direction=tk.get_angle(self.trace[0], self.trace[1]),
                    **self.spec
                )
                path2 = gdspy.Path(
                    self.mt.width + 2 * self.mt.clad_width, self.trace[0]
                )
                path2.segment(
                    tk.dist(self.trace[0], self.trace[1]),
                    direction=tk.get_angle(self.trace[0], self.trace[1]),
                    **self.clad_spec
                )
        elif br == 0:
            """ Do path routing for sharp 90 degree trace bends """
            path.segment(
github DerekK88 / PICwriter / picwriter / components / mmi2x2.py View on Github external
)
        clad_path4.turn(
            self.wgt.bend_radius,
            self.angle,
            number_of_points=self.wgt.get_num_points_wg(self.angle),
            final_width=self.wgt.wg_width + 2 * self.wgt.clad_width,
            **self.clad_spec
        )
        clad_path4.turn(
            self.wgt.bend_radius,
            -self.angle,
            number_of_points=self.wgt.get_num_points_wg(self.angle),
            **self.clad_spec
        )
        # Bottom output
        clad_path5 = gdspy.Path(
            self.taper_width + 2 * self.wgt.clad_width,
            (clad_path2.x + self.length, clad_path2.y),
        )
        clad_path5.turn(
            self.wgt.bend_radius,
            -self.angle,
            number_of_points=self.wgt.get_num_points_wg(self.angle),
            final_width=self.wgt.wg_width + 2 * self.wgt.clad_width,
            **self.clad_spec
        )
        clad_path5.turn(
            self.wgt.bend_radius,
            self.angle,
            number_of_points=self.wgt.get_num_points_wg(self.angle),
            **self.clad_spec
        )
github DerekK88 / PICwriter / picwriter / components / stripslotmmiconverter.py View on Github external
path_taper = gdspy.Path(
            (self.w_mmi - self.wgt_slot.slot) / 2.0,
            initial_point=(path_mmi.x, path_mmi.y),
            number_of_paths=2,
            distance=(self.w_mmi + self.wgt_slot.slot) / 2.0,
        )
        path_taper.segment(
            self.length - self.l_mmi,
            final_width=self.wgt_slot.rail,
            final_distance=self.wgt_slot.rail_dist,
            direction=0,
            **self.wg_spec
        )

        # Cladding for waveguide taper
        path_clad = gdspy.Path(
            2 * self.wgt_strip.clad_width + self.wgt_strip.wg_width, (0, 0)
        )
        path_clad.segment(
            self.length,
            final_width=2 * self.wgt_slot.clad_width + self.wgt_slot.wg_width,
            direction=0,
            **self.clad_spec
        )

        if not self.input_strip:
            center_pt = (self.length / 2.0, 0)
            path_mmi.rotate(np.pi, center_pt)
            path_taper.rotate(np.pi, center_pt)
            path_clad.rotate(np.pi, center_pt)

        self.add(path_mmi)