Learn R Programming

ResistorArray (version 1.0-7)

circuit: Mensurates a circuit given potentials of some nodes

Description

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 and currents over the whole circuit.

Usage

circuit(L, v, currents=0, give.internal=FALSE)

Arguments

L
Conductance matrix
v
Vector of potentials; one element per node of the conductance matrix. Elements with NA are interpreted as free nodes, that is, nodes that are not kept at a fixed potential. The potential of these nodes is well
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 NA for nodes that are at a specified potential). The idea is that each node has
give.internal
Boolean, with TRUE meaning to return also a matrix showing the node to node currents, and default FALSE meaning to omit this.

Value

  • A list of 2 or 4 elements, depending on argument give.internal is FALSE or TRUE.
  • potentialsA vector of potentials. Note that the potentials of the nodes whose potential was specified by input argument v retain their original potentials; symbolically all(potentials[!is.na(v)] == v[!is.na(v)]).
  • currentsVector of currents required to maintain the system with the potentials specified by input argument v
  • internal.currentsMatrix showing current flow from node to node. Element [i,j] shows current flow from node i to node j.
  • powerThe power dissipated at each edge
  • total.powerTotal power dissipated over the resistor network

See Also

resistance

Examples

Run this code
#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)

Run the code above in your browser using DataLab