Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What algorithm do I use to calculate voltage across a combination circuit?

I'm trying to programmatically calculate voltage changes over a very large circuit.

*This question may seem geared toward electronics, but it's more about applying an algorithm over a set of data.

To keep things simple,
here is a complete circuit, with the voltages already calculated:

enter image description here

I'm originally only given the battery voltage and the resistances:

enter image description here

The issue I have is that voltage is calculated differently among parallel and series circuits.
A somewhat similar question asked on SO.

Some formulas:

When resistors are in parallel:
Rtotal = 1/(1/R1 + 1/R2 + 1/R3 ... + 1/Rn)

When resistors are in series:
Rtotal = R1 + R2 + R3 ... + Rn

Ohm's Law:

V = IR
I = V/R
R = V/I

V is voltage (volts)
I is current (amps)
R is resistance(ohms)

Every tutorial I've found on the internet consists of people conceptually grouping together parallel circuits to get the total resistance, and then using that resistance to calculate the resistance in series.

enter image description here

This is fine for small examples, but it's difficult to derive an algorithm out of it for large scale circuits.

My question:
Given a matrix of all complete paths,
is there a way for me to calculate all the voltage drops?

I currently have the system as a graph data structure.
All of the nodes are represented(and can be looked up by) an id number.

So for the example above, if I run the traversals, I'll get back a list of paths like this:

[[0,1,2,4,0]
,[0,1,3,4,0]]

Each number can be used to derive the actual node and it's corresponding data. What kind of transformations/algorithms do I need to perform on this set of data?


It's very likely that portions of the circuit will be compound, and those compound sections may find themselves being in parallel or series with other compound sections.

I think my problem is akin to this:
http://en.wikipedia.org/wiki/Series-parallel_partial_order

like image 324
Trevor Hickey Avatar asked Jun 03 '15 07:06

Trevor Hickey


People also ask

How do you find the voltage across a series in components?

How do you calculate voltage in a series circuit? Voltage for each circuit element in a series circuit can be calculated by applying Ohm's law: V=R*I. Also, if the element's resistance is unknown, the Kirchhoff loop rule helps to calculate the voltage across such a circuit element.

How do you calculate voltage across?

Now that we know the amperage for the circuit (remember the amperage does not change in a series circuit) we can calculate what the voltage drops across each resistor is using Ohm's Law (V = I x R).


1 Answers

Some circuits cannot even be analyzed in terms of series and parallel, for example a circuit which includes the edges of a cube (there's some code at the bottom of that web page that might be helpful; I haven't looked at it). Another example that can't be analyzed into series/parallel is a pentagon/pentagram shape.

A more robust solution than thinking about series and parallel is to use Kirchhoff's laws.

  1. You need to make variables for the currents in each linear section of the circuit.
  2. Apply Kirchhoff's current law (KCL) to nodes where linear sections meet.
  3. Apply Kirchhoff's voltage law (KVL) to as many cycles as you can find.
  4. Use Gaussian elimination to solve the resulting linear system of equations.

The tricky part is identifying cycles. In the example you give, there are three cycles: through battery and left resistor, battery and right resistor, and through left and right resistors. For planar circuits it's not too hard to find a complete set of cycles; for three dimensional circuits, it can be hard.

You don't actually need all the cycles. In the above example, two would be enough (corresponding to the two bounded regions into which the circuit divides the plane). Then you have three variables (currents in three linear parts of the circuit) and three equations (sum of currents at the top node where three linear segments meet, and voltage drops around two cycles). That is enough to solve the system for currents by Gaussian elimination, then you can calculate voltages from the currents.

If you throw in too many equations (e.g., currents at both nodes in your example, and voltages over three cycles instead of two), things will still work out: Gaussian elimination will just eliminate the redundancies and you'll still get the unique, correct answer. The real problem is if you have too few equations. For example, if you use KCL on the two nodes in your example and KVL around just one cycle, you'll have three equations, but one is redundant, so you'll only really have two independent equations, which is not enough. So I would say throw in every equation you can find and let Gaussian elimination sort it out.

And hopefully you can restrict to planar circuits, for which it is easy to find a nice set of cycles. Otherwise you'll need a graph cycle enumeration algorithm. I'm sure you can find one if you need it.

like image 64
Edward Doolittle Avatar answered Oct 12 '22 06:10

Edward Doolittle