Repository navigation
Releases
SPECTRA-RCWA 1.6.2
Changed (times on an RTX 5090 in complex64, against 1.6.1 on the same card)
- Thick layers next to each other hand their reflection matrix over directly, without an admittance and an inverse in between: 4 layers of 0.8 µm take 49 ms instead of 63 for value and gradient (9 solves at 338 x 338).
- The topmost step of a thin layer is solved for its two right-hand sides only, and the first step uses that the admittance of the substrate is block diagonal: a 0.25 µm layer takes 12.5 ms instead of 15, a 0.05 µm layer 8.8 ms instead of 11.6. The 144 solves of the 0.25 µm benchmark take 0.174 s (value) and 0.194 s (value and gradient) instead of 0.207 and 0.227.
solveof a JSON problem treats uniform layers in closed form per order (ColorRouterForward.uniform_block): a grating on a 2 µm spacer takes 29 ms instead of 56 at 578 x 578, one between two films 47 ms instead of 74.- The check before a solve no longer loops over the orders in Python, wavelengths with the same permittivities share their permittivity matrices, and a solve without a gradient keeps fewer matrices.
Results change within rounding. A single 0.8 µm layer of 144 solves is as fast as before in complex64. In complex128 it is as fast as before as well: on the RTX 5090 each version takes about 8.0 or 8.2 to 8.4 s depending on what was allocated earlier in the process, and the two versions differ by less than 1 % on an RTX 3060 and an RTX 4090.
pip install -U spectra-rcwa
SPECTRA-RCWA 1.6.1
Changed
- Large single solves are 1.8 to 2.3 times faster on an RTX 5090 (one wavelength and direction; value: 5.07 to 2.20 s at 7442 x 7442 matrices, 1.59 to 0.71 s at 4802, 188 to 105 ms at 2178) and a single solve at 578 takes 24 ms instead of 36: one product of large complex64 matrices runs as three real ones, and the LU and the inverse of one matrix, or of a few large ones, in cuSOLVER. They need about a fifth more GPU memory. The batch of 144 solves is as fast as before.
- complex128 products on a GeForce GPU run as three real ones: 7 % less time for the 144 solves in complex128 on an RTX 5090.
Results change within rounding.
pip install -U spectra-rcwa
SPECTRA-RCWA 1.6.0
Added
factorization="normal"(SolverConfig, andfactorizationof a problem): the in-plane permittivity of a crossed grating from a smooth normal tensor of the pattern, with the adjoint gradient, on any lattice. On a silicon pillar the largest efficiency error is 4.3e-3 at 394 x 394 matrices, against 6.3e-2 with the Laurent rule, which reaches 1.6e-2 at 3586 x 3586. On a freeform pattern with small features the well responses and the gradient were not more accurate at the same orders. The default stays Laurent.- The wells of the colour router with circular orders (
Stack(truncation="circular")). At 9 circular orders (506 x 506) value and gradient of the benchmark problem take 172 ms on an RTX 5090, against 270 ms at 8 rectangular orders (578 x 578) on the same machine; the errors of the well responses against a larger computation are 9.0e-4 and 7.7e-4.
Changed
- A layer goes through its S-matrix from 5 steps on instead of 7 (
block_from_steps), with a thin step of up to 6.5 (block_step_phase). Layers of 5 or 6 steps are up to 25 % faster, and the single-precision gradient of two 0.6 um silicon layers is off by 5e-5 instead of 6e-4. Results change within rounding. - The block inverse ends in a Gauss-Jordan kernel instead of cuBLAS: 6 % faster at 578, 16 % at 226.
Results with the default settings change within rounding only.
pip install -U spectra-rcwa
SPECTRA-RCWA 1.5.0
Added
- Oblique lattices:
lattice_angle_degof a problem and ofStack, the angle between a1 = (period_x, 0) and a2 (60 or 120 with equal periods is hexagonal). Disks, rectangles, lamellar stripes and pixel arrays have exact Fourier coefficients there too; efficiencies, gradients and the convergence in the orders work as on a rectangular lattice. A hexagonal lattice needs fewer orders than its rectangular supercell: for an array of index 2 pillars, 254 x 254 matrices against 546 x 546 at about the same error, 3 to 5 times faster on a GPU. truncation: "rectangular" or "circular" orders; "auto" keeps a rectangle at 90 degrees, as before, and a circle otherwise, so a hexagonal pattern keeps its symmetry.- The example
hexagonal_pillars.
Not on an oblique lattice: 1D gratings, Li's rules, and the wells of the colour router.
Fixed
convergencewith atolerancetook the start-up of the GPU kernels in the first solve for its cost, and stopped with "max_seconds reached" too early.
Results at 90 degrees are unchanged.
pip install -U spectra-rcwa
SPECTRA-RCWA 1.4.0
Added
convergence_in_orders/problem.convergencetake atolerance: the orders grow by 1.5x until the last two changes and an error estimated from them are below it. The result hasconverged,fourier_orders,estimated_errorand, if it stops short, thereason.- Patterns
arrayandnpytakepixels: true: constant over rectangular pixels of any number, with exact Fourier coefficients, also in the gradient.
Changed
problem.solve(and the command line and MCP server) uses exact Fourier coefficients for lamellar layers (with Li's rule in a 1D grating) and, in a crossed grating, for rectangles and disks, so it no longer depends ongridthere. Sampled edges moved by up to one sample: at 512 samples a lamellar grating of fill factor 0.3 was off by up to 6e-3, and these efficiencies change by that.- The change reported by
convergenceis over all efficiencies instead of over the orders of the first truncation. - The default
gridgrows with the orders above 127. A rectangle or disk with orders along one axis only gets a warning.
Arrays without pixels, the gradient with respect to the density of the shapes, and the Python classes are as before. The paper is at arXiv:2611.30305.
pip install -U spectra-rcwa
SPECTRA-RCWA 1.3.1
Fixed
convergence_in_orders/problem.convergence: the default orders repeated or went down when an axis started at 1 or 2 orders (2, 4, 4 and 1, 3, 2), so the last change could be 0 without convergence. They now increase at every step: the problem's orders, 1.5x and 2x.- It solves every truncation on one grid, large enough for the largest, and returns that grid. Before, a coarse
gridgrew with the orders and its error mixed into the change, and more than 63 orders on the default grid raised an error. - An
orders_listthat starts below the problem's orders no longer raises a KeyError. - The change is described as an estimate of the truncation error, not a bound.
The solver is unchanged: efficiencies, fields and gradients are the same as in 1.3.0.
pip install -U spectra-rcwa
SPECTRA-RCWA 1.3.0
Changed
- 1D gratings (one of
fourier_orders0) build the in-plane permittivity matrices by Li's inverse rule. TM efficiencies of a lamellar grating now converge like the TE ones: within 1e-4 at 20 orders, where the Laurent rule still moved by 3e-4 between 80 and 160 orders. - Crossed gratings keep the Laurent rule by default, so their results do not change.
SolverConfig(factorization=...)picks"auto"(default),"li"(Li's rules also for crossed gratings) or"laurent"(the 1.2.0 behaviour). - The adjoint gradient handles E_xx != E_yy (checked against autograd to 5e-15 and finite differences to 3e-10; complex64 on CUDA within 2e-6 of complex128).
Fixed
ColorRouterForward(device=None)picked CUDA in complex64 with torch older than 2.8, which cannot compile the kernels; it now falls back to the CPU there.
pip install -U spectra-rcwa
SPECTRA-RCWA 1.2.0
1.2.0 (2026-11-23)
Added
spectra_rcwa.problem: grating problems as JSON (lattice, orders, wavelengths, incidence, media, layers with patterns), checked before solving,
with efficiencies of every order for p and s incidence, gradients of one order's efficiency, and convergence in the orders.- The command
spectra-rcwa(info,example,check,solve,mcp) and an MCP server with seven tools (optional dependencymcp). - AGENTS.md, CLAUDE.md, llms.txt, llms-full.txt, CITATION.cff, a Claude Code plugin (
plugins/spectra-rcwa), package keywords and links. benchmarks/bench_synthetic.py: a benchmark of the README's size on a synthetic freeform pattern, with nothing outside this package.
Removed
- The
cr_itd_v2adapter and the benchmark scripts that needed external colour-router code and data. Their measurements stay inbenchmarks/results/.
No solver code changed.