stanfordnqp/spins-b

Custom Parametrization

marpers opened this issue · 4 comments

Is it possible to create custom shape nodes which also have a custom parametrization? As mentioned in the documentation, it is possible to add custom nodes, so they can be used to add custom shapes. But can some of the variables defining the geometry of the custom shapes also be parameters in the optimization? So essentially, is it possible to have custom parametrizations besides the pixelated continuous shape?
Thanks!

To be clear, in goos, the only thing that is optimizable is goos.Variable, which represents some numeric quantity. If this value is used to compute some shape, which is used in a simulation, then the framework will detect that the simulation depends on the shape which depends on the goos.Variable and optimize over that variable. Therefore in principle, there's no issue with, for example, using a variable to define the radius of a cylinder.

The tricky part, though, is that the simulator must also understand how to draw the shape flow and how to produce gradients for the shape flow. Currently, the Maxwell solver can only produce gradients for non-overlapping pixelated continuous shape flows, which is why the grating coupler example uses PixelatedGrating (which produces a PixelatedContinuousShapeFlow) rather than an implementation that produces a list of CuboidFlows. This a temporary stop-gap measure, since you can get increasingly better approximations of the structure by using finer and finer pixels (note that the pixel size is independent of the simulation grid and may be finer or coarser than the simulation). You can of course modify the simulator (or use your own) to resolve this issue.

Thanks a lot! Just a follow up question: When it comes modifying the solver, on which level would that have to be? So is it basically sufficient to modify the simulator in spins/goos_sim/maxwell to be able to deal with other shape flows? And then use spins/fdfd_solvers and the maxwell-b multi-GPU solver unchanged. And if that is the case, would goos or invdes be better suited for this purpose?

It would be at spins/goos_sim/maxwell level. Specifically, the maxwell.RenderShape which is responsible for drawing the shapes onto a Yee cell grid. The input to maxwell-b is just permittivity distribution on the Yee cell grid, so that is unchanged (as is maxwell.fdfd_simulation).

Great, thank you!