Skip to content

feat(rcwa): z-varying geometry and materials — ProfiledLayer, Graded, Bruggeman, automatic z slicing - #224

Merged
yonghakim merged 7 commits into
mainfrom
claude/sweet-thompson-v8n1to
Nov 25, 2026
Merged

yonghakim merged 7 commits into
mainfrom
claude/sweet-thompson-v8n1to

Conversation

@yonghakim

@yonghakim yonghakim commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Summary

RCWA layers are uniform in z. Until now a sloped or rounded sidewall, a graded film or a mixed interface had to be sliced by hand ("the slice count is yours to choose"). This adds layers whose cross-section and material change with height. Wavebit slices them itself, reports the staircase error in z, and every parameter differentiates. Together they are the z-direction model OCD and ellipsometry fitting need: sidewall angle, top rounding, footing/undercut, roughness and interface layers.

New public names. These are additive only; no existing layer or shape result changes name or meaning.

Name What it is
rcwa.ProfiledLayer(thickness, background, regions) a layer whose regions and materials may change with height; solved as internal slices, reported as one public layer
rcwa.Trapezoid(cd, swa, top_rounding, footing, center, cd_at) a y-invariant line's x–z cross-section; each slice → Rectangle (closed form)
rcwa.Loft(bottom, top) / rcwa.Profile(section) an outline interpolated linearly in z / any z -> vertices; each slice → Polygon (painting route)
rcwa.Graded(material, relative=False), Graded.interface(below, above, fraction) a material that changes with height, for a ProfiledLayer's background or regions; interface is a Bruggeman mixing layer
wavebit.materials.Bruggeman(host, inclusion, fraction) two-phase Bruggeman effective medium, a material model like Drude; roughness = one uniform layer of it
rcwa.Slicing(count, rule, tolerance, min_count, max_count, estimate) via Numerics(slicing=...) slice count ('auto' doubles until the Richardson estimate meets tolerance), 'arclength' (default) or 'uniform'
rcwa.diagnostics.SlicingWarning 'auto' stopped at max_count short of tolerance

Conventions (confirmed by the maintainer before implementation)

  • SWA. The angle between base and sidewall, measured inside the material, in radians. pi/2 is vertical, < pi/2 a taper, > pi/2 an undercut, and a (left, right) pair is allowed. Walls are offset by (z - z_cd)·tan(pi/2 - swa), exactly zero at pi/2.
  • cd. Measured on the straight walls at cd_at ('bottom', 'middle' or 'top'). top_rounding is a convex arc and footing a concave fillet, both tangent (C¹).
  • Slice boundaries. Fractions of the thickness, fixed at prepare; derivatives are those of one fixed staircase.
  • Diagnostics. result.diagnostics['z_slicing'] has one entry per public layer; validity.checks['z_slicing_converged'] is set under 'auto'.
  • Height-independent layers. A layer identical at every height is solved as one layer, bitwise the ordinary layer, unless its geometry carries a derivative.
  • Bruggeman root. The passive root is chosen in conventions.bruggeman_root.
  • Refusals. The raster path is refused (layer.profile_raster). A profile shape or a Graded material outside a ProfiledLayer is refused (layer.profile_geometry, layer.profile_material, stack.graded_half_space).

Design. The private src/wavebit/rcwa/_profile.py lowers each ProfiledLayer to ordinary layers before preparation, and Prepared keeps one inner preparation per sliced layout. There are no engine changes, so every backend, factorization and derivative rule applies as written.

Pre-registered checks (criteria fixed before measuring; none loosened)

Criterion Measured
(a) vertical, unrounded Trapezoid ≡ Rectangle layer; equal-outline Loft ≡ Polygon layer, bitwise; traced SWA at pi/2 within 1e-12 bitwise (Li and default NVF, all cd_at, off-centre); traced < 1e-12
(b) observed order in [1.8, 2.2] on a straight taper (TE/TM); ≥ 1.8 on a rounded profile, arc-length slicing 2.000 / 1.999; rounded 1.89–2.07 (uniform falls to 1.35–1.48, recorded)
(c) AD vs central difference on the same preparation ≤ 1e-6 rel. cd, swa, top_rounding, footing, height 2.4e-10 … 3.8e-9; roughness thickness 3.7e-10, volume fraction 2.1e-9, interface thickness 6.4e-10; JAX within bound
(d) same staircase vs RETICOLO V10 ≤ 1e-10; 'auto' within tolerance of RETICOLO's extrapolated limit 3.5e-14 worst (16 cases); 2.9e-5 … 7.3e-5 vs 1e-4
(e) graded and effective-medium films vs closed forms ≤ 1e-6 in the fine-slice limit linear grading vs the exact Airy solution 3.3e-7 at 512 slices (order 2.0001); roughness vs thin-film formula 3e-16; graded interface vs 20 000-sublayer characteristic matrix 5.7e-8
(f) numpy / torch / jax ≤ 1e-12 within
(g) raster refusal fires at run and check fires, with the raster layer's path

