ac_sweep ¤
AC small-signal frequency sweep returning S-parameters.
AC analysis linearises the circuit DAE at a DC operating point and sweeps a range of frequencies, returning the N-port scattering parameters S(f).
The DAE F(y) + dQ/dt = 0 is linearised at y_dc:
- G = ∂F/∂y|_{y_dc} (conductance matrix)
- C = ∂Q/∂y|_{y_dc} (capacitance matrix)
The complex nodal admittance matrix at angular frequency ω is::
Y(jω) = G + jωC
For N circuit ports with reference impedance Z0::
Y_total = Y(jω) + diag(1/Z0 at port nodes)
RHS[:, p] = 2/Z0 at port_nodes[p], zero elsewhere
V = solve(Y_total, RHS) # shape (num_vars, N_ports)
S = V[port_nodes, :] - I # I = N_ports × N_ports identity
Frequency-domain components contribute Y_fdomain(f) to Y_total at each frequency point and are evaluated inside the frequency sweep loop.
Example::
groups, num_vars, pmap = compile_netlist(net_dict, models)
linear_strat = analyze_circuit(groups, num_vars)
y_dc = linear_strat.solve_dc(groups, jnp.zeros(num_vars))
port_nodes = [pmap["R1,p1"]]
run_ac = setup_ac_sweep(groups, num_vars, port_nodes, z0=50.0)
freqs = jnp.logspace(6, 10, 100) # 1 MHz to 10 GHz
S = run_ac(y_dc, freqs) # shape (100, 1, 1) complex
# JIT for repeated sweeps:
S = jax.jit(run_ac)(y_dc, freqs)
Functions:
| Name | Description |
|---|---|
renormalize | Renormalize S-parameters from one reference impedance to another. |
setup_ac_sweep | Configure and return a callable for AC small-signal S-parameter sweep. |
renormalize ¤
Renormalize S-parameters from one reference impedance to another.
Transforms S-parameters computed at impedance z0_from to the equivalent S-parameters at impedance z0_to, using the standard power-wave renormalization formula.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
S | Array | S-parameter array of shape | required |
z0_from | float | Array | Original reference impedance. Scalar or | required |
z0_to | float | Array | Target reference impedance, same shape options as | required |
Returns:
| Type | Description |
|---|---|
Array | Renormalized S-parameter array, same shape as |
Source code in circulax/solvers/ac_sweep.py
setup_ac_sweep ¤
setup_ac_sweep(
groups: dict[str, Any],
num_vars: int,
port_nodes: list[int],
*,
z0: float | Array = 50.0,
is_complex: bool = False,
holomorphic: bool = False
) -> Callable[[Array, Array], Array]
Configure and return a callable for AC small-signal S-parameter sweep.
Linearises the circuit DAE at the DC operating point and sweeps over an array of frequencies, returning the complex S-parameter matrix at each frequency. The returned callable is compatible with :func:jax.jit and :func:jax.vmap.
The analysis solves Y(jω) · V = RHS at each frequency, where::
Y(jω) = G + jωC + Y_fdomain(f) + port_terminations + ground_penalty
G = ∂F/∂y and C = ∂Q/∂y are extracted once at the DC operating point. Y_fdomain(f) is the admittance contribution from frequency-domain components, re-evaluated at each frequency.
S-parameter convention — matched-load verification:
- Matched load (Z_circuit = Z0) → S11 = 0
- Open circuit (Z_circuit → ∞) → S11 = +1
- Short circuit (Z_circuit = 0) → S11 = −1
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
groups | dict[str, Any] | Compiled component groups from :func: | required |
num_vars | int | Total number of scalar unknowns (second return value of :func: | required |
port_nodes | list[int] | Global node indices for each circuit port, in the desired port ordering. Obtain from the port-to-node map returned by :func: | required |
z0 | float | Array | Reference impedance in ohms. Accepts:
For frequency-dependent impedance, solve at a fixed z0 and use :func: | 50.0 |
is_complex | bool | If | False |
holomorphic | bool | If | False |
Returns:
| Type | Description |
|---|---|
Callable[[Array, Array], Array] | A callable |
Callable[[Array, Array], Array] |
|
Callable[[Array, Array], Array] | circuits or |
Callable[[Array, Array], Array] |
|
Callable[[Array, Array], Array] |
|
Callable[[Array, Array], Array] |
|
Callable[[Array, Array], Array] | Compatible with :func: |
Source code in circulax/solvers/ac_sweep.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |