Skip to content
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

subpixel smoothing gradients #1649

Closed
smartalecH opened this issue Jun 30, 2021 · 4 comments · Fixed by #1754 or #1780
Closed

subpixel smoothing gradients #1649

smartalecH opened this issue Jun 30, 2021 · 4 comments · Fixed by #1754 or #1780

Comments

@smartalecH
Copy link
Collaborator

Now that material grids have support for subpixel smoothing, it would be nice to enable gradient support.

Luckily, this should be rather straightforward given the current infrastructure. Since the current recombination step uses a finite difference to compute dA/dp, we just need to make sure that the finite difference routine also calls the new subpixel averaging routine (in this function).

We also need to store the adjoint D fields, rather than the E fields.

@stevengj
Copy link
Collaborator

We also need to store the adjoint D fields, rather than the E fields.

This might be an improvement, i.e. compute -Eₐᵀ (∂ε⁻¹/∂p) D instead of Eₐᵀ (∂ε/∂p) E as we are doing now. The two should be equivalent in the continuum limit, but I have a feeling that the former is more accurate in the discrete case. We'll have to look at it more closely, though, and it could be done separately from this issue.

@smartalecH
Copy link
Collaborator Author

A rather straightforward approach to properly calculate the permittivity at each point is to use the get_material_pt() function (as previously discussed). Unfortunately, we need an instance of the geom_epsilon object (e.g. geps) used to fill in the structure, which seems to be discarded after the simulation is initialized. This is problematic when calling material_grids_addgradient() (which is ultimately what loops over the design regions and does the recombination step in the adjoint method).

Currently, to get around this, we pass in a copy of the geom_tree and reinitialize several things (on every process). Is there a better (i.e. cleaner way) to gain access to the get_material_pt() function we need?

@stevengj
Copy link
Collaborator

stevengj commented Sep 1, 2021

We could just return the geom_epsilon object and save it in the Python simulation object.

Basically, refactor set_materials_from_geometry to a function that first constructs a geom_epsilon object (which will now be public in meepgeom.hpp) and then a second function that sets the materials given this geom_epsilon object). Then Python can save geom_epsilon.

@stevengj
Copy link
Collaborator

stevengj commented Oct 1, 2021

(#1754 was only the refactoring part of this change, so it shouldn't have closed this issue.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants