Routing
- class pyphotonics.layout.routing.WaveguideGeometry(width, kind='slab', ridge_width=None)
Waveguide shape.
- Variables
width (float) – Base width of waveguide in GDS units.
geometry ('slab' or 'ridge') – Geometry of waveguide. Ridge waveguides are currently unimplemented.
ridge_width (float) – Width of partial etch mask for ridge in GDS units.
- class pyphotonics.layout.routing.Port(x, y, angle, geometry=None)
Connection port for waveguide routing.
- Variables
x (float) – GDS x coordinate.
y (float) – GDS y coordinate.
angle (float) – Angle from positive x axis in radians.
geometry (WaveguideGeometry) – Geometry of waveguide at port.
- class pyphotonics.layout.routing.WaveguidePath(router, points, wg_geometry, r_vals, input_geometry=None, output_geometry=None)
GDS waveguide route.
- Parameters
router (Router) – Waveguide router class.
points (list[numpy tuple]) – Coordinates of points defining the waveguide route.
wg_geometry (WaveguideGeometry) – Geometry of the waveguide.
r_vals (list[float]) – Possible bend radii in GDS units.
input_geometry (WaveguideGeometry) – Geometry of input port.
output_geometry (WaveguideGeometry) – Geometry of output port.
- Variables
N (int) – Number of points in path.
points (list[numpy tuple]) – Coordinates of points defining the waveguide route.
wg_geometry (WaveguideGeometry) – Geometry of the waveguide.
r_vals (list[float]) – Possible bend radii in GDS units.
r_min (float) – Minimum bend radius in GDS units.
bend_radii (list[float]) – Bend radius at each point, 0 at starting and ending vertices.
input_geometry (WaveguideGeometry) – Geometry of input port.
output_geometry (WaveguideGeometry) – Geometry of output port.
input_taper_len (float) – Length of input taper
output_taper_len (float) – Length of output taper
Notes
The path traced out by the points should make up the tangent line to the final path. Bends will be automatically computed upon export to GDS.
- get_length(index)
Returns the length of the given path segment.
- Parameters
index (int) – Index of segment in path. Must be in the range [0, len(path)-1).
- Returns
length – Length of specified segment in path.
- Return type
float
- minimum_length(index)
Returns the minimum length of the given path segment such that the corresponding bend radii are valid.
- Parameters
index (int) – Index of segment in path. Must be in the range [0, len(path)-1).
- Returns
min_length – Minimum length of specificied segment in path.
- Return type
float
- trim()
Deletes points that do not contribute to the waveguide geometry.
- segment_drag(index, d)
Drag segment by the given perpendicular distance while maintaining its angle. Cannot drag the first or last segments.
- Parameters
index (int) – Index of segment in path. Must be in the range [1, len(path)-2).
d (float) – Distance to drag segment.
- ensure_r_min()
Shift path segments by minimum amount to ensure that there is space for each bend.
- maximize_bend_radii()
Assign the largest possible bend radius to each bend, prioritizing uniformity.
- class pyphotonics.layout.routing.Router(wavelength=1.762, n_core=3.67, n_cladding=1.44, alpha=0.9)
Waveguide router class.
- Variables
wavelength (float) – Operation wavelength of device.
n_core (float) – Refractive index of waveguide core.
n_cladding (float) – Refractive index of waveguide cladding.
alpha (float) – Proportionality constant for width of adiabatic tapers.
- calculate_taper(input_geometry, output_geometry, start, angle)
Computes a taper with the given parameters for export to GDS.
- Parameters
input_geometry (WaveguideGeometry) – Input geometry of taper.
output_geometry (WaveguideGeometry) – Output geometry of taper.
start (numpy tuple) – Coordinates of taper start.
angle (float) – Angle of taper in radians counter-clockwise from the horizontal.
- Returns
poly1 (list[numpy tuple]) – GDS polygon for first layer of taper.
poly2 (list[numpy tuple]) – GDS polygon for second layer of taper.
end (numpy tuple) – Coordinate of midpoint of end of taper.
- get_potential_ports(gds, geometries, bbox=None)
Finds potential ports in the provided GDS file using the geometry of the connecting waveguides.
- Parameters
gds (str) – Path to the GDS for which the routes are being generated.
geometries (list[WaveguideGeometry]) – Geometry of waveguide connecting ports.
bbox (4-tuple) – (x0, y0, x1, y1) tuple where (x0, y0) and (x1, y1) are the bottom-left and top-right corners, respectively, of the area in which to look for ports.
- Returns
ports – List of ports that correspond to the given geometry.
- Return type
list[Port]
- get_rough_paths(inputs=[], outputs=[], bbox=None, geometries=None, route_file=None, current_gds=None)
Returns a user specified route from an existing .route file or the GUI.
- Parameters
inputs (list[Port]) – List of input ports.
outputs (list[Port]) – List of output ports.
bbox (4-tuple) – (x0, y0, x1, y1) tuple where (x0, y0) and (x1, y1) are the bottom-left and top-right corners, respectively, of the area in which the paths will be found. Automatically calculated from provided inputs and outputs unless explicitly specified.
geometries (list[WaveguideGeometry]) – If provided, allows the GUI to detect unspecified potential ports.
route_file (str) – Path to a .route file with the desired initial paths.
current_gds (str) – Path to the GDS for which the routes are being generated.
- Returns
inputs (list[Port]) – List of input ports corresponding to returned paths.
outputs (list[Port]) – List of output ports corresponding to returned paths.
paths (list[list[numpy tuple]]) – List of paths each consisting of a list of GDS coordinates.
- turn_port_route(port, r_min, target_angle, reverse=False, four_point_threshold=0.17453292519943295)
Returns a 3- or 4-point bend that turns the given port to the desired angle.
- Parameters
port (Port) – Port to turn to target angle.
r_min (float) – The minimum radius for executing the turn.
target_angle (float) – Angle in radians counter-clockwise from the horizontal that the port should be turned to.
reverse (bool) – Treat port as an output, returning the turn leading into the port from target_angle.
four_point_threshold (float) – Bends with angles from [-pi + fpt, pi - fpt] will have 3 points, outside of that range bends will have 4
- Returns
bend – 3- or 4-point bend that turns the given port to the desired angle.
- Return type
list[numpy tuple]
- direct_route(port1, port2, geometry, r_vals, x_first=None)
Returns a basic two segment Manhattan route between two ports, adding segments as necessary to account for port angle.
- Parameters
port1 (Port) – Input port.
port2 (Port) – Output port.
geometry (WaveguideGeometry) – Geometry of waveguide.
r_vals (list[float]) – Possible bend radii in GDS units
x_first (bool or None) – Determines whether the Manhattan bend traverses the x axis or y axis first. If None, the direction that minimizes bends is chosen.
- Returns
path – WaveguidePath between input and output port.
- Return type
Warning
direct_route()does not account for waveguide crossings or obstacles and simply connects two ports in the most efficient way possible. Crossings can be avoided by offsetting ports slightly from one another or using thex_firstparameter. It may also not work for cases where the ports cannot be connected by a simple two segment path.
- user_route(geometry, r_vals, inputs=[], outputs=[], bbox=None, route_file=None, current_gds=None, port_geometries=[])
Returns a user specified route that has been modified to fit the given specifications. Opens a routing GUI if necessary to allow for user input.
- Parameters
geometry (WaveguideGeometry) – Geometry of waveguides.
r_vals (list of floats) – Possible bend radii in GDS units.
inputs (list[Port]) – List of input ports.
outputs (list[Port]) – List of output ports such that each input port corresponds to the output port at the same index.
route_file (str) – Path to a .route file with the desired initial paths.
current_gds (str) – Path to the GDS for which the routes are being generated.
port_geometries (list[WaveguideGeometry]) – Additional geometries of ports if they differ from the routing waveguide geometry.
- Returns
paths – WaveguidePaths between each input and output port.
- Return type
list[WaveguidePath]
- write_paths_to_gds(paths, output_file, layer=0, datatype=0, layer2=1, datatype2=0, style='segmented')
Generates a set of paths with waveguides connecting inputs ports to output ports.
- Parameters
paths (list[WaveguidePath]) – List of WaveguidePaths to be written.
output_file (str) – Path to output GDS file.
layer (int) – Desired GDS layer for waveguides.
datatype (int) – Datatype label for GDS layer.
layer2 (int) – Desired GDS layer for partial etch.
datatype2 (int) – Datatype label for partial etch GDS layer.
style ('segmented' or 'continuous') – ‘segmented’ separates bends from straights, while ‘continuous’ creates a single polygon that is split up arbitrarily if the vertex count grows too large.
- Returns
paths – List of WaveguidePaths between their corresponding inputs and outputs.
- Return type
list[WaveguidePath]