Representing electrical circuits as data structures?
I'm working on an open ended project at the moment in python (though java or C++ could both do). The idea is that for me to create a circuit solver (basic DC resistive) that generates and walks through solutions for circuit problems either through nodal or mesh analysis. Of course online circuit simulators exist, but I find that they tend to give the answer without the work; I'm looking to make a "CAS" for circuits so as to speak (of course a basic one). I'me come up with a problem though, that is, I'm not really sure what hte best way of representing such a circuit would be. Immediately coming to mind is a weighted graph with an adjacency matrix, but while that will do for resistances, it can't address current sources and voltages sources (dependent or independent). I was wondering if anyone had any ideas...
Also, mesh analysis seems to send me in the direction of cycle bases, and the only information I can find regarding the topic is a intimidating 45 page paper which is supposed to have a general algorithm in there somewhere. Considering that my circuits are likely to be small, I was wondering if there might be an easier O(blah) time algorithm where I don't really care if blah is n! or even n^n
@inkyvoyd Just a thought built on your idea of representing the network by a weight graph. The vertices could represent voltage, the edges resistance, and the current flow is a variable along each edge. The idea came from a flow network. In the case of a circuit, the network would be closed (circular). A voltage source would be equivalent to a source with defined voltage, and a sink. Internal resistance is just an extra edge between the source and sink. I don't have all the details, but just brain-storming with you.
*
Join our real-time social learning platform and learn together with your friends!