Advanced Analysis
The three core analyses -- DC operating point, AC frequency sweep, and transient simulation -- answer the most common questions about a circuit. But sometimes you need to ask deeper questions.
How sensitive is the output voltage to a 1% change in a resistor? Sensitivity analysis answers this, systematically computing the derivative of any output with respect to every device parameter in the circuit. It tells you which components matter most and which are irrelevant.
What is the voltage gain, input impedance, and output impedance of this amplifier? Transfer function analysis extracts all three from a single linearized solve, giving you the small-signal characterization that an analog designer needs.
Is this feedback loop stable? Where are the poles and zeros? Pole-zero analysis finds the roots of the transfer function in the complex
These three analyses share a common foundation: they all start from the DC operating point and work with the linearized circuit. They're computationally inexpensive compared to transient analysis -- each involves a handful of matrix solves rather than thousands -- but they provide insight that would be difficult or impossible to extract from time-domain waveforms alone.
Sensitivity Analysis
Every component in a circuit has tolerances. A 10 k
Sensitivity analysis (.SENS) answers this quantitatively. For a specified output (typically a node voltage), it computes:
for every device parameter
The adjoint method
The brute-force approach to sensitivity would be: for each parameter, perturb it slightly, re-solve the entire circuit, and measure the change in output. With
SPICE uses a much more efficient approach: the adjoint method. The idea is to factor the matrix once during the DC operating point, then reuse that factored matrix for every parameter perturbation. Each parameter's sensitivity requires only a single forward/back substitution -- not a full matrix factorization.
The algorithm:
Step 1: Solve the DC operating point. Run the full nonlinear DC solver. This gives the operating point solution
Step 2: For each parameter, perturb and measure. For each device parameter
- Choose the perturbation:
if , else . - Compute the delta stamps: the difference in matrix and RHS between original and perturbed values.
- Form the RHS:
- Solve (back-substitution only, since
is already factored). - Extract sensitivity:
.
What gets perturbed
Not every device parameter is meaningful for sensitivity. Typical examples:
| Device | Parameters |
|---|---|
| Resistor | resistance |
| Capacitor | capacitance |
| Inductor | inductance |
| Diode | |
| MOSFET | |
| BJT |
Reading the results
The output is a table of sensitivities. For a voltage output
Parameter Sensitivity (V/unit)
r1 -4.5000e-04 (V per ohm)
r2 2.1000e-04 (V per ohm)
q1:bf 8.3000e-06 (V per unit beta)
q1:is -1.2000e+08 (V per amp of Is)
The large magnitude for q1:is doesn't mean
This gives the percent change in output per percent change in parameter -- a dimensionless quantity that allows direct comparison across all device types.
Practical use
Sensitivity analysis is invaluable for:
- Tolerance analysis: Identify which components need tight tolerances (high sensitivity) and which can be relaxed (low sensitivity). This directly affects BOM cost.
- Design centering: Understand which parameters shift the output in which direction, guiding the designer toward a robust operating point.
- Debugging: When a circuit doesn't meet spec, sensitivity tells you which parameter to adjust for the most effect.
The computation is fast -- one DC operating point plus
Transfer Function Analysis
Transfer function analysis (.TF) extracts the three most important small-signal properties of a circuit in a single analysis:
- Transfer function -- the ratio of output to input: voltage gain (
), transimpedance ( ), or current gain ( ). - Input impedance -- the impedance seen looking into the input source.
- Output impedance -- the impedance seen looking back from the output.
These three numbers completely characterize a linear two-port network at DC.
.TF V(out) Vin * voltage gain and impedances
.TF V(out,ref) Vin * differential output
.TF I(Vout) Iin * current gain
The algorithm
Transfer function analysis requires one DC operating point solve (which factors the matrix) and then just two back-substitutions -- no additional matrix factorizations.
Step 1: Solve the full nonlinear circuit to find the operating point. Factor the MNA matrix
Step 2: Zero the entire RHS vector. Inject a unit excitation at the input source (1V for voltage source, 1A for current source).
Step 3: Solve (back-substitution only). The result
Step 4: The transfer function is the output variable from the solution. Since the input was 1V (or 1A), the ratio is just the output value itself.
Step 5: Read the input impedance from the same solution.
Step 6: Compute output impedance by injecting unit excitation at the output and solving again.
What the numbers mean
Consider a common-emitter amplifier:
.TF V(out) Vin
Transfer function: -45.2 (voltage gain)
Input impedance: 2.8 kOhm
Output impedance: 4.7 kOhm
Transfer function = -45.2 means the amplifier inverts the signal and provides 45.2x voltage gain.
Input impedance = 2.8 k
Output impedance = 4.7 k
Relationship to AC analysis
Transfer function analysis gives you the DC (zero-frequency) values of gain and impedance. AC analysis gives you these same quantities as a function of frequency. The .TF result corresponds to the .AC.
Why have .TF as a separate analysis? Because it's cheaper and more direct. AC analysis requires sweeping across hundreds of frequency points. .TF gives you the DC gain and both impedances from two back-substitutions.
Pole-Zero Analysis
Pole-zero analysis (.PZ) finds the poles and zeros of a circuit's transfer function in the complex
.PZ V(out) GND Vin GND CUR POL * find poles
.PZ V(out) GND Vin GND CUR ZER * find zeros
.PZ V(out) GND Vin GND CUR PZ * find both
What are poles and zeros?
Any linear circuit's transfer function can be written as a ratio of polynomials in the complex frequency variable
The zeros
The physical meaning of poles
A pole at
Left-half-plane poles (
Right-half-plane poles (
Imaginary-axis poles (
Connecting poles to frequency response
Each pole creates a -20 dB/decade rolloff in the magnitude response at frequencies above the pole's natural frequency. Each zero creates a +20 dB/decade rise. The frequency response you see in a Bode plot is completely determined by the locations of the poles and zeros.
The physical meaning of zeros
A zero at
How SPICE finds them
Finding poles and zeros is harder than it might seem. The transfer function is defined implicitly by the circuit's MNA matrix -- you don't have an explicit polynomial to factor. The poles are values of
The algorithm in spice-rs uses an iterative root-finding approach:
- Setup. Solve the DC operating point and compute small-signal parameters.
- Initial search. Start from a real initial guess on the negative real axis and use a logarithmic search strategy to bracket roots.
- Refinement. Use a variant of Muller's method (a quadratic interpolation root-finder that works with complex numbers) to converge on each root.
- Deflation. After finding a root, deflate it out of the determinant so the next iteration finds a different root.
- Repeat. Continue until no more roots are found within the search region.
Reading the output
The result is a list of poles and zeros as complex numbers:
Poles:
p1 = -1.59e+06 (real pole at 253 kHz)
p2 = -4.78e+08 (real pole at 76 MHz)
p3,4 = -2.3e+07 +/- j3.1e+07 (complex pair at ~6 MHz)
Zeros:
z1 = -3.14e+09 (real zero at 500 MHz)
When to use pole-zero analysis
Pole-zero analysis is most valuable for:
- Stability analysis: If any pole has a positive real part, the circuit is unstable. This is the definitive test.
- Feedback loop design: The locations of poles and zeros determine phase margin and gain margin.
- Understanding frequency response shape: The Bode plot is just a graphical representation of the pole-zero locations.
- Resonance identification: Complex conjugate poles identify resonant frequencies and their damping.
For simple circuits with one or two poles, AC analysis and visual inspection of the Bode plot is usually sufficient. Pole-zero analysis becomes essential for complex multi-stage amplifiers, feedback loops, and any circuit where stability is a concern.