Python bindings for ngspice simulation engine
Latest commit 668c51d Feb 12, 2017 @ignamv committed on GitHub Merge pull request #7 from endolith/master
ENH: Add basic Windows support

Python bindings for the ngspice simulation engine

This is a library that allows Python applications to talk to Ngspice, an engine for simulating electronic circuits. Currently it supports sending commands to the engine and reading the results into numpy arrays, for plotting and analysis. Future goals include voltage and current sources defined by Python functions, and the possibility of stepping through a simulation in order to inspect results and modify the circuit mid-run.


Low-pass filter

Bipolar transistor output characteristics

Operational amplifier oscillator

Getting libngspice

This library requires libngspice.

On Linux, this means you have to download the source package for ngspice and compile it like this:

./configure --with-ngshared
sudo make install

On Windows, it currently assumes that ngspice.dll is installed in C:\Spice\bin_dll (32-bit Python) or C:\Spice64\bin_dll (64-bit Python). Go to Ngspice Download and choose one of the packages (such as ngspice-26plus-scope-inpcom-6-64.7z) that contains ngspice.dll, and extract it to C:\. (To support all features, this folder structure must also include spinit,, etc.)

Making netlists

One fast way to produce SPICE netlists is to draw the schematic with GSchem and then export a netlist with

gnetlist -g spice-sdb schematic.sch -o

For details on simulation commands, check out the Ngspice manual.