Skip to content

Simulation

POST /api/simulate

Run a SPICE netlist without creating or modifying a notebook. Useful for one-off simulations or integration testing.

Request body:

{
"netlist": "V1 1 0 DC 5\nR1 1 2 1k\nR2 2 0 2k\n.op\n.end",
"engine": "ngspice"
}

Response 200:

{
"success": true,
"waveform": {
"variables": [
{"name": "v(1)", "type": "voltage"},
{"name": "v(2)", "type": "voltage"}
],
"points": 1,
"x_data": [0.0],
"y_data": {"v(1)": [5.0], "v(2)": [3.333]},
"x_type": "time",
"is_complex": false,
"y_magnitude_db": null,
"y_phase_deg": null
},
"log": "ngspice output...",
"error": null,
"elapsed_seconds": 0.42
}
POST /api/notebooks/{notebook_id}/cells/{cell_id}/run

No request body. Uses the cell’s source as the netlist and the notebook’s engine setting.

Response 200 — same SimulationResponse shape as standalone. The cell’s outputs array is updated in the saved notebook.

FieldTypeDescription
successbooleanWhether the simulation completed without errors
waveformWaveformData | nullSimulation results (null if simulation failed)
logstringRaw simulator output (stdout/stderr)
errorstring | nullError message if simulation failed
elapsed_secondsnumberWall-clock simulation time
{
"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,
"y_magnitude_db": null,
"y_phase_deg": null
}
FieldTypeDescription
variablesarraySignal names and types (voltage, current)
pointsintegerNumber of data points
x_datanumber[]Horizontal axis values (time or frequency)
y_dataobjectSignal name → value array mapping
x_typestring"time" or "frequency"
is_complexbooleantrue for AC analysis
y_magnitude_dbobject | nullPer-signal magnitude in dB (AC only)
y_phase_degobject | nullPer-signal phase in degrees (AC only)

When a simulation fails (syntax error, convergence failure, missing model), the response still returns 200 but with success: false:

{
"success": false,
"waveform": null,
"log": "Error: unknown subcircuit...",
"error": "Simulation failed: unknown subcircuit 'LM741'",
"elapsed_seconds": 0.1
}

Check the log field for the full simulator output — it often contains line numbers and detailed diagnostics that aren’t in the error summary.