AC analysis
An AC analysis allows you to find the behavior of a circuit for small signals. The simulation will first determine the operating point, after which small sinusoidal excitations are applied on top of the calculated biasing conditions. Each voltage, current or other simulated quantity will then vary along with the excited signal and will show an amplitude and phase shift that is represented by a single complex number. This is useful when characterizing a filter, or when analyzing stability of systems that have feedback in them.
By assuming the perturbations are small and sinusoidal, the circuit can be linearized which makes this type of simulation relatively fast. The result is a Complex number, which contains the amplitude and phase information.
Consider the following circuit:
To simulate this, we can write
// Build the circuit
var ckt = new Circuit(
new VoltageSource("V1", "in", "0", 0.0)
.SetParameter("acmag", 1.0),
new Resistor("R1", "in", "out", 10.0e3),
new Capacitor("C1", "out", "0", 1e-6)
);
// Create the simulation
var ac = new AC("AC 1", new DecadeSweep(1e-2, 1.0e3, 5));
// Make the export
var exportVoltage = new ComplexVoltageExport(ac, "out");
// Simulate
ac.ExportSimulationData += (sender, args) =>
{
var output = exportVoltage.Value;
var decibels = 10.0 * Math.Log10(output.Real * output.Real + output.Imaginary * output.Imaginary);
};
ac.Run(ckt);
For our AC analysis, we need an AC source that will excite the circuit. The amplitude and phase of the excitation can be set by using the acmag and acphase parameters for a VoltageSource object.
The frequency points that are simulated in our example range from 10mHz to 1kHz, simulating 5 points per decade, logarithmically spaced.
This is effectively the same as using the following netlist in other Spice simulators:
AC example
V1 in 0 0 AC 1
R1 in out 10k
C1 out 0 1u
.AC dec 5 10m 1k
* Export voltages/currents/etc.
.END
Plotting the output amplitude in decibels gives the following low-pass filter characteristic: