Repository navigation
feat(rcwa): z-varying geometry and materials — ProfiledLayer, Graded, Bruggeman, automatic z slicing - #224
Merged
Conversation
yonghakim
marked this pull request as ready for review
November 18, 2026 08:46
yonghakim
marked this pull request as draft
November 24, 2026 16:36
yonghakim
force-pushed
the
claude/sweet-thompson-v8n1to
branch
from
November 24, 2026 17:32
f5f3664 to
efd25e6
Compare
…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
force-pushed
the
claude/sweet-thompson-v8n1to
branch
from
November 25, 2026 03:05
efd25e6 to
213b698
Compare
yonghakim
marked this pull request as ready for review
November 25, 2026 03:06
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.
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 inz, 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.
rcwa.ProfiledLayer(thickness, background, regions)rcwa.Trapezoid(cd, swa, top_rounding, footing, center, cd_at)Rectangle(closed form)rcwa.Loft(bottom, top)/rcwa.Profile(section)z -> vertices; each slice →Polygon(painting route)rcwa.Graded(material, relative=False),Graded.interface(below, above, fraction)ProfiledLayer's background or regions;interfaceis a Bruggeman mixing layerwavebit.materials.Bruggeman(host, inclusion, fraction)Drude; roughness = one uniform layer of itrcwa.Slicing(count, rule, tolerance, min_count, max_count, estimate)viaNumerics(slicing=...)'auto'doubles until the Richardson estimate meetstolerance),'arclength'(default) or'uniform'rcwa.diagnostics.SlicingWarning'auto'stopped atmax_countshort oftoleranceConventions (confirmed by the maintainer before implementation)
pi/2is vertical,< pi/2a taper,> pi/2an undercut, and a(left, right)pair is allowed. Walls are offset by(z - z_cd)·tan(pi/2 - swa), exactly zero atpi/2.cd. Measured on the straight walls atcd_at('bottom','middle'or'top').top_roundingis a convex arc andfootinga concave fillet, both tangent (C¹).prepare; derivatives are those of one fixed staircase.result.diagnostics['z_slicing']has one entry per public layer;validity.checks['z_slicing_converged']is set under'auto'.conventions.bruggeman_root.layer.profile_raster). A profile shape or aGradedmaterial outside aProfiledLayeris refused (layer.profile_geometry,layer.profile_material,stack.graded_half_space).Design. The private
src/wavebit/rcwa/_profile.pylowers eachProfiledLayerto ordinary layers before preparation, andPreparedkeeps 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)
cd_at, off-centre); traced < 1e-12'auto'within tolerance of RETICOLO's extrapolated limitrunandcheckThe 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:
factorization='li'jax.jitwith the default exceptional-point handlingjax.jitwithexceptional_points='off'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 underjit. No GPU was available.Commits
feat(rcwa):ProfiledLayer,Trapezoid/Loft/Profile,Slicing,_profile.py, lifecycle wiring,SlicingWarning, tests.test(references): RETICOLO tapered-line golden, generator, cases, test.docs: profiled-layers guide and validation (English + Korean, figures), "Limits of RCWA" rewrite, references,examples/rcwa/tapered_line_swa.py.feat:Graded,Graded.interface,wavebit.materials.Bruggeman, root rule, tests.docs: materials that change with height, effective media, (e) results, refusal-code table (English + Korean).docs(rcwa): measured costs, and why the slices are not batched.examples:film_roughness_interface.py(oxide film with roughness and a graded interface, checked against an independent characteristic matrix).Local validation (head
213b698, rebased on660664a)python tools/run_verification.py --profile quick: 17 passed.ruff check .clean.tests/api2355 passed;test_polygon_region119 passed; slow tiers passed.-WEnglish and Korean builds are clean.https://claude.ai/code/session_01MiXWYrCNRHseS7CwjV5b4Q
Generated by Claude Code