Add time-delay transient solver and vector-fitting components - #46
Closed
cdaunt wants to merge 5 commits into
Closed
Add time-delay transient solver and vector-fitting components#46cdaunt wants to merge 5 commits into
cdaunt wants to merge 5 commits into
Conversation
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
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rational_component(time-domain DAE),rational_fdomain_component(AC/HB oracle),rational_delay_component(delay+rational cascade) from vfitax SSModel data (15 tests)Details
15 files changed, 2143 insertions, 130 deletions.
All 291 tests pass with no regressions.