-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
static jax structures & dispersive adjoint #1281
Conversation
…entiable and static geometry / medium in JaxStructure
f69f70b
to
ca7872c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. Somewhat related, and also related to our discussion yesterday, we should (or do we already?) validate that JaxSimulations
do not have nonlinear media in either their static structures or their JaxStructureStaticMedium ones.
@@ -253,6 +257,14 @@ def make_sim( | |||
|
|||
jax_geo_group = JaxGeometryGroup(geometries=[jax_polyslab1, jax_polyslab1]) | |||
jax_struct_group = JaxStructure(geometry=jax_geo_group, medium=jax_med1) | |||
|
|||
jax_struct_static_med = JaxStructureStaticMedium( | |||
geometry=jax_box1, medium=td.Medium() # material_library["Ag"]["Rakic1998BB"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you forget to uncomment the silver?
Yea good point. I can either do that in this PR or a separate one but would be a good idea. We could also consider just warning because the gradients might be approximately correct in some contexts? |
I guess warning could be fine too yeah. |
Hi @tylerflex! I tried the In the In the |
This is probably because we'd need to build a solver to use this front end commit. Can you try with a run_local instead of run? |
Note this PR adds a new field to the Jax info datastructure to remember what kind of input structures were used. So we need to make sure this is handled in the backend too. It might not even work with run local. @momchil-flex if it doesn't maybe could you build a solver using this commit so i can test? |
Ok.. got it! |
I've built a release and associated it to frontend version |
Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @tylerflex and @momchil-flex!
It is working now! The gradients were calculated with no errors in both examples.
Thanks for this feature Tyler! Taking into account dispersive materials in the simulation adds another level of interest to the adjoint.
Great! Maybe we can update those examples to use the new structure and materials from your test. Could you open a PR in the docs repo? (Assuming everything else worked the same too, if there were some complications like poor performance, we can leave them out for now). Also at some point it might be good to do a metallic inverse design example. Maybe an antenna. I will get to field projection support hopefully in the coming weeks |
Sure, I will run the complete optimizations and update them in docs. |
Thanks Emerson. @momchil-flex ill do nonlinear warnings in a separate PR |
Support for dispersive materials in adjoint (with shape / boundary optimization).
Adds two new adjoint structure classes:
JaxStructureStaticMedium
combines a jax geometry with a tidy3d medium.JaxStructureStaticGeometry
combines a tidy3d geometry with a jax medium.The former can be used to pair a differentiable geometry (
JaxPolySlab
) with any medium, eg a dispersive medium or something from the material library (like a metal).This PR mainly generalizes the
JaxGeometry
internals to an abstract class and then splits into the threeJaxStructure
,JaxStructureStaticMedium
, andJaxStructureStaticGeometry
to handle the field definitions and to do different adjoint handling depending on their_differentiable_fields
class attribute.Among another static geometry structure, the tests have a
JaxStructureStaticMedium
containing aJaxBox
and silver from our material library. So I think we can begin using this for eg metallic antenna design.