Author Topic: Python-based circuit simulator (MNA, no SPICE backend) – looking for feedback  (Read 774 times)

0 Members and 1 Guest are viewing this topic.

Offline kvdTopic starter

  • Contributor
  • Posts: 35
  • Country: nl
Hi all,

I’ve just released version 1.0 of *impulso-mna*, a Python-based analog circuit simulator built around Modified Nodal Analysis.

The main goal is not to replace tools like LTspice, but to provide a lightweight simulator that integrates directly into Python workflows (e.g. optimization, parameter sweeps, algorithmic circuit design).

I originally built this while working on a Foster–Seeley FM detector, where I needed to explore how a coupling capacitor affects resonance. Doing that kind of parameter sweep and analysis in traditional SPICE tools felt cumbersome, which led me to build a Python-native approach.Key characteristics:

* Pure Python (only depends on NumPy)
* No SPICE backend required
* Easy integration into scripts and optimization loops
* Platform independent
* Useful for learning and experimenting with MNA

Current features:

* DC, AC, transient, and sweep analysis
* Components: R, C, L, mutual inductance
* Sources: AC/DC voltage and current
* Controlled sources (VCCS, CCCS, VCVS, CCVS)
* Nonlinear devices: diode, BJT (npn/pnp)
* Ideal op-amp
* Support for building compound/lumped components

The solver is based on standard MNA formulations and companion models for dynamic elements.

Source code:
[https://github.com/kvdijken/impulso-mna](https://github.com/kvdijken/impulso-mna)

Available on PyPI as **impulso-mna**.

This 1.0 version is intended to be feature-stable and maintained. A more experimental branch (*impulsox-mna*) will be used to explore additional features.

I’d be very interested in feedback, especially on:

* correctness of device models
* numerical stability / convergence
* missing features

Some example results (BJT curves, rectifier, etc.) are attached.

Regards,
Koen
 

Offline Sensorcat

  • Regular Contributor
  • *
  • Posts: 203
  • Country: de
  • Independent Sensor Consultant
    • Sensorberatung
Very interesting project. It's a pity you did not yet get feedback.

Two questions:
  • What is sweep analysis?
  • You did a lot of difficult work in order to avoid interfacing to an existing simulator. In my projects that required automation of simulation, I didn't feel that interfacing is that complicated. What advantages does your code have over creating netlists, starting a simulation job in a different tool, and reading in the results?
 

Offline JohnG

  • Frequent Contributor
  • **
  • Posts: 615
  • Country: us
I think that this is interesting, but I can do most of this analysis via some version of Spice and either Python or Octave (open-source Matlab-compatible). Spice compatibility, at least at the netlist level, is a big plus because of the sheer number of existing models. At this point it would take something really compelling to try a different simulator, as my interest is more in circuits than simulators. Dealing with data and parameter sweeps is not that hard when driving Spice as describe above, i.e. much easier the writing a new simulator.

However faster simulation, more robust convergence, simplified mixed-signal or digital co-simulation compared to Spice would make it more tempting to give it a try. Do you have any evidence about those, or some other solid advantage in terms of actual simulation capability? Perhaps some advantage that I haven't thought of?

Thanks,
John
"Reality is that which, when you quit believing in it, doesn't go away." Philip K. Dick (RIP).
 

Online zapta

  • Super Contributor
  • ***
  • Posts: 6596
  • Country: 00
A clean and modern rewrite of a simulator has a lot of potential but expect a marathon rather than a sprint.

Arbitrary suggestion
* Demonstrated one significant feature of advantage of this simulator over SPICE.
* Add a real life complex example.
* Add testing framework that uses a large set circuit examples from the internet and compare their results with those of SPICE. This will allow you to detect regressions, limitations, and inaccuracies.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->