fancompute / legume

🌱 Guided-mode expansion of photonic crystal slabs
https://legume.readthedocs.io/
MIT License
104 stars 27 forks source link

Overlapping shapes #67

Closed iarayad closed 2 months ago

iarayad commented 3 months ago

Hi!

I am interested in creating C6 symmetric unit cells using legume, and FourierShape seems like a good option. However, I notice that one should not have overlapping shapes. Is there a way to have a FourierShape "inside" another by going around the overlapping error? Say for example I want a hexagonal unit cell, with a hexagone "hole" inside of it, but I don't want the hole to be completely empty, but to have a circular pillar inside. Is this possible? how would I approach it?

momchil-flex commented 3 months ago

Off the top of my head I don't remember ever trying that, so I'm not sure if it will work. But what comes to mind is to create the shape as a "folded" polygon, meaning you can make cut somewhere, and "unfold" the polygon such that it doesn't have holes anymore, and its first two points are the same as the last two points. Do you know what I mean? You should definitely verify if this works by plotting eps_ft, and please share your results here so others know too if this works!

iarayad commented 3 months ago

Thank you! I think this sounds like an interesting idea, but I'm worried I may get into troubles when optimizing multiple shapes with autograd. Perhaps using shapes is not the correct approach to my problem. Do you know whether I can do pixel-based optimization for bandstructure with legume? (or maybe another tool). I recognize this is not the right place to ask for this, but I think my question may have been too narrow, as using shapes introduces problems when many of their parameters make them overlap.

momchil-flex commented 2 months ago

Yeah I think legume wouldn't really work with pixel-based (topology) optimization. I can't think of any implementation of the adjoint method that works directly on the band structure and can do topology optimization - maybe one exists but I don't know. There are differentiable implementations of the RCWA method though that may or may not work for you, e.g. https://github.com/weiliangjinca/grcwa

Eventually, we may support this in Tidy3D too. However currently our ResonanceFinder is not differentiable, so you cannot backprop from the eigenvalues (band structure). However, there too you could already do topology optimization on the scattering properties, e.g. like here