A technical comparison of NGSpice and LTspice for circuit designers. Explore integration methods, behavioral source syntax, automation trade-offs, and online simulation workflows.
For decades, SPICE (Simulation Program with Integrated Circuit Systems) has been the foundation of analog circuit simulation. While the core algorithmic principles originate from UC Berkeley's SPICE3f5, the modern engineering ecosystem relies heavily on two prominent free simulation tools: Analog Devices' LTspice and the open-source community's NGSpice.
Engineers, educators, and makers frequently ask: How do these two engines compare under the hood, and how compatible are their netlists in practice?
Whether you are migrating subcircuits between tools, automating netlist regression tests, or exploring browser-based SPICE alternatives, understanding the numerical and syntax differences between NGSpice and LTspice will save hours of debugging.
---
1. Core Architecture and Philosophy
| Feature | LTspice | NGSpice |
|---|---|---|
| Maintainer | Analog Devices | Open-source community (BSD-style license) |
| Distribution | Freeware desktop application (Windows, macOS) | Open-source C engine (Linux, Windows, macOS, shared library) |
| Model Library | Extensive built-in macromodels for Analog Devices ICs | Generic Berkeley models + XSPICE event-driven code models |
| Scripting & Automation | Command-line batch execution (-b) | Interactive nutmeg scripting, shared C library (libngspice), Python bindings |
| Primary Use Cases | Desktop SMPS design, power electronics, vendor-specific IC validation | Open-source EDA integration (e.g., KiCad), headless server pipelines, mixed-signal flows |
LTspice: Tailored for Power and Proprietary Macromodels
Originally developed by Mike Engelhardt, LTspice was created with a clear focus: delivering exceptionally fast, convergent simulations for complex switching-mode power supply (SMPS) controllers. It bundles thousands of tuned macromodels for Analog Devices and legacy Linear Technology parts. While closed-source, it provides a highly optimized standalone engine and schematic editor.
NGSpice: The Extensible Open-Source Standard
NGSpice is an active, open-source continuation of Berkeley SPICE3f5. It incorporates the Georgia Tech XSPICE extension, enabling mixed-signal simulation through event-driven digital and analog code models. Distributed under an open license, NGSpice can be built as a standalone binary or as a shared dynamic library (libngspice), making it the simulation backend of choice for modern open-source EDA suites like KiCad and cloud engineering platforms.
---
2. Syntax and Netlist Compatibility
Standard passive components (R, L, C) and fundamental semiconductor devices (D, Q, M) generally share identical syntax across both simulators. However, differences emerge when using behavioral sources, mathematical functions, and subcircuit conventions.
Arbitrary Behavioral Sources (B-Sources)
Both engines implement non-linear dependent sources using the Berkeley B element prefix, but support different convenience conventions:
- Voltage and Current Assignment:
- In NGSpice, notation strictly adheres to the standard:
B1 out 0 V=f(...)orB1 out 0 I=f(...). - In LTspice, the standard syntax is accepted along with shorthand qualifiers like
BV1 out 0 ...andBI1 out 0 ....
- Mathematical Operators:
- In NGSpice, standard C and SPICE conventions such as
pow(x, y)orx**yare used for exponentiation. - In LTspice,
x^yis frequently permitted alongsidex**y, though care must be taken when transferring netlists to other SPICE engines.
- Step Functions:
- In NGSpice, Berkeley's standard
u(x)returns 1 when x > 0 and 0 otherwise. - In LTspice,
u(x)and convenience functions likebuf(x)andinv(x)are provided for behavioral logic.
Vendor Macromodel Scoping
When importing third-party operational amplifier or MOSFET subcircuits, netlists may include .model definitions placed directly inside .subckt ... .ends blocks or spread across external include files. While both engines parse hierarchical subcircuits, netlist preprocessors and different parser implementations may resolve local versus global scopes differently. For consistent cross-simulator compatibility, placing shared .model definitions in clean, globally referenced include files is recommended.
---
3. Numerical Integration and Convergence
When an analog transient simulation encounters steep edges or non-linear feedback, the choice of numerical integration algorithm directly impacts both stability and runtime.
Integration Methods: Trap, Modified Trap, and Gear
Simulators solve differential equations by discretizing time into discrete steps:
- Trapezoidal Rule (
trap): Available in both LTspice and NGSpice. Trapezoidal integration is fast and conservative with numerical damping, but it is susceptible to "trapezoidal ringing" (artificial oscillations around sharp switching discontinuities). - Gear Integration (
gear): Supported by both engines. Gear introduces artificial numerical damping, effectively smoothing high-frequency numerical artifacts at the cost of slight damping on physical resonances. In NGSpice, this can be selected via.options method=gear. - Modified Trapezoidal (
modified trap): The default method in LTspice. It adjusts the standard trapezoidal algorithm to cancel trapezoidal ringing without introducing the excessive numerical damping associated with Gear methods.
Initial Conditions and the UIC Option
In non-linear circuits like relaxation oscillators or astable multivibrators, finding an operating point can be challenging because a symmetric DC equilibrium may not naturally break into oscillation.
The .tran directive in SPICE includes an optional parameter: uic (Use Initial Conditions):
.tran 10u 50m uic
- What
uicdoes: It skips the initial steady-state DC operating-point calculation (.op) and begins transient simulation directly from the specified node voltages (or zero if unspecified). - When to use it: While
uicis valuable when evaluating transient startup behaviors or forcing an initial capacitor charge withIC=..., it should be used deliberately. Bypassing the DC solution can sometimes introduce artificial transient spikes or convergence difficulties if initial voltages conflict with circuit Kirchhoff constraints.
---
4. Automation and Toolchain Integration
Depending on whether your workflow centers around interactive schematic design or automated batch testing, the two tools present different integration models:
LTspice Command-Line Batching
LTspice supports automated batch simulation from the command line:
XVIIx64.exe -b -ascii circuit.net
In batch mode, LTspice runs headless and generates waveform output files (.raw). Post-processing these files typically involves third-party script libraries (such as PyLTSpice) that parse binary raw traces into Python NumPy arrays.
NGSpice Scripting and Embedded Shared Library
NGSpice was architected with native command-line and programmatic control in mind:
- Interactive Control Scripts: Netlists can include native
.control ... .endcblocks with iterative loops, variable definitions, and conditional analysis directly executed by thenutmeginterpreter. libngspiceDynamic Library: NGSpice can be linked directly into external host programs as a C library. The host application passes netlists into memory and receives simulation vectors in real-time callbacks without reading or writing files to disk.
# Headless NGSpice transient simulation using PySpice (Python 3)
from PySpice.Spice.Netlist import Circuit
from PySpice.Unit import *
circuit = Circuit('RC Low-Pass Filter')
circuit.R(1, 'input', 'output', 1@u_kOhm)
circuit.C(1, 'output', circuit.gnd, 1@u_uF)
circuit.PulseVoltageSource('input', 'input', circuit.gnd,
initial_value=0@u_V, pulsed_value=5@u_V,
pulse_width=5@u_ms, period=10@u_ms)
simulator = circuit.simulator(temperature=25, nominal_temperature=25)
analysis = simulator.transient(step_time=10@u_us, end_time=20@u_ms)
---
5. Modern Browser-Based Simulation: Where CircuPilot Fits
For traditional desktop design, installing native desktop software and maintaining local SPICE libraries remains standard practice. However, collaborative engineering, educational classrooms, and rapid concept testing increasingly benefit from web-accessible simulation environments.
This is where platforms like CircuPilot complement desktop tools:
- Server-Side NGSpice Engine: Rather than approximating circuit physics with simplified heuristic solvers, CircuPilot runs standard NGSpice on its cloud backend. Netlists generated from the interactive canvas are evaluated by real SPICE routines, preserving the mathematical rigor of DC and transient solvers.
- Natural Language Schematic Generation: Instead of manually wiring every junction, engineers and students can describe circuit requirements in plain English (for example, "Design a 555 astable timer running at 1 kHz with a 60% duty cycle"). The platform creates an editable schematic ready for immediate simulation.
- Co-Simulating Analog Circuitry with Firmware: In addition to pure analog SPICE simulation, CircuPilot integrates cycle-accurate AVR emulation in the browser. You can design an analog sensor circuit, connect it to an Arduino or ATmega microcontroller, and inspect how your compiled C++ firmware interacts with the analog network. For more details on digital-analog co-design, check out our guide on designing and simulating Arduino sensor circuits.
---
Summary: Which Tool Fits Your Workflow?
- Choose LTspice if your primary work involves power supply design using Analog Devices ICs, complex desktop schematic hierarchies, or proprietary vendor macromodels.
- Choose NGSpice if you prioritize open-source licensing, require cross-platform Linux pipelines, integrate simulation into KiCad or custom software, or need embedded headless execution via
libngspice. - Try CircuPilot if you need a zero-install, online circuit simulator that pairs authentic NGSpice analog analysis with AI-assisted schematic design and microcontroller emulation in the browser. You can also explore our comparison on LTspice vs online SPICE simulation.
Frequently asked questions
What is the main difference between NGSpice and LTspice?
LTspice is proprietary freeware by Analog Devices optimized for desktop SMPS design and packed with proprietary IC macromodels, while NGSpice is an open-source, cross-platform engine with XSPICE mixed-signal support and a shared C library (libngspice) for headless integration.
Can NGSpice run LTspice netlists?
Basic netlists with standard passive parts and Berkeley semiconductor models run interchangeably. Discrepancies occur when netlists use LTspice-specific behavioral syntax (such as BV/BI shorthand), proprietary vendor macromodels, or non-standard math operators.
Which integration method is better: Trapezoidal, Modified Trap, or Gear?
Both simulators support Trapezoidal and Gear methods. Trapezoidal is fast with minimal numerical damping but prone to ringing on sharp edges. Gear dampens ringing but can suppress physical resonances. LTspice defaults to Modified Trapezoidal, which cancels numerical ringing without the heavy damping of Gear.
Does NGSpice run in the browser?
NGSpice itself is a native C engine. Platforms like CircuPilot run authentic NGSpice on cloud backends, providing interactive browser-based schematic editing and visualization without local installation.