circuit            package:ResistorArray            R Documentation

_M_e_n_s_u_r_a_t_e_s _a _c_i_r_c_u_i_t _g_i_v_e_n _p_o_t_e_n_t_i_a_l_s _o_f _s_o_m_e _n_o_d_e_s _a_n_d _c_u_r_r_e_n_t
_f_l_o_w _i_n_t_o _t_h_e _o_t_h_e_r_s

_D_e_s_c_r_i_p_t_i_o_n:

     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.

_U_s_a_g_e:

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

_A_r_g_u_m_e_n_t_s:

       L: Conductance matrix

       v: Vector of potentials; one element per node.  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 defined by the other nodes in the problem.  Note that
          such nodes must have current inputs (which may be zero)
          specified by argument 'currents'.

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
          *either* a specified voltage, *or* a specified current is fed
          into it; not both, and not neither.

          Observe that feeding zero current into a node at free
          potential is perfectly acceptable (and the usual case).

use.inverse: Boolean, with default 'FALSE' meaning to use 'solve(A,b)'
          and 'TRUE' meaning to use 'solve(A)',  thus incurring the
          penalty of evaluating a matrix inverse, which is typically to
          be avoided if possible.

          The default option should be faster most of the time, but
          YMMV

give.internal: Boolean, with 'TRUE' meaning to return also a matrix
          showing the node-to-node currents, and default 'FALSE'
          meaning to omit this.

_V_a_l_u_e:

     Depending on the value of Boolean argument 'give.internal',
     returns  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 'v'
          retain their original potentials; symbolically
          'all(potentials[!is.na(v)] == v[!is.na(v)])'.

currents: Vector of currents required to maintain the system with the
          potentials specified by input argument 'v'

internal.currents: Matrix showing current flow from node to node. 
          Element '[i,j]' shows current flow from node 'i' to node 'j'.
           This and the next two elements only supplied if argument
          'give.internal' is 'TRUE'.

   power: The power dissipated at each edge

total.power: Total power dissipated over the resistor network

     normal-bracket50bracket-normal

_N_o_t_e:

     The SI unit of potential is the "Volt"; the SI unit of current is
     the "Ampere"

_A_u_t_h_o_r(_s):

     Robin K. S. Hankin

_S_e_e _A_l_s_o:

     'resistance'

_E_x_a_m_p_l_e_s:

     #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.

