Skip to content

feat: Harmonic Balance solver, example reorganisation, and HB tests#5

Merged
cdaunt merged 16 commits intomainfrom
development
Mar 4, 2026
Merged

feat: Harmonic Balance solver, example reorganisation, and HB tests#5
cdaunt merged 16 commits intomainfrom
development

Conversation

@cdaunt
Copy link
Owner

@cdaunt cdaunt commented Mar 4, 2026

Summary

  • Harmonic Balance solver (circulax/solvers/harmonic_balance.py): new setup_harmonic_balance() for periodic steady-state analysis via Newton–Raphson in the frequency domain, compatible with jax.jit, jax.vmap, and jax.grad
  • Example reorganisation: examples restructured under examples/electrical/{dc,transient,harmonic_balance} and examples/photonic/{dc,transient,advanced}; new ring modulator and HB frequency-sweep notebooks added
  • HB tests (tests/test_harmonic_balance.py): 24 tests covering correctness, jax.jit, jax.vmap, and jax.grad for both real (float64) and complex (photonic) circuits, parametrised over all three solver backends
  • Docs: new harmonic_balance.md page and updated index.md/SUMMARY.md

cdaunt and others added 16 commits March 2, 2026 10:34
Implements setup_harmonic_balance(), a JAX-native periodic steady-state
solver that uses vmap over K time points, rfft/irfft for the HB residual,
and optx.FixedPointIteration (lax.while_loop) for a JIT-compatible Newton
loop — no manual block-circulant Jacobian derivation required.

- circulax/solvers/harmonic_balance.py: new solver; returns a plain
  callable matching the setup_transient API pattern
- circulax/solvers/__init__.py, circulax/__init__.py: export
  setup_harmonic_balance at the top-level package
- docs/harmonic_balance.md: full mathematical derivation and usage guide
- docs/SUMMARY.md: add nav entry
- examples/harmonic_balance.ipynb: LCR resonator (validated against
  analytical Bode) + diode half-wave clipper + jax.vmap frequency sweep
  over 5 points in a single XLA compilation
- CLAUDE.md: updated simulation flow and key files table

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Brings in the Harmonic Balance solver (setup_harmonic_balance), docs,
and example notebook from the harmonic_balance feature branch.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…analysis type

Groups the 8 example notebooks under examples/electrical/{dc,transient,harmonic_balance}
and examples/photonic/{dc,transient}. Updates pyproject.toml copy-examples task to
reflect the new directory structure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tor notebook

compile_netlist now adds "Instance,state" entries to port_map alongside
"Instance,port" entries, giving callers direct index access to component
internal states (e.g. port_map["Ring,a"] for ring energy). Previously
states had to be reconstructed indirectly from port voltages.

- compiler.py: iterate comp_cls.states by name in the index assignment
  loop; update docstring
- test_compiler.py: update assertion to derive num_nets from connection
  keys only; assert state keys are present in port_map
- ring_modulator.ipynb: use port_map["Ring,a"] directly; replace
  eqx.tree_at sweeps with update_group_params; remove AI-generated
  comments; add worktree kernel metadata

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds NRZSource (sum-of-sigmoids, JAX-compatible) with 128-bit PRBS pattern.
Shows RC-filtered time-domain waveforms and an eye diagram with T_bit/2 fold
offset so both crossings are centred, revealing ISI and eye closure not
predictable from small-signal frequency response alone.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cdaunt cdaunt merged commit c483d58 into main Mar 4, 2026
6 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