Skip to content

Wright Omega explicit diode solver with selectable SolverMethod#33

Merged
ajmwagar merged 3 commits intomainfrom
feature/wright-omega-solver
Apr 18, 2026
Merged

Wright Omega explicit diode solver with selectable SolverMethod#33
ajmwagar merged 3 commits intomainfrom
feature/wright-omega-solver

Conversation

@ajmwagar
Copy link
Copy Markdown
Owner

Summary

Replaces Newton-Raphson iteration for diode solving with an explicit Wright Omega / Lambert W closed-form evaluation. Zero iterations, deterministic cycle count, critical for Cortex-M7 real-time guarantees.

  • wright_omega(x) — D'Angelo ω₃ approximation with Halley refinement (< 1e-10 accuracy)
  • explicit_diode_pair() / explicit_single_diode() — WO warm-start + 2 NR correction steps (hybrid for maximum accuracy while keeping deterministic cost)
  • SolverMethod enum on Component trait — NewtonRaphson (default) or WrightOmega
  • solver_hint() — Component-level opt-in, diodes default to WrightOmega
  • DIODE_SOLVER_OVERRIDE — global atomic for runtime/platform-dependent selection (firmware sets WrightOmega on Cortex-M7, desktop can force NewtonRaphson for comparison)

Architecture

The SolverMethod enum is extensible for future use:

  • BJT models: EbersMoll vs GummelPoon
  • Triode models: Koren vs Dempwolf
  • MOSFET levels

Selection priority: global override > component hint > default (NR).

Tests

  • 5 Wright Omega unit tests (known values: ω(0)≈0.567, ω(1)≈1.0, ω(-1)≈0.278, large/negative)
  • 2 explicit diode pair tests (silicon + germanium match NR within 1e-6)
  • Klon, Tube Screamer, RAT, inverting amp integration tests all pass

Test plan

  • Wright Omega accuracy against known analytic values
  • Explicit diode pair matches NR for silicon and germanium models
  • Klon Centaur (germanium diode clipping)
  • Tube Screamer (silicon feedback diodes)
  • ProCo RAT (distortion pot + diode clipping)
  • All core op-amp tests still pass

🤖 Generated with Claude Code

ajmwagar and others added 3 commits April 17, 2026 20:17
- wright_omega(): piecewise initial approx + 3 Halley steps for
  near-double-precision ω(x) across the full real domain
- explicit_diode_pair(): anti-parallel pair WDF reflection using
  WO warm start (odd-symmetry fold) + 2 NR correction steps; < 1e-8
  vs NR over all guitar-pedal Rp ranges
- explicit_single_diode(): single forward diode using WO warm start
  + 2 NR correction steps; same accuracy
- ExplicitDiodePairRoot / ExplicitDiodeRoot: WdfRoot + NlDeviceIv
  implementations wrapping the explicit solvers with Rs correction
- Unit tests: wright_omega known values, explicit pair/single vs NR

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… stage dispatch

Phase 3-4 of Wright Omega explicit diode solver:
- Add SolverMethod enum to compiler::component and elements::nonlinear::solver
- Add solver_hint() default to Component trait; Diode/DiodePair override with WrightOmega
- Add DIODE_SOLVER_OVERRIDE atomic in solver.rs with set/clear/get API
- Wire solver selection in build.rs: resolve_diode_solver() checks global override,
  falls back to component hint; diodes now default to ExplicitDiodePairRoot/ExplicitDiodeRoot
- Add ExplicitDiodePair/ExplicitSingleDiode variants to RootKind and NlDeviceKind in stage.rs
- Update all match arms in stage.rs and compiled.rs for new variants

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ajmwagar ajmwagar merged commit 0283159 into main Apr 18, 2026
2 of 11 checks passed
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