flexcompute / tidy3d

Fast electromagnetic solver (FDTD) at scale.
https://docs.flexcompute.com/projects/tidy3d/en/latest/
GNU Lesser General Public License v2.1
188 stars 44 forks source link

Adjoint Master Plan #1548

Open tylerflex opened 8 months ago

tylerflex commented 8 months ago

October 2024 >

Older

Roughly ordered by priority within each section

Tyler

Yannick

nkvij commented 2 months ago

Hello, I am a Tidy3D user and am interested in doing inverse design on photonic crystal cavities for which I would require Adjoint support for Cylinder geometry, FieldTimeMonitor and FieldMonitor. Is it possible for you guys to bump up these things in priority? It would also be great if you could give me an approximate timeline for these features. Also, apologies if this is the wrong place for this comment. Thank you, Neelesh

tylerflex commented 2 months ago

Hi @nkvij thanks for your feedback.

Thanks for your patience. We're going through a bit of a clean-up period to make the feature more stable and tested after the very fast feature implementation over the past couple months, but once we finish that up, we'll definitely start on cylinder and field time!

momchil-flex commented 2 months ago

Hi @nkvij , do you also need our ResonanceFinder to be differentiable and not just the FieldTimeMonitor? Because that's another thing that's not even on the map yet.

By the way maybe you should consider legume :)

nkvij commented 2 months ago

Hey @momchil-flex, just saw your comment. Yes, I would need Resonancefinder to be differentiable too. I forgot that it was separate from FieldTimeMonitor.

Haha that's a great pitch for Legume. However, it would be nice to be able to inverse design 1D photonic crystals too :)

nkvij commented 1 month ago

Hello, as we are reaching the 2-month mark, I wanted to check in if there are any updates regarding this. Thank you so much!

Hi @nkvij thanks for your feedback.

  • FieldMonitor is supported as of the latest release (2.7.2) and you can differentiate through various operations on the field monitor output, such as flux, poynting and intensity.
  • Cylinder is in production, there's actually a PR open for it 🗻 autograd Cylinder #1791 but it will need some more work. I'd anticipate it will be out within the next 2-3 weeks.
  • FieldTimeMonitor is a bit trickier. In principle it shouldn't be too hard, but we need more bandwidth to work on it. So I'll bump the priority (you're the first person who asked) but I wouldn't expect that one for the next 2-3 months.

Thanks for your patience. We're going through a bit of a clean-up period to make the feature more stable and tested after the very fast feature implementation over the past couple months, but once we finish that up, we'll definitely start on cylinder and field time!

tylerflex commented 1 month ago

Hi @nkvij ,

Cylinder is working, but we have not started work on FieldTimeMonitor or ResonanceFinder. I looked into the field time monitor support and I think it will require substantial changes. Since we have a number of things on our roadmap which are higher urgency (such as some performance improvements), I don't anticipate being able to work on this for at least a few more months.

In the meantime, it might be worth seeing if you can find a workaround solution. For example, perhaps you can run your simulations with FieldTimeMonitor and ResonanceFinder, find the resonance frequency, and then run a differentiable simulation using a FieldMonitor at that frequency?

Given your concern, I'll bump the priority of this feature and will keep you updated once we start work on it.

nkvij commented 1 month ago

How do I use the cylinder geometry?

I will try and figure out a workaround using only the FieldMonitor. Thank you for the update!

tylerflex commented 1 month ago

The cylinder just works when your objective function arguments ultimately give rise to either the center or the radius of a td.Cylinder. For example, an objective function like

def f(x):
    radius = x + 2
    cyl = td.Cylinder(radius=radius, ...)
    # make a sim containing this cylinder
    # figure of merit, etc.

see cell [9] of this unpublished notebook for an example for photonic crystals

https://github.com/flexcompute/tidy3d-notebooks/blob/e6501bf89419fbefcd3566b1eee1dc062dbc5876/Autograd18PhotonicCrystal.ipynb