The RETICOLO golden (tests/references/golden_reticolo_taper.npz, with provenance record) was generated with Octave 8.4.0 from the V10 Zenodo archive. Its staircase comes from an independent geometry construction, and the generator ran with Wavebit's import blocked.

Performance (measured; no engine change)

Measurements per slice on 4 CPU cores at 31 orders:

Path Cost
NumPy or PyTorch, factorization='li' 12 ms
default NVF 1.26 s, 87% the shape normal field
eager JAX 166 ms
jax.jit with the default exceptional-point handling ~30 s compile, ~0.5 s per call, 0.6–1 GB
jax.jit with exceptional_points='off' 4 slices: 6.3 s compile, 72 ms per call, 0.54 GB

Hand-written layers cost the same, so none of this comes from the slicing.

Batching the slices' eigensolves was measured and not done. The eigensolves are 22% of a run, and a batch saves 1.0–1.2× on NumPy (slower at 242×242) and up to 1.9× on PyTorch. That is at most a tenth of a run, for a restructured per-layer loop. The guide recommends 'li' for lines and says when 'off' is the fast choice under jit. No GPU was available.

Commits

  1. feat(rcwa): ProfiledLayer, Trapezoid/Loft/Profile, Slicing, _profile.py, lifecycle wiring, SlicingWarning, tests.
  2. test(references): RETICOLO tapered-line golden, generator, cases, test.
  3. docs: profiled-layers guide and validation (English + Korean, figures), "Limits of RCWA" rewrite, references, examples/rcwa/tapered_line_swa.py.
  4. feat: Graded, Graded.interface, wavebit.materials.Bruggeman, root rule, tests.
  5. docs: materials that change with height, effective media, (e) results, refusal-code table (English + Korean).
  6. docs(rcwa): measured costs, and why the slices are not batched.
  7. examples: film_roughness_interface.py (oxide film with roughness and a graded interface, checked against an independent characteristic matrix).

Local validation (head 213b698, rebased on 660664a)

  • python tools/run_verification.py --profile quick: 17 passed.
  • ruff check . clean.
  • Related suites: 730 passed, 1 skipped. These cover profiled-layer, graded-materials, Bruggeman, RETICOLO-taper, docs-contract, reference-record, pinned-public-API, jobs and unified RCWA tests.
  • Earlier on this branch: full tests/api 2355 passed; test_polygon_region 119 passed; slow tiers passed.
  • Sphinx -W English and Korean builds are clean.
  • Examples run in 2 s and 16 s.

https://claude.ai/code/session_01MiXWYrCNRHseS7CwjV5b4Q


Generated by Claude Code

@yonghakim
yonghakim marked this pull request as ready for review November 18, 2026 08:46
@yonghakim
yonghakim marked this pull request as draft November 24, 2026 16:36
@yonghakim
yonghakim force-pushed the claude/sweet-thompson-v8n1to branch from f5f3664 to efd25e6 Compare November 24, 2026 17:32
…z slicing

Add rcwa.ProfiledLayer with three height-dependent region shapes:
Trapezoid (a y-invariant line: cd, swa, top_rounding, footing, center,
cd_at), Loft (an outline interpolated linearly from bottom to top) and
Profile (section(z) -> vertices). rcwa.Numerics(slicing=rcwa.Slicing(...))
chooses the slices: count='auto' doubles from min_count until the
Richardson estimate of the staircase error in the efficiencies meets
tolerance; rule='arclength' (default) places boundaries at equal steps
of the sidewall's arc length, 'uniform' at equal thicknesses.

