computer analysis of circuit networks

Hi there

I am wanting to write a program that, given a network, can calculate current, voltage, etc over all components and branches in the network. At the moment, I am just concentrating on linear DC networks that have nothing but voltage and/or current sources, and resistors. I'm ignoring capacitive and inductive components for the time being

In a circuit analysis textbook I've got, it says that branch current analysis can solve any linear DC network, so this is the algorithm I have chosen for the program. With voltage sources and resistors this seems to be no problem, as you are using KVL around each independant loop of the circuit, plus a couple of KCL equations, then you solve them simulataneously.

I get stuck with current sources though. for example the following:

-----R1------------------ | | | | | | V C R2 | | | | | | ---------------------------

Lets say V is a 6V battery, R1 is 2 ohms, C is a 2A current source and R2 is a 5 ohm resistor

With branch analysis, there should be two KVL eqns and one KCL eqn. But how can you do KVL around a loop with current sources in? I know that you could convert C into a voltage source through source conversion, but what if you cannot do a source conversion, such as when there is not a convenient parallel resistor. i suppose what im asking for is a surefire algorithm that can be used in a computer program (ie generic and doesn't rely on human intuition) that will solve any network. Any hints or open source programs that can be of help are appreciated...

cheers Michael

Reply to
michaelquinlivan
Loading thread data ...

The following two pages have some good tips:

formatting link
formatting link

Reply to
longjohnstuartmill

Michael, use nodal analysis if you want to tackle this yourself.

Better yet, download LT spice (it's free ... give it a Google) and learn how to use it.

Reply to
Charles Schuler

Its called...er... SPICE...

Why do you want to reinvent the wheel? Its all been done for 30 years.

The soucce code can be obtained from many sources, e.g. ngspice

formatting link

Even the my windows version XSpice engine can be ran standalone to do this if that's all you are after.

Kevin Aylward snipped-for-privacy@anasoft.co.uk

formatting link
SuperSpice, a very affordable Mixed-Mode Windows Simulator with Schematic Capture, Waveform Display, FFT's and Filter Design.

Reply to
Kevin Aylward

I know Kevin, I used Spice at uni. That's not the point.

Call me unhinged, but sometimes I like to understand how things work, especially algorithms. I am after all a programmer by trade...

Anyhow, I found out what Spice uses, an algorithm called modified nodal analysis (MNA). Right now, I don't completely understand the mathematics behind it, but I know enough to implement it in software.

Thanks all for your help

Michael

Reply to
michaelquinlivan

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.