Electronic – Create Circuit Simulation

programmingsimulation

I wonder if someone can help me. How will one go about to create a simple circuit simulator? Similar to Multisim, just a lot simpler!

Basically, I only need resistors, capacitors, inductors and voltage sources.

Is there a tutorial I can follow, to create this using C# and Visual Studio?

Best Answer

I wrote the simulation engine that powers CircuitLab from scratch: from the sparse matrix library up through component models and simulation modes. My co-founder wrote the front-end. It ended up being an unbelievably huge programming project, but one I'm quite proud of. If you're up for the challenge, writing a circuit simulator may be one of the most rewarding programming projects you'll ever tackle.

At a high level, you just need to:

  1. Turn a network of components into a system of equations (non-linear differential equations).
  2. Numerically solve the system of equations (using sparse matrix techniques).

I don't know of an online tutorial, but I've tried to document a lot of this as I write the "Ultimate Electronics" textbook, especially in Chapter 2. There are also a number of 1990s-era books on the topic of circuit simulation, though I don't have them handy at the moment.

My suggestion would be to start from only voltage sources and resistors, and continue building from there. Good luck.