Skip to content

Add time-delay transient solver and vector-fitting components - #46

Closed
cdaunt wants to merge 5 commits into
mainfrom
worktree-feat-time-delay
Closed

Add time-delay transient solver and vector-fitting components#46
cdaunt wants to merge 5 commits into
mainfrom
worktree-feat-time-delay

Conversation

@cdaunt

@cdaunt cdaunt commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Transient delay infrastructure: DDE history buffer, OpticalDelayLine component, adaptive step-size support (8 tests)
  • Rational component factories: rational_component (time-domain DAE), rational_fdomain_component (AC/HB oracle), rational_delay_component (delay+rational cascade) from vfitax SSModel data (15 tests)
  • AC sweep fix: correct complex-voltage extraction from 2N real-block form
  • Specs: time-delay spec (updated for transient+fdomain coexistence), vector-fitting spec

Details

  • feat(solvers): add fixed time-delay support for circuit components
  • feat(solvers): add adaptive step-size support for time-delayed circuits
  • feat(components): add rational factory functions for vector fitting
  • feat(components): add rational_delay_component for vector fitting with delay
  • docs(specs): add vector-fitting spec, update time-delay for Phase 4

15 files changed, 2143 insertions, 130 deletions.
All 291 tests pass with no regressions.

cdaunt and others added 5 commits July 31, 2026 10:49
Implements constant/fixed time-delay support for circuit components (e.g.
waveguide group delay) without depending on diffrax's general DDE support,
which is stalled upstream on the much harder problem of state-dependent
delays with discontinuity root-finding.

- circuit_diffeq.py: accepted-step (t, y) history buffer in CircuitState,
  seeded at t0 and written on every accepted step, registered with
  eqxi.while_loop's buffer machinery so the checkpointed adjoint handles it.
- base_component.py: new `hist` reserved physics-function argument and a
  `.delay` registration decorator, mirroring the existing `init`/`.setup`
  pattern, injecting the delayed local state at t - tau.
- compiler.py: `has_delay`/`tau_func` on ComponentGroup.
- assembly.py: per-instance vmapped jnp.interp delayed read (tau may vary
  across instances of the same component type, e.g. waveguides of
  different lengths, in one batched group) wired into all four real/complex
  x full/residual-only assemble functions, plus a tau >= dt guard.
- transient.py: hist_t/hist_y threaded through all solver variants;
  setup_transient gates recording behind whether any group has_delay and
  rejects adaptive step-size controllers for delayed circuits (v1 requires
  ConstantStepSize).
- photonic.py: new OpticalDelayLine component modelling real time-of-flight
  group delay via a VCVS constraint.
- tests/test_delay.py: analytic time-shift match across differently-sized
  instances in one group, gradient-vs-finite-difference through the
  checkpointed adjoint, and the tau/step-size guards.

Addresses #2
Previously, setup_transient() raised a ValueError when a circuit contained
delayed components and used an adaptive step-size controller, forcing users
to ConstantStepSize. This removes that restriction by proactively clamping
the adaptive controller's proposed step size to the smallest active delay
(tau) across all delayed groups.

The new min_active_tau() helper (assembly.py) computes this once per solve,
since group params are fixed. This lets the existing tau>=dt safety guard in
assembly.py become a pure safety net instead of something adaptive stepping
could unexpectedly trip. ConstantStepSize behavior is unchanged (explicit
dt0 > tau still raises).

Changes:
- Added circulax/solvers/assembly.py::min_active_tau() helper
- Threaded min_tau parameter through circuit_diffeq.py's circuit_diffeqsolve/_circuit_loop
- Updated transient.py::setup_transient() to compute and pass min_tau for adaptive controllers only
- Replaced assertion test (adaptive+delay raises) with three new tests: adaptive vs analytic shift, adaptive vs constant-step accuracy, and adaptive gradient vs finite-difference

All 223 tests pass with zero regressions.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DYTzQW4crC3K3PB34ronUP
Create rational_component and rational_fdomain_component factory functions
that generate circulax time-domain and frequency-domain components from vfitax
SSModel data. Includes 11 tests covering unit tests, DC response validation,
AC sweep 4-way agreement with pole-residue oracle, and transient stability
verification with steady-state checks.
…h delay

Add rational_delay_component factory that cascades delay embedding with
rational models in the frequency domain. Evaluates S_full = P @ S_deemb @ P
where P = diag(exp(-j*pi*f*tau_k)), converting results back to Y for the
circuit solver. Supports AC sweep and harmonic balance analysis.

Includes 4 delay composite tests validating via independent group delay
measurement from S21 phase slope (not by repeating implementation formula).
Tests cover symmetric delay, zero-delay equivalence, and asymmetric
per-port delays. Adds _measure_s_matrix and _group_delay_from_s helper
functions for reference-independent validation.

Updates specs/time-delay.md to reflect Phase 3 completion with full
fdomain + transient modeling support.

Phase 3 of vector-fitting feature implementation.
Add comprehensive specification for S-parameter vector fitting with delay
de-embedding (rational_component, rational_fdomain_component,
rational_delay_component). Update time-delay spec to reflect coexistence
of transient DDE history buffer with frequency-domain approaches, and
restore test matrix with previously removed transient delay tests.
Update overview with vector-fitting row and clarified descriptions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HgSATMvChpJChaxEfzjbDC
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@cdaunt cdaunt closed this Aug 3, 2026
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