Skip to content

[13/14][Adjoint Module] Cover mode monitors under a mirror symmetry - #3301

Draft
smartalecH wants to merge 1 commit into
feat/adjoint-pade-dftfrom
test/adjoint-mode-monitor-symmetry
Draft

[13/14][Adjoint Module] Cover mode monitors under a mirror symmetry#3301
smartalecH wants to merge 1 commit into
feat/adjoint-pade-dftfrom
test/adjoint-mode-monitor-symmetry

Conversation

@smartalecH

Copy link
Copy Markdown
Collaborator

test_adjoint_symmetry.py (added earlier in this stack) exercises FourierFields only. EigenmodeCoefficient reaches 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 -> -y and 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 objective is unchanged by declaring the symmetry;
  • the gradient matches a finite difference under it;
  • the folded gradient matches the unsymmetrised one.

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.

@smartalecH
smartalecH marked this pull request as draft September 4, 2026 16:55
@smartalecH
smartalecH force-pushed the test/adjoint-mode-monitor-symmetry branch from 34ef4a4 to 25588b9 Compare September 4, 2026 17:32
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
smartalecH force-pushed the test/adjoint-mode-monitor-symmetry branch from 25588b9 to 95c2bf8 Compare September 4, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant