a SPICE-like electronic circuit simulator written in Python
Pull request Compare This branch is 26 commits ahead, 925 commits behind ahkab:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Monkeying around ahkab

a SPICE-like electronic circuit simulator written in Python

The code should be easy to read and modify, the main language is Python 2.x and it is platform-independent.githalytics.com alpha


  • Update your scientific Python installation! We benefit from the latest updates to numpy and get a 40% speed-up for all large networks simulations.


Supported simulations:

  • Numeric:
    • Operating point, with guess computation to speed up the solution. See example: Downscaling current mirror
    • DC sweep
    • Transient analysis, available differentiation formulas: implicit Euler, trapezoidal, gear orders from 2 to 5. See for example the simulation of a Colpitts Oscillator.
    • AC analysis
    • Periodic steady state analysis of non-autonomous circuits, time domain shooting and brute-force algorithms.
  • Symbolic:

The results are saved to disk, plotted or printed to stdout and can be read/processed by the most common tools (eg. Octave, gnuplot, Matlab, gwave and others)

Download and install

There are no packages for the time being (this program is at an early development stage). Go to ahkab on github and follow the instructions to check out the code. You can find the list of the dependencies in the Install notes.


  • ahkab can be run within Python scripts as a library. This will likely become the preferred way in the future. See this butterworth filter simulation for an example/tentative tutorial.

  • or stand-alone with a netlist file, the syntax being:

    $ python ahkab -o graph.dat `

See ahkab --help for command line switches.


The simulator can either be run from the command line with a netlist file or included in a python script. Both possibilities will be maintained for the foreseeable future.

Refer to the netlist syntax page for how to write the netlist files that describe the circuit. Experience with running SPICE or other commercial simulators can be useful.

The latter option is shown briefly in the Python API wiki page. The code comes with docstrings associated with most functions, type help(ahkab.function_name).

How this project was born

This project was born when I was an enthusistic undergrad, apparently with plenty of free time, attending "Simulazione Circuitale" (Circuit Simulation) taught by Prof. A. Brambilla back in Italy at the Polytechnic University of Milan.

I am grateful to prof. Brambilla for teaching one of the most interesting courses of my university years. -GV


Giuseppe Venturini, Ian Daniher, Rob Crowther.

Bugs and patches

Note that I often add new functionality at the expense of breaking stuff. Most likely I will introduce a new feature even if that means breaking a couple of others. It should get fixed soon, but if you have a bit of time to spare, you can send me a pull request or a patch. :)

Does it work? Bugs? Do you have patches? Did you run some noteworthy simulation? Let me know! Feedback is very welcome, my email address is available after a captcha.