The private _profile module lowers each ProfiledLayer to ordinary
layers before preparation -- a Trapezoid slice is a Rectangle on the
closed-form route, a Loft or Profile slice a Polygon on the painting
route -- so no engine code changes and every backend, derivative and
factorization rule applies as written. Slice boundaries are fractions
of the thickness fixed at prepare; a run moves only the thickness and
widths, so derivatives are those of one fixed staircase. SWA is in
radians, pi/2 vertical; a wall is offset by (z - z_cd)*tan(pi/2 - swa),
exactly zero at pi/2, and a layer the same at every height is solved
as one layer -- bit for bit the Rectangle/Polygon layer -- unless its
geometry carries a derivative.

result.diagnostics['z_slicing'] reports count, fractions, merged,
staircase_error, observed_order and levels per public layer; validity
gains z_slicing_converged under count='auto', and SlicingWarning marks
a count stopped at max_count. A raster layer beside a ProfiledLayer is
refused (layer.profile_raster); a profile shape in a Layer is refused
(layer.profile_geometry); sample_structure and operators.assemble
refuse a profiled layer by name. Existing layer and shape results keep
their names and meaning.

Pre-registered checks in tests/rcwa/test_profiled_layer.py: (a) bitwise
equality at a vertical wall, (b) observed order 2.000 TE / 1.999 TM on a
straight taper and >= 1.8 (1.89-2.07) on a rounded profile under
arc-length slicing, (c) AD vs central differences 2.4e-10 to 3.8e-9,
(f) numpy/torch/jax within 1e-12, (g) the raster refusal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MiXWYrCNRHseS7CwjV5b4Q
golden_reticolo_taper.npz holds RETICOLO's efficiencies for a straight
taper and an asymmetric rounded line with a footing (lossy silicon-like
line on fused silica, TE/TM, 0 and 20 degrees, 31 orders): the same
uniform staircase at 8 and 32 slices, and 64/128/256 slices for
Richardson extrapolation. The staircase is built by
_reticolo_taper_cases.py from its own geometry (offset-line circle
centres), not the solver's slicer, and the generator ran with Wavebit's
import blocked, driving interface/reticolo_res2.m directly.

Measured: 3.5e-14 worst on the same staircase (bound 1e-10); the
automatic slice count within 2.9e-5 to 7.3e-5 of the extrapolated
profile (bound: the 1e-4 slicing tolerance). Provenance record
included; README oracle table row added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MiXWYrCNRHseS7CwjV5b4Q
Add guide/rcwa/profiled-layers (shapes, SWA convention table, how the
layer is sliced and how to choose the count, the report, why the
region path and not a raster, cost, derivatives) and
validation/rcwa/profiled-layers (pre-registered criteria and results,
convergence orders by rule, the RETICOLO reference, cost), each with a
Korean overlay and figures in both languages. Rewrite the 'Limits of
RCWA' sidewall item in getting-started/overview, which said the slice
count is the user's to choose, and add a Korean overlay of that page.
List the new names in the keyword and API references, the numerics
guide, the indexes and the source map, and change each of those pages'
Korean overlay with it. The Korean overview keeps the translation main
already carries and gains the two changed items. Add profiled layer,
slice, sidewall angle and arc length to docs/locales/ko/GLOSSARY.md.

Add examples/rcwa/tapered_line_swa.py: reflection spectra of a tapered,
rounded silicon line over its sidewall angle, checking the power
balance, the reported staircase error and a vertical wall against the
Rectangle layer bit for bit.

Richardson (1911), Popov et al. (2002) and Hugonin & Lalanne
(arXiv:2101.00901) are cited where their ideas are used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MiXWYrCNRHseS7CwjV5b4Q
…layers

Add wavebit.materials.Bruggeman(host, inclusion, fraction), a material
model like Drude or TabulatedMaterial: the two-phase symmetric
Bruggeman rule with spherical inclusions (Bruggeman, Ann. Phys. 416,
636 (1935)), evaluating both constituents at each wavelength, so
dispersive and tabulated constituents and nested mixtures work. The
passive root of 2e^2 - b e - eps_a eps_b = 0 is chosen in
conventions.bruggeman_root by its imaginary part (the real part between
two real roots), independent of the square-root branch. The fraction
differentiates on PyTorch and JAX; magnetic or tensor constituents are
refused (material.mixture), a fraction outside [0, 1] too
(material.fraction). It is not re-exported at the top level: the list
of duplicate public paths may only shrink.

