Skip to content

Reconstruct in-layer E_x from the continuous D_x series on 1D TM and conical - #103

Merged
yonghakim merged 1 commit into
mainfrom
claude/rcwa-circular-polarization-843042
Oct 27, 2026
Merged

yonghakim merged 1 commit into
mainfrom
claude/rcwa-circular-polarization-843042

Conversation

@yonghakim

Copy link
Copy Markdown
Contributor

What

solver.reconstruct_field(..., discontinuous='continuity') reconstructs E_x inside a patterned layer by summing the Fourier series of eps E_x (continuous across every wall) and dividing by eps at each sample. This is the near-field rule of Lalanne & Jurek (J. Mod. Opt. 45, 1357, 1998). RETICOLO's res3 applies it (champ=1). The default, 'fourier', is unchanged.

Scope in this PR: 1D TM and conical, raster structures, through reconstruct_field.

How

  • 1D TM (field_1d): V = epx^-1 W q, so D_x = W q u with no inverse.
  • Conical (_field_coupled): D_x = i Ky U_z + [V_21 V_22] q (a+ + a-). The z-derivative sign follows the kernel's z, which runs into the stack.
  • Engine: _continuity_rows reads eps at each sample column of the raster. Uniform layers are skipped.
  • Refusals: 2D gratings, shape structures, tensor materials and merged field state are each refused by name (NotImplementedError).

Evidence

  • RETICOLO goldens: the 1D TM and conical field goldens now match on every slot, E_x included, at a 1e-12 tolerance. Measured errors are 3.6e-14 and 6e-14. The default sum is 7e-2 to 1e-1 off on those slots. The existing tests for the default keep their exceptions, with the cause now explained.
  • New tests/rcwa/test_field_continuity.py (15 tests):
    • eps E_x is continuous across every wall, from both incidence sides. Reading the wrong layer's eps breaks this by 0.75.
    • Every other component, and every uniform layer, is bit-identical to the default. TE is unchanged.
    • Explicit sample points reproduce the count grid.
    • JAX and torch match NumPy.
    • The gradient through raster values matches a central difference.
    • Unsupported cases raise the refusals.
  • Field-related suite (94 files, excluding slow and research), run locally: all pass except test_canary_inductor_compiles_the_eye_write_in_order. That test fails on clean main too (torch 2.13 inductor).
  • Docs contract test: passes.

Docs

  • docs/guide/rcwa/fields.md: new section, "Normal components inside a patterned layer".
  • tests/references/README.md: the champ=0/1 question is marked resolved.

Not yet

  • The result API (field) door.
  • 2D line-wise rule.
  • NVF / shape structures.

🤖 Generated with Claude Code

…conical

reconstruct_field(discontinuous='continuity') sums the Fourier series of
eps E_x, which is continuous across the walls of a patterned layer, and
divides by eps at each sample (Lalanne & Jurek, J. Mod. Opt. 45, 1357,
1998). The plain Fourier sum of E_x rings at every wall at any truncation;
this is the near-field rule RETICOLO's res3 applies (champ=1).

- 1D TM: D_x = W q u needs no inverse, since V = epx^-1 W q.
- Conical: D_x = i Ky U_z + [V_21 V_22] q (a+ + a-), with the z-derivative
  sign fixed by the kernel's z running into the stack.
- The engine reads eps per sample column from the raster; uniform layers
  and every other component stay bit-identical to the default.
- 2D gratings, shape structures, tensor materials and merged field state
  are refused by name.

The RETICOLO 1D TM and conical field goldens now match on every slot,
E_x included, to 1e-12 (measured 3.6e-14 and 6e-14), where the default
sum is 7e-2 to 1e-1 off. A label-free test checks eps E_x continuity
across every wall from both incidence sides. The default ('fourier') is
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yonghakim
yonghakim merged commit d422a6e into main Oct 27, 2026
56 checks passed
@yonghakim
yonghakim deleted the claude/rcwa-circular-polarization-843042 branch October 27, 2026 06:53
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