Talk:Resistor mesh: Difference between revisions

Content added Content deleted
(link)
Line 10: Line 10:
I was hoping for something other than <code>42</code> ;-) Maybe a link to something with an algorithm and its explanation? Thanks. --[[User:Paddy3118|Paddy3118]] 07:26, 29 August 2011 (UTC)
I was hoping for something other than <code>42</code> ;-) Maybe a link to something with an algorithm and its explanation? Thanks. --[[User:Paddy3118|Paddy3118]] 07:26, 29 August 2011 (UTC)
: A long, long time ago, I took the class that taught how to [http://www.allaboutcircuits.com/vol_1/chpt_10/index.html do this]. I don't really remember, now. Not the most helpful of links; it teaches more theory than solving this task ought to require. --[[User:Short Circuit|Michael Mol]] 11:44, 29 August 2011 (UTC)
: A long, long time ago, I took the class that taught how to [http://www.allaboutcircuits.com/vol_1/chpt_10/index.html do this]. I don't really remember, now. Not the most helpful of links; it teaches more theory than solving this task ought to require. --[[User:Short Circuit|Michael Mol]] 11:44, 29 August 2011 (UTC)
:: The general idea is this: given a circuit and some input, what's the response of the system? For this particular problem, the input is two voltage values on nodes A and B, and the response is the voltage values on every other node. By Ohm's law, if two neighoring nodes have voltages <math>V_i</math> and <math>V_j</math>, then the current flowing from i to j is <math>(V_i - V_j)/R_{ij}</math> where R is the resistance (=1 here). Given a set of voltages on the nodes, you can calculate net current flow out of each node; to be a valid solution, the total current out of each node must be zero unless the node is an electrode (i.e. given a fixed voltage as part of boundary condition). The C code gives A 1 volt and B -1 volt, calculates what voltage each other node has, then calculates the current I flowing out of A and into B (they must be equal); the resistance is again given by Ohm's law: R = 2/I.
:: Of course the interesting part is how to get the voltage values, and there are multiple ways to do it. The C code just give the circuit some arbitrary values initially, then at each iteration calculates how much voltage difference is needed on each node to locally sastisfy the current flow constraint on that node, and adds it onto the voltage. For this task it converges and pretty quickly at that. --[[User:Ledrug|Ledrug]] 15:45, 29 August 2011 (UTC)