\section{Circuits}

An \textit{electrical circuit} is a graph with a few extra properties,
called \textit{current}, \textit{voltage}, and \textit{resistance}. \par
In the definitions below, let $X$ be the set of nodes in a circuit.


\begin{itemize}[itemsep=3mm]
	\item \textbf{Voltage} is a function $V: X \to \mathbb{R}$ that assigns a number to each node of our graph. \par
	In any circuit, we pick a \say{ground} node, and define the voltage\footnotemark{} there as 0. \par
	We also select a \say{source} node, and define its voltage as 1. \par

	\vspace{1mm}

	Intuitively, you could say we're connecting the ends of a 1-volt battery to our source and ground nodes.

	\footnotetext{
		In the real world, voltage is always measured \textit{between two points} on a circuit.
		Voltage is defined as the \textit{difference} in electrical charge between two points.
		Hence, voltage is a function of two nodes.

		\vspace{2mm}

		Note that this is different than current and resistance, which aren't functions
		of two arbitrary nodes --- rather, they are functions of \textit{edges}
		(i.e, two adjacent nodes).
	}


	\item \textbf{Current} is a function $I: X^2 \to \mathbb{R}$ that assigns a number to each
	\textit{oriented edge} in our graph. An \say{oriented edge} is just an ordered pair of nodes $(n_1, n_2)$. \par

	\vspace{1mm}

	Current through an edge $(a, b)$ is a measure of the flow of charge from $a$ to $b$. \par
	Naturally, $I(a, b) = -I(b, a)$.


	\item \textbf{Resistance} is a function $R: X^2 \to \mathbb{R}^+_0$ that represents a certain edge's
	resistance to the flow of current through it. \par
	Resistance is a property of each \textit{link} between nodes, so order doesn't matter: $R(a, b) = R(b, a)$.
\end{itemize}

\vspace{2mm}

It is often convenient to compare electrical circuits to systems of pipes. Say we have a pipe from point $A$ to point $B$.
The size of this pipe represents resistance (smaller pipe $\implies$ more resistance), the pressure between $A$ and $B$
is voltage, and the speed water flows through it is to current.


\definition{Ohm's law}
With this \say{pipe} analogy in mind, you may expect that voltage, current, and resistance are related:
if we make our pipe bigger (and change no other parameters), we'd expect to see more current. This is indeed
the case! Any circuit obeys \textit{Ohm's law}, stated below:
$$
	V(a, b) = I(a,b) \times R(a,b)
$$

This handout uses two notations for voltage: two-variable $V(a, b)$ and one-variable $V(a)$. \par
The first represents the voltage between points $a$ and $b$, better reflecting reality (see the footnote below).
The second measures the voltage between $a$ and ground, and is more convenient to use in equations.
\textbf{Try to use the single-variable notation in your equations.}
Convince yourself that $V(a, b) = V(a) - V(b)$.

\vfill


\definition{Kirchoff's law}
The second axiom of electrical circuits is also fairly simple. \textit{Kirchoff's law} states that the sum of all currents connected to
a given edge is zero. You can think of this as \say{conservation of mass}: nodes in our circuit do not create or
destroy electrons, they simply pass them around to other nodes.\par
Formally, we can state this as follows:

\vspace{2mm}

Let $x$ be a node in our circuit and $N_x$ the set of its neighbors. We than have
$$
	\sum_{b \in N_x} I(x, b) = 0
$$
which must hold at every node \textbf{except the source and ground vertices.} \par
\hint{Keep this exception in mind, it is used in a few problems later on.}

\vfill
\pagebreak



\begin{instructornote}
	Be aware that some students may not be comfortable with these concepts from physics,
	nor with the circuit notation on the next page.

	\vspace{2mm}

	It may be a good idea to give the class a quick lecture on this topic,
	explaining the basics of electronic circuits and circuit diagrams.

	\vspace{2mm}

	Things to cover:
	\begin{itemize}
		\item All the definitions on the previous page, in detail.
		\item What's an Ohm, an Amp, a Volt?
		\item Measuring voltage. Why is $V(a, b) = V(a) - V(b)$?
		\item What does the $\Omega$ in the picture below mean?
		\item Circuit symbols in the diagram below.
	\end{itemize}

	\vspace{2mm}

	You could also draw connections to the graph flow handout,
	if the class covered it before.
\end{instructornote}


Consider the circuit below. \textbf{This the graph from \ref{firstgraph}}, turned into a circuit by:
\begin{itemize}
	\item Replacing all edges with $1\Omega$ resistors
	\item Attaching a 1 volt battery between $A$ and $B$
\end{itemize}
\vspace{2mm}
Note that the battery between $A$ and $B$ isn't really an edge.
It exists only to create a potential difference between the two nodes.

\begin{center}
\begin{circuitikz}[american voltages]
	\draw
		(0,0) node[above left] {$A$ (source)}
		to[R, l=$1\Omega$, *-*] (2,0) node[above] {$x$}
		to[R, l=$1\Omega$, *-*] (4,0) node[above] {$y$}
		to[R, l=$1\Omega$, *-*] (6,0) node[above right] {$B$ (ground)}
		to[short] (6, -1) node[below] {$-$}
		to[battery,invert,l={1 Volt}] (0, -1) node[below] {$+$}
		to[short] (0, 0)
	;
\end{circuitikz}
\end{center}

\problem{}<onecurrents>
From the circuit diagram above, we immediately know that $V(A) = 1$ and $V(B) = 0$. \par
What equations related to the currents out of $x$ and $y$ does Kirchoff's law give us? \par
\hint{Current into $x$ = current out of $x$}

\vfill




\problem{}
Use Ohm's law to turn the equations from \ref{onecurrents} into equations about voltage and resistance. \par
Find an expression for $V(x)$ and $V(y)$ in terms of other voltages, then solve the resulting system of equations.
Does your result look familiar?

\begin{solution}
	\setlength{\abovedisplayskip}{0pt} % Fix spacing on top
	\begin{flalign*}
		V(x) &= \frac{V(A) - V(y)}{2} &&\\
		V(y) &= \frac{V(x) - V(B)}{2} &&
	\end{flalign*}
\end{solution}

\vfill
\pagebreak
