phidl icon indicating copy to clipboard operation
phidl copied to clipboard

non-manhattan connect

Open joamatab opened this issue 3 years ago • 6 comments
trafficstars

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])

image

joamatab avatar Jun 22 '22 16:06 joamatab

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()

image

joamatab avatar Jun 22 '22 17:06 joamatab

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?

amccaugh avatar Jun 22 '22 19:06 amccaugh

1e-10 looks better

image

the default is 1e-9

joamatab avatar Jun 23 '22 04:06 joamatab

We solved this issue in gdsfactory

https://github.com/gdsfactory/gdsfactory/pull/479

now we can even work with offgrid ports

joamatab avatar Jun 23 '22 17:06 joamatab

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:

image

amccaugh avatar Jun 25 '22 17:06 amccaugh

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

joamatab avatar Jun 27 '22 17:06 joamatab