Skip to content

Conversation

@pepijndevos
Copy link

This implements AC analysis by:

  • Unifying b vector to fully deferred pattern (like G/C matrices)
  • Adding b_ac vector for AC excitation stamps
  • Updating VoltageSource/CurrentSource with optional ac parameter
  • Updating SPICE codegen to parse AC magnitude/phase specifications
  • Creating new src/mna/ac.jl with ac!() and freqresp() functions

Key changes:

  • MNAContext: Replace immediate b stamps with deferred b_I/b_V arrays
  • MNAContext: Add b_ac_I/b_ac_V for AC disturbance tracking
  • VoltageSource/CurrentSource: Add ac::ComplexF64 field
  • stamp!(): Call stamp_b_ac!() for sources with AC specification
  • ac!(): Build DSS system from linearized G, C matrices and b_ac
  • freqresp(): Compute frequency response at any node

The AC analysis workflow:

  1. Solve DC operating point
  2. Linearize circuit at DC solution (G, C matrices)
  3. Extract AC excitation vector (b_ac)
  4. Build DescriptorStateSpace: E=C, A=-G, B=b_ac
  5. Compute H(jω) = (jωC + G)⁻¹ · b_ac

Tests updated for new deferred b pattern and new AC API.

- Rewrite src/ac.jl to use MNA matrices instead of DAECompiler
- Add AC excitation support to VoltageSource/CurrentSource (ac field)
- Add b_ac storage to MNAContext for AC excitation stamps
- Add get_rhs_ac() to assemble AC excitation vector
- Update SPICE codegen to parse and pass AC values to sources
- Fix ground handling in codegen (use literal 0 for node "0")
- Add sema_visit_ids! for ACSource nodes
- Update test/ac.jl with minimal API changes (Symbol node access)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@pepijndevos pepijndevos force-pushed the claude/ac-noise-mna-update-rPulQ branch from f93a0d7 to be9489f Compare January 13, 2026 14:19
pepijndevos and others added 2 commits January 13, 2026 16:03
- Add RobustAndOptimalControl dependency for ss(::DescriptorStateSpace)
- Restore bode() test using ss() conversion from DescriptorSystems
- Add CMOS inverter AC test with sp_mos1 vs ngspice reference data
- Document remaining limitations in src/ac.jl and test/ac.jl:
  - Device observables (internal variables like sys.l3.V)
  - Noise analysis (noise!() not implemented)
  - AC source phase (parser limitation)
  - Combined AC+transient sources

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- VoltageSource{T} now has dc, ac, and tran fields supporting all analysis modes
- CurrentSource{T} follows the same pattern
- SinWaveform and PWLWaveform are callable structs for transient waveforms
- Legacy constructors preserved for backward compatibility:
  - SinVoltageSource(vo, va, freq; ...)
  - PWLVoltageSource(times, values; ...)
  - TimeDependentVoltageSource(f; dc_value, ...)
- Updated codegen for SIN, PWL, and PULSE sources to use unified types
- Combined AC+SIN sources now work (e.g., `V1 in 0 AC 1 SIN(0 1 1k)`)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.

2 participants