I have to layout asymmetric MZIs with an exact path length difference. The overall path lengths should be no longer than necessary. Normally I solve the trigonometry problem on paper, then code it as a Python function.
Since there’s typically not a closed-form solution I use scipy.minimize() to find function parameters that get the right path length difference and also make the waveguides connect up correctly.
This works, but I wonder if there’s a faster way to code it up than having to solve all this math for each geometry I try. Can I create a new cell with each iteration within scipy.minimize(), never place the cell in the layout, and use the a0/b0 ports’ .xya() data to make sure that my waveguides will join up ok? Do I need to do some cleanup after each iteration to avoid running out of memory or filling the netlist with cells I will never use? I see there’s a cell.close() method but I’m not sure if that does what I want, which is to erase the cell from memory & netlist as if it was never there.
By the way it also doesn’t seem appropriate to use interconnect functions for this application since I don’t think there is a way to get them to return path lengths or minimum curvature in an interconnect.
I set up a problem using trial cells with the purpose of finding path length & exact output port location. The approach does work. But I still haven’t figured out how to remove a cell from the netlist.
I get very many warnings like this:
WARNING: netlist.py: ND-342: Duplicate cell name in nd.Cell(name=’trial bot’) renamed to ‘trial bot_1506’.
I realized that cell.close() is automatically called when I use the “with nd.Cell(…) as cell:” formation, so that is not the method I’m looking for.
Standard python “del cell” does not seem to work.
The unused trial cells don’t show up in my GDS hierarchy, so they aren’t increasing my GDS file size. The only issue remains that if I adopt this practice of making trial cells and build bigger layouts with it, I’ll run out of memory or have slower compiles.