Two Linear Algebra Stacks, What Survived, and What Failed in Practice
Why nyx carried duplicate linear-algebra stacks, which older solvers beat generic replacements in benchmarks, and what unused methods remain on the shelf.
For a short stretch during the restructure documented in ADR 0008, femcore carried two largely complete sparse linear-algebra stacks side by side. The original modules — sparse, csparse, linalg, amg, eigen, and lobpcg — had grown directly alongside the physics kernels, with separate real and complex matrix types and exposed usize buffers. Beside them sat femsolve, a clean-room BSD-2-Clause solver library developed in an isolated working session with generic real and complex scalars, Krylov–Schur restarts, smoothed-aggregation multigrid, and fixed-chunk parallel reductions.
Merging femsolve into femcore::linalg::driver (ADR 0033) retired the duplicate sparse matrix types, yet it did not mean deleting every piece of the original stack. Once the ported solvers were measured against real physics problems instead of synthetic test matrices, three older choices stayed in service because numbers beat architectural neatness.
The Three Older Pieces That Survived
1. Real Block Arnoldi (arnoldi_real) for Lossless Optical Waveguides
In a lossless 2D waveguide with tilted crystal anisotropy or a real cross-section, the eigenvalue pencil is real and non-symmetric. When the driver initially routed those solves through the library’s Krylov–Schur eigensolver, complex arithmetic was used everywhere because the library lacked a real Schur decomposition with 2×2 blocks. On real non-normal waveguide pencils, that complex shift introduced spurious imaginary parts of 1e-8 to 1e-5 relative magnitude, preventing large meshes from reaching tolerance.
nyx therefore kept arnoldi_real::eigs_general from the original eigen.rs behind the driver::eigs_general entry point. A real Ritz matrix keeps real eigenvalues at exact zero imaginary part while legitimate leaky or complex-$\beta$ modes appear as conjugate pairs. Rather than silently discarding complex roots as simple real solvers sometimes do, eigs_general flags any converged mode satisfying $|\mathrm{Im},\theta| > 10,\mathrm{tol},|\theta|$ inside the nev + 2 window, sets complex_found, and lets nyx-ems rerun the cross-section in the full complex solver (modes_complex).1.Contract test a_converged_complex_pair_of_a_real_pencil_is_reported_and_never_dropped in crates/femcore/tests/linalg_contract.rs pins this behaviour so no update quietly drops physical complex waveguide pairs.
2. The Original Elasticity Multigrid (amg_elastic)
Smooth-aggregation algebraic multigrid for solid mechanics differs subtly from scalar Laplacian multigrid: coarse spaces must preserve all six rigid-body translations and rotations in 3D, smooth P2 quadratic systems through a P1 first coarse level, and run Chebyshev polynomial smoothing with single-precision inner-cycle storage (Csr32). Because nyx’s existing amg.rs already hit 3.1 to 2.8 s on 3D solid benchmarks and 33.7 s on baseline 3D eigenproblems, it was moved intact into femcore::linalg::amg_elastic rather than rewritten.
3. Column-Parallel Complex Solves (par_solve_min_n = 5000)
The ported solver library defaulted all triangular back-substitutions to Sequential after its authors observed faer 0.24.4 taking ~1.4 s for parallel multi-right-hand-side solves versus 12 ms sequentially on a 64,000-unknown scalar test. Yet the original complex waveguide solver (csparse::CSolver::solve_many) had done something different: instead of calling a parallel BLAS-3 multi-RHS triangular kernel, it dispatched independent sequential column solves against one shared LU factorisation across rayon worker threads once unknowns exceeded 5,000.
Benchmarking a P2 waveguide with PML up to 35,465 unknowns confirmed the original heuristic (ADR 0033): strict sequential solves ran at 1.033 s, roughly 7% slower than the old stack at 0.963 s, whereas column-parallel dispatch recovered to 0.914 s while keeping identical effective indices to six digits (NYX_PAR_SOLVE_MIN_N controls the threshold).
Where Elegant Ideas Lost to Measurement
Moving the solvers behind one facade exposed places where textbook expectations failed on real discretisations:
- Nested dissection lost to AMD on 3D elasticity (
FillOrdering::Auto): The library’sAutoheuristic runs a second symbolic analysis with nested dissection and chooses whichever ordering produces fewer factor nonzeros. On scalar 3D Laplacians this cut fill by 30%, yet on 205,479-unknownP23D solid elasticity under parallel Cholesky, AMD beatAutoon both timing runs (4.68 s and 10.92 s vs 13.46 s and 17.78 s).AMDtherefore stayed the default for standard elasticity. - Symmetric indefinite
LBL^H/Sym LBL^Tbroke the 3D EM bottleneck (ADR 0117): Where nested dissection struggled on elasticity, exploiting symmetry transformed 3D $P_2$ Nédélec curl-curl solves. Factorising indefinite Maxwell matrices with unsymmetricCOLAMDLU stored both $L$ and $U$ with off-diagonal fill pivoting. Wiringfaersupernodal Bunch–KaufmanLBL^H(for real-symmetric and Hermitian matrices) andSym LBL^T(for non-conjugate complex-symmetric PML/IBC matrices) guarded by a 1-vector backward residual check (<= 1e-8) reduced factor nonzeros and RAM by 76%–77% and sped up factorisation 4–8× while falling back automatically to LU if any inter-supernode pivot fails. - Thin structures still defeat smoothed-aggregation LOBPCG: Above 80,000 3D unknowns,
Autotries multigrid-preconditionedLOBPCGfor the lowest eigenmodes, probes convergence, and tripsLobpcgOptions::stall_gainon slender two-element-thick shells where smoothed aggregates lock. When it stalls, the driver falls back explicitly to sparse factorisation and records the fallback in the solver log.
What Was Ported Cleanly — and Sits Unused Today
docs/ports/solvers/PROVENANCE.md documents the clean-room origin of femsolve: every algorithm was either rewritten from documented PETSc/SLEPc specifications (without copying source or reading LGPL/CeCILL solvers such as BLOPEX or MUMPS) or derived directly from literature. Several solvers inside femcore::linalg pass their own unit and contract tests yet are not selected automatically by production physics kernels:
ILU/ICC, additive Schwarz (schwarz),fieldsplit,Jacobi–Davidson, contour eigensolvers (contour/nep),Chebyshevpolynomial filtering (chebfsi),ADSH(div) auxiliary-space preconditioning, andBLR/HODLRlow-rank factorisations.- The standalone $P_2$ Nédélec Hiptmair–Xu auxiliary-space Maxwell solver
AmsP2(crates/femcore/tests/linalg/fr16.rs): verified mathematically on 3D curl-curl systems, whilenyx-ems::cavitystays onShiftedFactorization(LBL^H/Sym LBL^T) until large-scale iterative cavity preconditioning is wired in (ADR 0117).
Keeping those routines tested inside femcore::linalg without letting uncalibrated heuristics pick them in user studies keeps failure modes honest and easy to inspect in the solver log.