Ejemplo n.º 1
0
    def get_routes(self):
        from ipkiss.plugins.photonics.routing.to_line import RouteToNorth, RouteToEastAtY, RouteToWestAtY, RouteToEast, RouteToWest

        # if we route south, we just flip the ports, and do allt he calculation
        # for north. Then at the end we flip again.
        if self.route_south:
            sp = self.splitter_port.transform_copy(VMirror())
            cp = self.combiner_port.transform_copy(VMirror())
        else:
            sp = self.splitter_port
            cp = self.combiner_port
        str_p = self.structure.ports.transform_copy(
            self.structure_transformation)

        # going up
        r1a = RouteToNorth(input_port=sp, end_straight=0.0)
        r1b = RouteToEast(input_port=r1a.ports[-1])
        # going towards the center
        r2a = RouteToNorth(input_port=cp, end_straight=0.0)
        r2b = RouteToWest(input_port=r2a.ports[-1])
        # going outward from the component
        r1c = RouteToWest(input_port=str_p[self.port_labels[0]],
                          end_straight=0.0)
        r2c = RouteToEast(input_port=str_p[self.port_labels[1]],
                          end_straight=0.0)

        # deterimine which should go more north
        if r1b[-1].y - r1c[-1].y > r2b[-1].y - r2c[-1].y:
            r2b = RouteToWestAtY(input_port=r2a.ports[-1],
                                 y_position=r1b.ports[-1].position.y)
        else:
            r1b = RouteToEastAtY(input_port=r1a.ports[-1],
                                 y_position=r2b.ports[-1].position.y)

        if not self.extra_length == 0.0:
            # adjust the length to the user-set length
            y = r2b.ports[-1].position.y + 0.5 * (self.extra_length)
            r2b = RouteToWestAtY(input_port=r2a.ports[-1],
                                 y_position=r2b.ports[-1].position.y +
                                 0.5 * self.extra_length)
            r1b = RouteToEastAtY(input_port=r1a.ports[-1],
                                 y_position=r1b.ports[-1].position.y +
                                 0.5 * self.extra_length)

        # moving the structure in place
        extra_translation = (0.5 * (r1b[-1].x + r2b[-1].x -
                                    (r1c[-1].x + r2c[-1].x)),
                             r1b[-1].y - r1c[-1].y)

        r1 = r1a + r1b + r1c.reversed().move_copy(extra_translation)
        r2 = r2a + r2b + r2c.reversed().move_copy(extra_translation)

        # don't forget to flip if we calculated everything upside down
        if self.route_south:
            r1.v_mirror()
            r2.v_mirror()
        return [r1, r2]
Ejemplo n.º 2
0
 def define_R2(self):
     if self.separation is None:
         return RouteToEast(
             input_port=self.CPin[0],  #.move_copy(in_coupler_pos), 
             bend_radius=self.bend_radius,
             rounding_algorithm=self.rounding_algorithm)
     else:
         return RouteToEastAtY(
             input_port=self.CPin[0],  #.move_copy(in_coupler_pos), 
             y_position=-0.5 * self.separation,
             bend_radius=self.bend_radius,
             rounding_algorithm=self.rounding_algorithm)
Ejemplo n.º 3
0
    def get_route(self):
        from ipkiss.plugins.photonics.routing.to_line import RouteToNorth, RouteToEastAtY, RouteToWestAtY, RouteToEast, RouteToWest

        # if we route sourh, we just flip the ports, and do allt he calculation
        # for north. Then at the end we flip again.
        if self.route_south:
            sp = self.splitter_port.transform_copy(VMirror())
            cp = self.combiner_port.transform_copy(VMirror())
        else:
            sp = self.splitter_port
            cp = self.combiner_port

        r1a = RouteToNorth(input_port=sp)
        r2a = RouteToNorth(input_port=cp)
        # check which one ends up northmost, and bend both of them
        # toward each other at the same height.
        if r1a[-1].y > r2a[-1].y:
            r1b = RouteToEast(input_port=r1a.ports[-1])
            r2b = RouteToWestAtY(input_port=r2a.ports[-1],
                                 y_position=r1b.ports[-1].position.y)
        else:
            r2b = RouteToWest(input_port=r2a.ports[-1])
            r1b = RouteToEastAtY(input_port=r1a.ports[-1],
                                 y_position=r2b.ports[-1].position.y)
        r = r1a + r1b + r2b.reversed() + r2a.reversed()

        if not self.extra_length == 0.0:
            # adjust the length to the user-set length
            y = r2b.ports[-1].position.y + 0.5 * (self.extra_length)
            r2b = RouteToWestAtY(input_port=r2a.ports[-1], y_position=y)
            r1b = RouteToEastAtY(input_port=r1a.ports[-1], y_position=y)

            r = r1a + r1b + r2b.reversed() + r2a.reversed()

        # don't forget to flip if we calculated everything upside down
        if self.route_south:
            r.v_mirror()
        return r