Ohmforge AC Sweep (Bode plot)
Frequency response of a circuit: Bode magnitude/phase, −3 dB corner and unity gain.
How it works
Linearises the circuit at its DC operating point and solves the complex MNA equations across a logarithmic frequency sweep. Returns magnitude in dB and unwrapped phase of an output node (optionally relative to an input node), the peak gain, lower/upper −3 dB frequencies, the unity-gain frequency, a Bode chart and CSV.
- The DC operating point is solved first; every nonlinear device is replaced by its small-signal conductances at that point (diode gd, BJT gm/gπ/go, MOSFET gm/gds, op-amp output slope).
- Capacitors become admittances jωC, inductors impedances jωL in their branch equations, coupled inductors jωM; the complex system is solved by dense LU with partial pivoting at every frequency.
- Magnitude is 20·log10|H|, phase is unwrapped to be continuous. The −3 dB points are found 3.01 dB below the peak by logarithmic interpolation; unity gain is the 0 dB crossing.
Teaching-grade simulation: device models are simplified (Ebers–Moll BJT, level-1 MOSFET, behavioural op-amps and 555) and part ratings are typical values. Verify real designs on the bench and against manufacturer data before building anything connected to mains voltage.
Sources
- SPICE: A Computer Program to Simulate Semiconductor Circuits (L. W. Nagel, UC Berkeley ERL-M520, 1975) (University of California, Berkeley)
- The Modified Nodal Approach to Network Analysis (Ho, Ruehli, Brennan, IEEE Trans. Circuits and Systems, 1975) (IEEE)
- ngspice User Manual (device models, convergence options, source syntax) (ngspice project)
Part of Ohmforge
-
Ohmforge Virtual electronics workbench
Draw a circuit, switch it on, and measure it with real-feeling bench instruments.
Related tools
- Ohmforge DC Operating Point – SPICE netlist in, node voltages, branch currents, power and overload warnings out.
- Ohmforge Transient Simulation – Simulate a circuit over time: waveforms, Vpp/RMS/frequency, CSV and a chart.
How to use the Ohmforge AC Sweep (Bode plot)
Simulate the frequency response of a filter or amplifier from a SPICE netlist and read gain, phase, −3 dB corners and unity-gain frequency from a Bode plot.
What it is for
Filters, tone controls, amplifiers and feedback loops are judged by their frequency response. How much does the signal drop at 50 Hz or 20 kHz, where is the corner, how much phase shift is there? An AC sweep answers that the way an oscilloscope with a network analyser would: it drives the circuit with a 1 V small-signal sine at every frequency and records gain and phase at the output node.
Paste a SPICE netlist (or an Ohmforge project), name the output node, and optionally the source to excite and the sweep range. You get a Bode magnitude plot, a phase plot, the peak gain, upper and lower −3 dB points, the unity-gain crossing, and a CSV of all points. The analysis is linear around the DC operating point, so clipping, slew limits and other large-signal effects don't appear. Use the transient tool for those.
Worked example
The built-in RC low-pass, R = 1 kΩ, C = 100 nF:
V1 in 0 DC 0 AC 1
R1 in out 1k
C1 out 0 100n
.ac dec 20 10 1meg
Result: peak gain −0.0001715 dB at 10 Hz, −3 dB point at 1.591 kHz, exactly 1/(2π·1k·100n). At 100 Hz the phase is already −3.6°, a reminder that phase starts moving well before the amplitude does.
A series RLC band-pass (L 10 mH, C 100 nF, R 100 Ω across the output), swept 100 Hz to 100 kHz at 50 points per decade: peak −0.003 dB near 5.012 kHz, lower −3 dB at 4.299 kHz, upper at 5.892 kHz. The bandwidth of 1.593 kHz matches R/(2πL), and the centre matches 1/(2π√LC) ≈ 5.03 kHz. The reported peak sits on the nearest sweep point, so add points per decade if you need it exact.
For a high-pass, C 100 nF and R 10 kΩ with input V1 and 1 Hz to 100 kHz, the tool reports a lower −3 dB of 159.2 Hz and no upper corner, as expected.
How to read the result
- Peak gain and at: the highest magnitude in dB and its frequency. 0 dB means output equals input; 20 dB is ×10.
- Upper / lower −3 dB: where the response is 3.01 dB below the peak, interpolated between points. A dash means the sweep never got there.
- Unity gain: the 0 dB crossing, useful for op-amp loops.
- Magnitude and phase plots, the selected points table and the Bode CSV with every frequency.
Tips and common mistakes
- Give the source an AC magnitude (
AC 1), or name it in Input source. Otherwise there's nothing to drive, and other sources keep their own AC values. - Corners are measured from the peak, not from 0 dB. For an amplifier with 20 dB gain, the −3 dB point is where it falls to 17 dB.
- Use Reference node to get V(out)/V(in) when the input isn't an ideal 1 V source, for example behind a source resistance.
- A dash means no corner inside the sweep. Widen the range, or accept that there is none: the inverting amplifier example uses an ideal op-amp and stays flat at 20 dB and −180° from 10 Hz to 10 MHz.
- Cascaded stages load each other. Two 1 kHz RC stages from the
.subcktexample give a combined corner of 599.6 Hz, not 1 kHz.
FAQ
How is the −3 dB frequency calculated?
It's the frequency where the magnitude is 3.01 dB below the peak, found by logarithmic interpolation between sweep points.
Why doesn't my amplifier clip in the AC sweep?
An AC sweep is a small-signal analysis around the DC operating point. Clipping and distortion only show up in a transient simulation.
What does the phase tell me?
The time shift of the output relative to the input, in degrees. A low-pass approaches −90° per pole, and an inverting amplifier sits at −180°.
Can I export the data?
Yes. The Bode CSV contains frequency, magnitude and phase for every point.
Guide last updated:
For scripts and AI agents
- JSON API:
POST https://ohmforgeacsweep.usefulweb.site/api/v1/calculate(same calculation as this page) - Interface description: OpenAPI 3.1 · AI guide: llms.txt
- MCP server (Streamable HTTP):
https://ohmforgeacsweep.usefulweb.site/mcp· tool nameohmforge_ac_sweep
Example request
curl -s -X POST https://ohmforgeacsweep.usefulweb.site/api/v1/calculate \
-H 'content-type: application/json' \
-d '{"netlist":"* RC low-pass, fc = 1/(2*pi*1k*100n) = 1591.5 Hz\nV1 in 0 DC 0 AC 1\nR1 in out 1k\nC1 out 0 100n\n.ac dec 20 10 1meg","output":"out","input":"V1"}'