Add rcwa.Graded(material, relative=False): a callable height ->
material model for the background or a region of a ProfiledLayer;
each slice takes the material at its midpoint, and relative=True reads
u = z / thickness. Graded.interface(below, above, fraction) is a
Bruggeman mixing layer, linear by default. A grading is sliced
uniformly; a constant grading merges to one layer like a
height-independent outline. Graded in an rcwa.Layer is refused
(layer.profile_material), as a half-space too (stack.graded_half_space).

Pre-registered checks (tests/rcwa/test_graded_materials.py,
tests/materials/test_bruggeman.py): (e) a linearly graded film against
the exact Airy-function solution, 3.3e-7 at 512 slices (bound 1e-6),
observed order 2.0001; a roughness layer against the thin-film
formula, 3e-16; a graded interface against a 20 000-sublayer
characteristic matrix, 5.7e-8. (c) AD vs central differences on the
same preparation: roughness thickness 3.7e-10, fraction 2.1e-9,
interface thickness 6.4e-10. (f) torch/jax within 1e-12. Bruggeman:
mixing-equation residual < 1e-14, numpy.roots within 1e-13, phase
symmetry, exact limits, per-wavelength Drude constituent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MiXWYrCNRHseS7CwjV5b4Q
Add 'Materials that change with height' to the profiled-layers guide
(rcwa.Graded, Graded.interface, a Bruggeman roughness layer, slicing
and derivatives) and 'Effective media' to the materials guide; record
check (e) and the new derivative and Bruggeman checks in the
validation page; list Graded and Bruggeman in the keyword, RCWA and
shared API references. Add the refusal codes of both pieces to the
keyword page's code table (layer.profile_*, numerics.slicing,
operators.profiled_layer, shape.profile*, stack.graded_half_space,
structure.profiled_layer, material.fraction/mixture/graded), which
the profiled-layers commit left out. Each page's Korean overlay
changes with it; headings linked by slug stay in English; 'effective
medium' joins the glossary. Bruggeman (1935) and Aspnes, Theeten and
Hottier (1979) are cited where the ideas are used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MiXWYrCNRHseS7CwjV5b4Q
…not batched

Measure what a sliced line costs per slice on each backend (4 cores,
31 orders): 12 ms on NumPy and PyTorch under Li, 1.26 s under the
default NVF (87% the shape normal field), 166 ms on eager JAX once
warm. Under jax.jit with the default exceptional-point handling a
value and gradient compile in ~30 s per slice and run in ~0.5 s per
slice at 0.6-1 GB each; with exceptional_points='off' four slices
compile in 6.3 s and run in 72 ms at 0.54 GB. Hand-written layers cost
the same, so none of this is the slicing's.

Batching the slices' eigensolves was measured and not done: they are
22% of a run, and a batch of 32 62x62 problems saves 1.2x on NumPy
(none at 128, slower at 242x242) and 1.9x on PyTorch, at most a tenth
of a run, for a restructured per-layer loop. The guide now gives the
measured costs, replaces the earlier '4 s per layer' for eager JAX
(a first-run warm-up), and says when exceptional_points='off' is the
fast choice for a fit under jit. No GPU was available.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MiXWYrCNRHseS7CwjV5b4Q
examples/rcwa/film_roughness_interface.py: silicon, a 2 nm linear
oxide-silicon interface (rcwa.Graded.interface, 16 slices), 100 nm of
oxide and 3 nm of Bruggeman roughness (oxide, 50% void) at 70 degrees;
prints Rs and Rp with and without the two thin layers and checks the
full stack against an independent characteristic-matrix calculation
of the same layers (Born and Wolf, sec. 1.6), to 1e-10, in about 2 s.
The profiled-layers guide links it, in English and Korean.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MiXWYrCNRHseS7CwjV5b4Q
@yonghakim
yonghakim force-pushed the claude/sweet-thompson-v8n1to branch from efd25e6 to 213b698 Compare November 25, 2026 03:05
@yonghakim yonghakim changed the title feat(rcwa): ProfiledLayer — sidewall angles, rounding and automatic z slicing feat(rcwa): z-varying geometry and materials — ProfiledLayer, Graded, Bruggeman, automatic z slicing Nov 25, 2026
@yonghakim
yonghakim marked this pull request as ready for review November 25, 2026 03:06
@yonghakim
yonghakim merged commit c07aa07 into main Nov 25, 2026
68 checks passed
@yonghakim
yonghakim deleted the claude/sweet-thompson-v8n1to branch November 25, 2026 05:22
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.

2 participants