Skip to content

Running Simulations

Every SPICE cell has a Run button in its toolbar. Clicking it sends the cell’s netlist to the backend, which:

  1. Writes the netlist to a temp file
  2. Invokes the selected engine (ngspice or LTspice)
  3. Parses the raw output into structured WaveformData
  4. Returns results to the browser and saves them in the cell’s outputs array

Results appear inline beneath the cell — either a data table (for .op) or a waveform plot (for .tran, .dc, .ac).

The toolbar’s Run All button executes every SPICE cell in the notebook from top to bottom, sequentially. Each cell’s results are saved before the next cell runs.

This is useful for notebooks where later cells depend on understanding earlier results, or when you want to regenerate all outputs after changing the engine.

The analysis directive in your netlist determines what kind of results you get:

V1 1 0 DC 5
R1 1 2 1k
R2 2 0 2k
.op
.end

Returns a single set of node voltages and branch currents. Displayed as a table.

V1 1 0 PULSE(0 5 0 1n 1n 5u 10u)
R1 1 2 1k
C1 2 0 100n
.tran 10n 50u
.end

Returns time-series data. Displayed as an XY waveform plot with time on the horizontal axis.

V1 1 0 DC 5
R1 1 2 1k
R2 2 0 2k
.dc V1 0 10 0.5
.end

Sweeps a source value and returns node voltages at each step. Displayed as a waveform plot with the swept parameter on the horizontal axis.

V1 in 0 AC 1
R1 in out 1k
C1 out 0 1u
.ac dec 100 1 1meg
.end

Returns complex frequency-domain data. Displayed as a Bode plot — magnitude in dB and phase in degrees versus frequency on a log scale.

Every simulation returns a SimulationResponse:

{
"success": true,
"waveform": {
"variables": [{"name": "v(out)", "type": "voltage"}],
"points": 100,
"x_data": [0.0, 0.001, ...],
"y_data": {"v(out)": [0.0, 0.5, ...]},
"x_type": "time",
"is_complex": false
},
"log": "ngspice output...",
"error": null,
"elapsed_seconds": 0.42
}

If the simulation fails (syntax error, convergence failure), success is false and error contains the diagnostic message. The simulator log is always available in the log field for debugging.

SPICE uses its own suffix convention for component values — be aware that M means milli (10⁻³), not mega. Use meg for 10⁶.

SuffixMultiplierExample
T10¹²1T
G10⁹2.2G
meg10⁶1meg
k10³4.7k
m10⁻³10m
u10⁻⁶100u
n10⁻⁹47n
p10⁻¹²10p
f10⁻¹⁵1f