openmaterials.ai / codes / ngspice
ngspice: SPICE circuit simulation with mixed-signal and device-level extensions
The open-source successor of Berkeley Spice3f5, merged with the XSPICE code models and the CIDER device simulator, that solves DC, AC and transient analyses of a netlist.
What it is and how it works
Kirchhoff's laws, solved per time step
ngspice solves analog nodes iteratively from Kirchhoff's laws with a sparse matrix at each time point. Digital nodes propagate events in the same executable, a native mixed-mode simulator (ngspice manual 47).
Seven analyses
DC operating point and sweep (.op, .dc), AC small-signal (.ac), transient (.tran), pole-zero, small-signal distortion, sensitivity and noise (ngspice manual 47).
Device models
Gummel-Poon bipolar models including VBIC, diodes, JFET and JFET2, the six original MOSFET levels, BSIM3, BSIM4, BSIMSOI, plus Verilog-A via OpenVAF (ngspice manual 47).
XSPICE code models
Code model instances start with A and take a .MODEL card (ngspice manual 47). Over 60 functional blocks and a 12-state digital type (ngspice XSPICE page).
Two matrix solvers
Sparse 1.3 is the default and is required for noise and CIDER. option klu selects KLU for large MOS circuits with thousands of transistors (ngspice manual 47).
Shared library
Built as .so or .dll, ngspice takes a netlist from a host program, runs in its own thread and calls back at each time point. KiCad uses it (ngspice shared page).
By the numbers
- >60functional blocks in the XSPICE model libraryngspice XSPICE page
- 32.4 s8 threads vs 65.4 s at 1, 627 BSIM4.7 invertersngspice manual 47
- >20public Verilog-A compact models usable via OSDIngspice manual 47
How it is used
Write the netlist
Title line, element cards (R, C, M, X), .model cards, analysis lines such as .op or .tran.
Load extra models
osdi model.osdi for OpenVAF-compiled Verilog-A. spinit loads the .cm code model libraries.
Run
ngspice netlist.cir, or with -b for batch mode, or from a host via the shared library.
Read results
print, plot and wrdata write the vectors. option numdgt sets the significant digits.
What ngspice is
ngspice is the open-source circuit simulator descended from Berkeley SPICE 3f5, with XSPICE mixed-signal extensions. It solves DC, AC and transient analyses of circuits built from device models and behavioral sources, so a device characterized on the map can be placed in a circuit and simulated at the circuit level. On the map it serves the quantities read back from its operating-point (.op) analyses.
WebsiteOn the mapAll codesLicense: BSD-3-Clause AND LGPL-2.0-or-later AND LGPL-2.1-or-later AND MPL-2.0 AND GPL-2.0-or-later AND LicenseRef-ngspice-sparse
In more detail
Lineage and scope
ngspice merges Spice3f5, Cider1b1, which couples the circuit solver to a device simulator, and Xspice, which adds code modeling and event-driven digital simulation (ngspice README). Spice3f5 is the last Berkeley release of Spice3, and XSPICE came from Georgia Tech (ngspice manual 47). Most of the work since has been bug fixing and refactoring (ngspice manual 47). The project aims at compatibility. PSPICE and LTSPICE model parameters and netlists run, and ngspice reads HSPICE device libraries from foundry PDKs for integrated circuits (ngspice home page). Input is a netlist file or the command line, output is plots or data files, and there is no schematic entry (ngspice home page).
Analyses and numerics
Analog simulation solves Kirchhoff's laws as a matrix of simultaneous equations at time steps chosen for convergence and integration accuracy, with gmin stepping and source stepping as convergence aids for the DC solution (ngspice manual 47). Since version 42 ngspice has two solvers. Sparse 1.3, which has served all simulation tasks and suits behavioral models, sits next to KLU for large transistor circuits (ngspice manual 47). OpenMP parallelizes the device evaluation inside BSIM3 3.3.0 and 3.2.4, BSIM4 4.5, 4.6.5, 4.7 and 4.8, B4SOI 4.4 and OSDI models, where about two thirds of the CPU time goes for transistor-heavy circuits. The matrix solution stays serial (ngspice manual 47).
Device models and extensions
Compact models come from the built-in set and from Verilog-A. OSDI is a simulator-independent model interface, in ngspice since release 39, and OpenVAF compiles Verilog-AMS LRM 2.x models such as BSIMBULK, BSIMCMG, PSP, HiSIM and HICUM into .osdi shared libraries loaded with the osdi command on Linux and Windows (ngspice manual 47). CIDER solves Poisson's equation and the electron and hole continuity equations in one or two dimensions for the critical devices, with PISCES-like structure input and temperature dependence from -50 to 150 degC (ngspice manual 47). XSPICE adds User-Defined Node types that carry arbitrary data. The digital state with strength is one of them (ngspice manual 47).
Interfaces
Input files may carry scripts in the control language, and wrdata writes scale and value vector pairs as ASCII with numdgt significant digits (ngspice manual 47). As a shared library ngspice exports control functions and callbacks, so a host can start a run in a separate thread, read each time point, alter device or model parameters and resume. EXTERNAL sources let the host set node values during the run (ngspice manual 47). Bindings exist for C++ (KiCad), Python (PySpice), Ruby, Octave, Fortran, Rust and Go (ngspice shared page). Digital Verilog modules compiled with Verilator or Icarus Verilog can be attached, and C processes can be reached through pipes (ngspice manual 47).
What it computes on the map
2 quantities, drawn by tier with the data flow between them. Dashed boxes are intermediate quantities. Select one for its formula and the other codes that compute it.
Embed this submap
<iframe src="https://openmaterials.ai/m/c56731602651/00000000000000000000000000000440?embed=1" title="ngspice on the OpenMaterials map" width="100%" height="480" loading="lazy" style="border:1px solid #EBEBEB;border-radius:6px"></iframe>
Each quantity with the interface the representation records.
- ConductanceState.op with a DC source vread at the read bias across the device; G = -i(vread) / V_read (wrdata, or let g = -i(vread) / V_read before print: print drops one digit of a negative number)siemens
- DotProductError.op of the array netlist per input pattern (alter or a .control loop), wrdata of the readout node voltages at numdgt=15dimensionless
Releases on record
Versions on record for this code, with the license read from the release itself.
| Version | Released | License |
|---|---|---|
| 47 | 2026-08-11 | BSD-3-Clause AND LGPL-2.0-or-later AND LGPL-2.1-or-later AND MPL-2.0 AND GPL-2.0-or-later AND LicenseRef-ngspice-sparse |
References
No curated reference list yet. The citations recorded on the map representation are listed under How to cite.
How to cite
H. Vogt, G. Atkinson, D. Warning, P. Nenzi, Ngspice User's Manual, Version 47 (ngspice release version), 11 August 2026, https://ngspice.sourceforge.io/docs.html