Theory

Solving

pycircuit.circuit uses the [MNA] (Modified Nodal Analysis) formulation to solve the voltages and currents of an electric circuit.

For a circuit with N nodes and M independent voltage sources or inductors, the unknown quantities in the MNA method can be written as:

\[\begin{split}x = \left( \begin{array}{c} v\\ j \end{array} \right)\end{split}\]

where \(v\) is a vector of length N that contains the node voltages and \(j\) is a vector of branch currents through independent voltage sources and inductors.

The behaviour of a non-linear lumped circuit with energy storage elements such as inductors and capacitors can be found from the solution of a system of differential equations:

(1)\[\frac{d}{dt} q(v(t)) + i(v(t)) + u(t) = 0\]

Where \(t\) denotes time, \(v(t)\) is a vector of node voltages and terminal currents. \(q(\cdot)\) is a function that maps \(v(t)\) to sums of capacitive charge or inductive fluxes at a node, \(i(\cdot)\) is a function that maps the \(x(t)\) vector to a sum of currents at a node and finally \(u(t)\) is the input to the system.

If the circuit is linear or linearized around the operating point, equation (1) can be rewritten in matrix form as:

(2)\[C \frac{d}{dt} x(t) + G x(t) + u(t) = 0\]

where the matrix elements are given by:

\[\begin{split}C_{j, k} = \frac{\partial q_j}{\partial x_k} \\ G_{j, k} = \frac{\partial i_j}{\partial x_k}\end{split}\]

AC analysis

In an AC analysis the stimuli the circuit is a complex sinusoid, that is:

\[u(t) = A e^{j (\omega t + \phi)}\]

The solution can be found by applying the Laplace transform to equation (2):

\[\begin{split}\begin{array}{ll} \LARGE{\mathcal{L}} \left\{ C \frac{d}{d t} x(t) + G x(t) + u(t) \right\} = \large{\LARGE{\mathcal{L}}} \left\{ 0 \right\} & \Rightarrow \\ s C X(s) + G X(s) + U(s) = 0 & \Rightarrow\\ (G + s C) X(s) + U(s) = 0 & \Rightarrow\\ X(s) = -(G + s C)^{- 1} U(s) \end{array}\end{split}\]