[13/14][Adjoint Module] Cover mode monitors under a mirror symmetry - #3301
Draft
smartalecH wants to merge 1 commit into
Draft
[13/14][Adjoint Module] Cover mode monitors under a mirror symmetry#3301smartalecH wants to merge 1 commit into
smartalecH wants to merge 1 commit into
Conversation
smartalecH
marked this pull request as draft
September 4, 2026 16:55
smartalecH
force-pushed
the
test/adjoint-mode-monitor-symmetry
branch
from
September 4, 2026 17:32
34ef4a4 to
25588b9
Compare
test_adjoint_symmetry.py exercises FourierFields only. EigenmodeCoefficient reaches the adjoint through a different path, and the gap is not academic: it let a wrong mirror eigenvalue in a downstream example look like a solver fault for some time. The distinction a mode monitor adds is that its eigenvalue is not always +1. A mirror in y maps y -> -y and also flips the sign of y-components, so a mode with Ey even in y has eigenvalue -1. Declaring the wrong one does not fail; it projects onto the orthogonal sector and quietly returns a different answer. Here Ez is even, so +1 is right, and the tests assert what must then hold. Three properties: the objective is unchanged by declaring the symmetry; the gradient matches a finite difference under it; and the *folded* gradient matches the unsymmetrised one. The fold is the part worth stating -- the raw gradient is not invariant, because Meep reads epsilon only on y >= 0, so the raw result comes back doubled above the plane and zero below it.
smartalecH
force-pushed
the
test/adjoint-mode-monitor-symmetry
branch
from
September 4, 2026 17:42
25588b9 to
95c2bf8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test_adjoint_symmetry.py(added earlier in this stack) exercisesFourierFieldsonly.EigenmodeCoefficientreaches the adjoint through a different path, and the gap is not academic — it let a wrong mirror eigenvalue in the example at the top of this stack look like a solver fault for some time.What a mode monitor adds is that its mirror eigenvalue is not always +1. A mirror in y maps
y -> -yand flips the sign of y-components, so a mode whose Ey is even in y has eigenvalue −1. Declaring the wrong one does not fail; it projects onto the orthogonal sector and quietly returns a different answer. In the 3D grating coupler that showed up as a mode coefficient 1.51x the unsymmetrised one and a design gradient 16.8x too large against a converged finite difference.Here Ez is even about the plane, so +1 is the right eigenvalue, and the tests assert what must follow:
The fold is the part worth stating. The raw gradient is not invariant: Meep evaluates epsilon only on
y >= 0, so weights below the plane are inert and one above it drives both halves, and the raw result comes back doubled above the plane and zero below. Folding the halves together recovers the derivative with respect to a variable that owns both mirrored cells. Getting that wrong is what makes the correct behaviour look like a bug.