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 |
|---|---|
setup_ac_sweep | Configure and return a callable for AC small-signal S-parameter sweep. |
setup_ac_sweep ¤
setup_ac_sweep(
groups: dict[str, Any], num_vars: int, port_nodes: list[int], *, z0: float = 50.0
) -> 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 | Reference impedance in ohms, applied uniformly to all ports. Defaults to 50.0. | 50.0 |
Returns:
| Type | Description |
|---|---|
Callable[[Array, Array], Array] | A callable |
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
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |