phidl
phidl copied to clipboard
non-manhattan connect
How can we connect two structures that have non-manhattan connections with offgrid ports?
import phidl.path as pp
import phidl.device_layout as pd
if __name__ == "__main__":
c = pd.Device('non-manhattan-connect')
b = c << pg.arc(theta=30)
s = c << pg.straight(size=(1, 1))
s.connect(1, b.ports[2])

one possible solution is to flatten
c = pd.Device('non-manhattan-connect')
b = c << pg.arc(theta=30)
s = c << pg.straight(size=(0.5, 1))
s.connect(1, b.ports[2])
c = c.flatten()

Interesting, if it works flattened that suggests it's not an issue with the routing, but just a more common integer-precision error. If you save the GDS with a precision of e.g. 1e-5 (instead of 1e-3), is it less bad?
1e-10 looks better

the default is 1e-9
We solved this issue in gdsfactory
https://github.com/gdsfactory/gdsfactory/pull/479
now we can even work with offgrid ports
How do you avoid this exactly? I assume you can snap the port itself to the grid, but when you allow arbitrary rotations (e.g. not just 90/180/270 manhattan rotations), integer rounding errors are inevitable. See for example this example -- left is the unsnapped port, right is the snapped port. There's no grid snapping is able to satisfactorily align the two polygons:
Here is the exact commit that fixed the issue in gdsfactory https://github.com/gdsfactory/gdsfactory/pull/479/commits/2dc64705cfa3f0048e2977362cea867d315fea4d
we have tested it only on port facets that have the same widths and it seems to be working
this will enable us to add component that have offgrid ports together with non- manhattan orientations