Title: | Electrical Properties of Resistor Networks |
---|---|
Description: | Electrical properties of resistor networks using matrix methods. |
Authors: | Robin K. S. Hankin [aut, cre] |
Maintainer: | Robin K. S. Hankin <[email protected]> |
License: | GPL-2 |
Version: | 1.0-32 |
Built: | 2025-01-13 03:31:45 UTC |
Source: | https://github.com/robinhankin/resistorarray |
Electrical properties of resistor networks using matrix methods.
The DESCRIPTION file:
Package: | ResistorArray |
Version: | 1.0-32 |
Date: | 2019-01-30 |
Title: | Electrical Properties of Resistor Networks |
Description: | Electrical properties of resistor networks using matrix methods. |
Authors@R: | person(given=c("Robin", "K. S."), family="Hankin", role = c("aut","cre"), email="[email protected]", comment = c(ORCID = "0000-0001-5982-0415")) |
URL: | https://github.com/RobinHankin/ResistorArray.git |
BugReports: | https://github.com/RobinHankin/ResistorArray/issues |
License: | GPL-2 |
Repository: | https://robinhankin.r-universe.dev |
RemoteUrl: | https://github.com/robinhankin/resistorarray |
RemoteRef: | HEAD |
RemoteSha: | adef27288ce68b16d4819b38043fca862b09ead9 |
Author: | Robin K. S. Hankin [aut, cre] (<https://orcid.org/0000-0001-5982-0415>) |
Maintainer: | Robin K. S. Hankin <[email protected]> |
Index of help topics:
ResistorArray-package Electrical Properties of Resistor Networks SquaredSquare A Squared square Wu Wu's resistance matrix array.resistance Resistance between two arbitrary points on a regular lattice of unit resistors circuit Mensurates a circuit given potentials of some nodes and current flow into the others cube Specimen conductance matrices currents Calculates currents in an arbitrary resistor array hypercube Conductance matrix of a Boolean hypercube ladder Jacob's ladder of resistors makefullmatrix Conductance matrix for a lattice of unit resistors platonic Adjacency of platonic solids resistance Resistance for arbitrarily connected networks of resistors series Conductance matrix for resistors in series
Robin K. S. Hankin [aut, cre] (<https://orcid.org/0000-0001-5982-0415>)
R.K.S. Hankin 2006. "Resistor networks in R: introducing the 'ResistorArray' package". R News, volume 6, number 2.
# resistance between opposite corners of a skeleton cube: resistance(cube(),1,7) # known to be 5/6 Ohm # resistance of a Jacob's ladder: resistance(ladder(60),1,2) # should be about (sqrt(5)-1)/2 # Google aptitude test: array.resistance(1,2,15,17) # analytical answer 4/pi-1/2
# resistance between opposite corners of a skeleton cube: resistance(cube(),1,7) # known to be 5/6 Ohm # resistance of a Jacob's ladder: resistance(ladder(60),1,2) # should be about (sqrt(5)-1)/2 # Google aptitude test: array.resistance(1,2,15,17) # analytical answer 4/pi-1/2
Given two points on a regular lattice of electrical nodes joined by unit
resistors (as created by makefullmatrix()
), returns the
resistance between the two points, or (optionally) the potentials of
each lattice point when unit current is fed into the first node, and the
second is earthed.
array.resistance(x.offset, y.offset, rows.of.resistors, cols.of.resistors, give.pots = FALSE)
array.resistance(x.offset, y.offset, rows.of.resistors, cols.of.resistors, give.pots = FALSE)
x.offset |
Earthed node is at |
y.offset |
Earthed node is at |
rows.of.resistors |
Number of rows of resistors in the network (positive integer) |
cols.of.resistors |
Number of columns of resistors in the network (positive integer) |
give.pots |
Boolean, with |
Note that the electrical network is effectively toroidal.
Robin K. S. Hankin
jj.approximate <- array.resistance(1,2,15,17,give=FALSE) jj.exact <- 4/pi-1/2 print(jj.exact - jj.approximate) persp(array.resistance(4,0,14,16,give=TRUE),theta=50,r=1e9,expand=0.6)
jj.approximate <- array.resistance(1,2,15,17,give=FALSE) jj.exact <- 4/pi-1/2 print(jj.exact - jj.approximate) persp(array.resistance(4,0,14,16,give=TRUE),theta=50,r=1e9,expand=0.6)
Given a conductance matrix, a vector of potentials at each node, and a
vector of current inputs at each node (NA
being interpreted as
“unknown”), this function determines the potentials at each
node, and the currents along each edge, of the whole circuit.
circuit(L, v, currents=0, use.inverse=FALSE, give.internal=FALSE)
circuit(L, v, currents=0, use.inverse=FALSE, give.internal=FALSE)
L |
Conductance matrix |
v |
Vector of potentials; one element per node. Elements
with |
currents |
Vector of currents fed into each node. The only
elements of this vector that are used are those that correspond to a
node with free potential (use Observe that feeding zero current into a node at free potential is perfectly acceptable (and the usual case) |
use.inverse |
Boolean, with default The default option should be faster most of the time, but YMMV |
give.internal |
Boolean, with |
Depending on the value of Boolean argument give.internal
,
return a list of either 2 or 4 elements:
potentials |
A vector of potentials. Note that the potentials of the
nodes whose potential was specified by input argument |
currents |
Vector of currents required to maintain the system
with the potentials specified by input argument |
internal.currents |
Matrix showing current flow from node to
node. Element |
power |
The power dissipated at each edge |
total.power |
Total power dissipated over the resistor network |
The SI unit of potential is the “Volt”; the SI unit of current is the “Ampere”
Robin K. S. Hankin
#reproduce first example on ?cube: v <- c(0,rep(NA,5),1,NA) circuit(cube(),v) circuit(cube(),v+1000) # problem: The nodes of a skeleton cube are at potentials # 1,2,3,... volts. What current is needed to maintain this? Ans: circuit(cube(),1:8) #sanity check: maintain one node at 101 volts: circuit(cube(),c(rep(NA,7),101)) #now, nodes 1-4 have potential 1,2,3,4 volts. Nodes 5-8 each have one #Amp shoved in them. What is the potential of nodes 5-8, and what #current is needed to maintain nodes 1-4 at their potential? # Answer: v <- c(1:4,rep(NA,4)) currents <- c(rep(NA,4),rep(1,4)) circuit(cube(),v,currents) # Now back to the resistance of a skeleton cube across its sqrt(3) # diagonal. To do this, we hold node 1 at 0 Volts, node 7 at 1 Volt, # and leave the rest floating (see argument v below); we # seek the current at nodes 1 and 7 # and insist that the current flux into the other nodes is zero # (see argument currents below): circuit(L=cube(),v=c(0,NA,NA,NA,NA,NA,1,NA),currents=c(NA,0,0,0,0,0,NA,0)) # Thus the current is 1.2 ohms and the resistance (from V=IR) # is just 1/1.2 = 5/6 ohms, as required.
#reproduce first example on ?cube: v <- c(0,rep(NA,5),1,NA) circuit(cube(),v) circuit(cube(),v+1000) # problem: The nodes of a skeleton cube are at potentials # 1,2,3,... volts. What current is needed to maintain this? Ans: circuit(cube(),1:8) #sanity check: maintain one node at 101 volts: circuit(cube(),c(rep(NA,7),101)) #now, nodes 1-4 have potential 1,2,3,4 volts. Nodes 5-8 each have one #Amp shoved in them. What is the potential of nodes 5-8, and what #current is needed to maintain nodes 1-4 at their potential? # Answer: v <- c(1:4,rep(NA,4)) currents <- c(rep(NA,4),rep(1,4)) circuit(cube(),v,currents) # Now back to the resistance of a skeleton cube across its sqrt(3) # diagonal. To do this, we hold node 1 at 0 Volts, node 7 at 1 Volt, # and leave the rest floating (see argument v below); we # seek the current at nodes 1 and 7 # and insist that the current flux into the other nodes is zero # (see argument currents below): circuit(L=cube(),v=c(0,NA,NA,NA,NA,NA,1,NA),currents=c(NA,0,0,0,0,0,NA,0)) # Thus the current is 1.2 ohms and the resistance (from V=IR) # is just 1/1.2 = 5/6 ohms, as required.
Various conductance matrices for simple resistor configurations including a skeleton cube
cube(x=1) octahedron(x=1) tetrahedron(x=1) dodecahedron(x=1) icosahedron(x=1)
cube(x=1) octahedron(x=1) tetrahedron(x=1) dodecahedron(x=1) icosahedron(x=1)
x |
Resistance of each edge. See details section |
Function cube()
returns an eight-by-eight conductance matrix
for a skeleton cube of 12 resistors. Each row/column corresponds to
one of the 8 vertices that are the electrical nodes of the compound
resistor.
In one orientation, node 1 has position 000, node 2 position 001, node 3 position 101, node 4 position 100, node 5 position 010, node 6 position 011, node 7 position 111, and node 8 position 110.
In cube()
, x
is a vector of twelve elements (a scalar
argument is interpreted as the resistance of each resistor)
representing the twelve resistances of a skeleton cube. In the
orientation described below, the elements of x
correspond to
,
,
,
,
,
,
,
,
,
,
,
(here
is the resistance between node
and
). This series is obtainable by reading the rows given by
platonic("cube")
. The pattern is general: edges are ordered
first by the row number , then column number
.
In octahedron()
, x
is a vector of twelve elements (again
scalar argument is interpreted as the resistance of each resistor)
representing the twelve resistances of a skeleton octahedron. If node 1
is “top” and node 6 is “bottom”, the elements of x
correspond to
,
,
,
,
,
,
,
,
,
,
,
.
This may be read off from the rows of
platonic("octahedron")
.
To do a Wheatstone bridge, use tetrahedron()
with one of the
resistances Inf
. As a worked example, let us determine the
resistance of a Wheatstone bridge with four resistances one ohm and
one of two ohms; the two-ohm resistor is one of the ones touching the
earthed node.
To do this, first draw a tetrahedron with four nodes. Then say we
want the resistance between node 1 and node 3; thus edge 1-3 is the
infinite one. platonic("tetrahedron")
gives us the order of
the edges: 12, 13, 14, 23, 24, 34. Thus the conductance matrix is
given by jj <- tetrahedron(c(2,Inf,1,1,1,1))
and the resistance
is given by resistance(jj,1,3)
[compare the analytical answer
of 117/99 ohms].
Robin K. S. Hankin
F. J. van Steenwijk “Equivalent resistors of polyhedral resistive structures”, American Journal of Physics, 66(1), January 1988.
resistance(cube(),1,7) #known to be 5/6 ohm resistance(cube(),1,2) #known to be 7/12 ohm resistance(octahedron(),1,6) #known to be 1/2 ohm resistance(octahedron(),1,5) #known to be 5/12 ohm resistance(dodecahedron(),1,5)
resistance(cube(),1,7) #known to be 5/6 ohm resistance(cube(),1,2) #known to be 7/12 ohm resistance(octahedron(),1,6) #known to be 1/2 ohm resistance(octahedron(),1,5) #known to be 5/12 ohm resistance(dodecahedron(),1,5)
Calculates currents in an arbitrary resistor array
currents(L, earth.node, input.node) currents.matrix(L, earth.node, input.node)
currents(L, earth.node, input.node) currents.matrix(L, earth.node, input.node)
L |
Lagrangian conductance matrix |
earth.node |
Number of node that is earthed (that is, at a potential of zero) |
input.node |
Number of node that has current put into it (a notional one Amp) |
The methods used by the two functions are different; see documentation for
resistance()
for further details on input args 2 and 3
Function currents()
returns a three column matrix, each row of
which corresponds to an edge. The first two
columns show the node numbers specifying the edge, and the third shows
the current flowing along it.
Function current.matrix()
uses a different method to return a
matrix of the same size as the conductance matrix L
. Each
element of the returned matrix shows the current flowing along the
specified edge.
This function is essentially a simplified version of
circuit()
.
Robin K. S. Hankin
currents(cube(),1,7) currents.matrix(cube(),1,7) #check above solution: print out the currents flowing into each node: zapsmall(apply(currents.matrix(cube(),1,7),1,sum))
currents(cube(),1,7) currents.matrix(cube(),1,7) #check above solution: print out the currents flowing into each node: zapsmall(apply(currents.matrix(cube(),1,7),1,sum))
Returns the conductance matrix of an n-dimensional hypercube
hypercube(n)
hypercube(n)
n |
Integer giving the dimension of the hypercube |
The row and columnnames give the coordinates of each node (which are in binary order)
Returns a conductance matrix
In the case of a 3D cube, the nodes are in a different order from that
returned by cube()
(which uses Maple's scheme).
Robin K. S. Hankin
hypercube(4) resistance(hypercube(5),1,32) # cf exact answer of 8/15 resistance(hypercube(5),1,2) # cf exact answer of n <- 5; (2^n-1)/(n*2^(n-1))=31/80
hypercube(4) resistance(hypercube(5),1,32) # cf exact answer of 8/15 resistance(hypercube(5),1,2) # cf exact answer of n <- 5; (2^n-1)/(n*2^(n-1))=31/80
A potentially infinite resistor network.
Consider node 1 to be Earth. Nodes are each connected to node 1 by a resistor. For
, node
is connected to node
.
ladder(n, x = 1, y = 1, z = NULL)
ladder(n, x = 1, y = 1, z = NULL)
n |
Number of nodes |
x |
Resistance of resistors connected to node 1 (earth). Standard recycling rules are used |
y |
Resistance of the other resistors (ie those not connected to earth). Standard recycling rules are used |
z |
Resistance of all resistors in the network. If
non- |
Returns a standard conductance matrix
Robin K. S. Hankin
# Resistance of an infinite Jacob's ladder with unit resistors is known # to be (sqrt(5)-1)/2: phi <- (sqrt(5)-1)/2 resistance(ladder(20),1,2) - phi resistance(ladder(60),1,2) - phi Wu(ladder(20))[1,2]-phi # z is the resistance of all the resistors: ladder(n=8,z=1/(1:13)) # See how node 1 is the "earth", with resistors of conductance 1,2,...,7 # connecting to nodes 2-8. Then nodes 5 & 6, say, are connected by a # resistor of conductance 11.
# Resistance of an infinite Jacob's ladder with unit resistors is known # to be (sqrt(5)-1)/2: phi <- (sqrt(5)-1)/2 resistance(ladder(20),1,2) - phi resistance(ladder(60),1,2) - phi Wu(ladder(20))[1,2]-phi # z is the resistance of all the resistors: ladder(n=8,z=1/(1:13)) # See how node 1 is the "earth", with resistors of conductance 1,2,...,7 # connecting to nodes 2-8. Then nodes 5 & 6, say, are connected by a # resistor of conductance 11.
Conductance matrix for a lattice of unit resistors
makefullmatrix(R, C) makefullmatrix_strict(R, C,toroidal)
makefullmatrix(R, C) makefullmatrix_strict(R, C,toroidal)
R |
Number of rows of nodes |
C |
Number of columns of nodes |
toroidal |
Boolean, with |
The array produced by makefullmatrix_strict(R,C,TRUE)
is
toroidally connected.
Function makefullmatrix()
is not entirely straightforward. The
array produced is sort of toroidally connected. I regard this
function as the canonical one because it is more elegant (see example
image). Consider, for concreteness, the case with four rows and seven
columns of nodes giving 28 nodes altogether. Number these columnwise
so the top row is 1,5,9,13,17,21,25. Then number corresponds
to the row
and column
of the returned matrix.
Now, ‘interior’ nodes are as expected: node 6, for example, is connected to 2,5,10,7. And the wrapping is as expected in the horizontal: 1-25, 2-26, 3-27, and 4-28, are all connected.
However, the vertical wrapping is not as might be expected. One might
expect node 9, say, to be connected to 5,10 13,12; but in fact node 9
is connected to nodes 5,8,10,13. So there is a Hamiltonian path
comprising entirely of vertical connections (function
makefullmatrix_strict(R,C,TRUE)
returns the “expected”
adjacency graph).
For the arrays returned by functions documented here, one can
determine pairwise resistances using function
array.resistance()
.
Returns matrix of size . Note that this
matrix is singular.
Robin K. S. Hankin
makefullmatrix(3,3) image(makefullmatrix(4,7)) # A beautiful natural structure image(makefullmatrix_strict(4,7,TRUE)) # A dog's breakfast
makefullmatrix(3,3) image(makefullmatrix(4,7)) # A beautiful natural structure image(makefullmatrix_strict(4,7,TRUE)) # A dog's breakfast
Gives the adjacency indices of the five Platonic solids.
platonic(a)
platonic(a)
a |
String containing name of one of the five Platonic solids, viz “tetrahedron”, “cube”, “octahedron”, “dodecahedron”, “icosahedron” |
Returns a two column matrix a
, the rows of which show the two
vertices of an edge. Only
edges with a[i,1]<i[i,2]
are included.
For the dodecahedron and icosahedron, the nodes are numbered as per Maple's scheme.
Robin K. S. Hankin
platonic("octahedron")
platonic("octahedron")
Given a resistance matrix, return the resistance between two specified nodes.
resistance(A, earth.node, input.node, current.input.vector=NULL, give.pots = FALSE)
resistance(A, earth.node, input.node, current.input.vector=NULL, give.pots = FALSE)
A |
Resistance matrix |
earth.node |
Number of node that is earthed |
input.node |
Number of node at which current is put in: a nominal 1 Amp |
current.input.vector |
Vector of
currents that are fed into each node. If supplied, overrides the
value of Setting this argument to |
give.pots |
Boolean, with |
The function's connection to resistor physics is quite opaque. It is effectively a matrix version of Kirchoff's law, that the (algebraic) sum of currents into a node is zero.
This function is essentially a newbie wrapper for circuit()
,
which solves a much more general problem. The function documented
here, however, is clearer and (possibly) faster; it also gives an
explicit resistance if give.pots
is not set.
Use function currents()
(or currents.matrix()
) to
calculate the currents flowing in the resistor array.
Robin K. S. Hankin
B. Bollob\'as, 1998. Modern Graph Theory. Springer.
F. Y. Wu, 2004. “Theory of resistor networks: the two point resistance”, Journal of Physics A, volume 37, pp6653-6673
G. Venezian 1994. “On the resistance between two points on a grid”, American Journal of Physics, volume 62, number 11, pp1000-1004.
J. Cserti 2000. “Application of the lattice Green's function for calculating the resistance of an infinite network of resistors”, American Journal of Physics, volume 68, number 10, p896-906
D. Atkinson and F. J. van Steenwijk 1999. “Infinite resistive lattices”, American Journal of Physics, volume 67, number 6, pp486-492
resistance(cube(),earth.node=1, input.node=7) #known to be 5/6 ohm resistance(cube(),1,7, give=TRUE)
resistance(cube(),earth.node=1, input.node=7) #known to be 5/6 ohm resistance(cube(),1,7, give=TRUE)
Conductance matrix for resistors of arbitrary resistance in series
series(x)
series(x)
x |
The resistances of the resistors. |
Note: if length(x)=n
, the function returns a
conductance matrix of size n+1
by n+1
, because n
resistors in series have n+1
nodes to consider.
Robin K. S. Hankin
## Resistance of four resistors in series: resistance(series(rep(1,5)),1,5) ##sic! FOUR resistors have FIVE nodes ## What current do we need to push into a circuit of five equal ## resistors in order to maintain the potentials at 1v, 2v, ..., 6v? circuit(series(rep(1,5)),v=1:6) #(obvious, isn't it?) ## Now, what is the resistance matrix of four nodes connected in series ## with resistances 1,2,3 ohms? Wu(series(1:3)) #Yup, obvious again.
## Resistance of four resistors in series: resistance(series(rep(1,5)),1,5) ##sic! FOUR resistors have FIVE nodes ## What current do we need to push into a circuit of five equal ## resistors in order to maintain the potentials at 1v, 2v, ..., 6v? circuit(series(rep(1,5)),v=1:6) #(obvious, isn't it?) ## Now, what is the resistance matrix of four nodes connected in series ## with resistances 1,2,3 ohms? Wu(series(1:3)) #Yup, obvious again.
A resistor network corresponding to a squared square
data(SquaredSquare)
data(SquaredSquare)
Returns a conductance matrix
The nodes are ordered so that the potentials are in increasing order.
Bollobas 1998
data(SquaredSquare) resistance(SquaredSquare,1,13) # should be 1 circuit(L=SquaredSquare,currents=c(NA,rep(0,11),1),v=c(0,rep(NA,12)))$potentials # should be in increasing order
data(SquaredSquare) resistance(SquaredSquare,1,13) # should be 1 circuit(L=SquaredSquare,currents=c(NA,rep(0,11),1),v=c(0,rep(NA,12)))$potentials # should be in increasing order
Returns a matrix M
with M[i,j]
is the resistance between
nodes i
and j
.
Wu(L)
Wu(L)
L |
Laplacian conductance matrix |
Evaluates Wu's resistance matrix, as per his theorem on page 6656.
Returns a matrix of the same size as L
, but whose elements are
the effective resistance between the nodes.
In the function, the sum is not from 2 to n
as in Wu, but
from 1 to , because
eigen()
orders the
eigenvalues from largest to smallest, not smallest to largest.
Robin K. S. Hankin
F. Y. Wu, 2004. “Theory of resistor networks: the two point resistance”, Journal of Physics A, volume 37, pp6653-6673
Wu(cube()) Wu(cube())[1,2] - resistance(cube(),1,2) Wu(series(1:7)) # observe how resistance between, say, nodes 2 # and 5 is 9 (=2+3+4)
Wu(cube()) Wu(cube())[1,2] - resistance(cube(),1,2) Wu(series(1:7)) # observe how resistance between, say, nodes 2 # and 5 is 9 (=2+3+4)