Skip to main content
Contents
Dark Mode Prev Up Next
\(\newcommand{\vect}[1]{\mathbf{#1}}
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section 3.8 Using Python in AC circuits
Just as with DC circuits, we can let Python do most of the mathematical manipulation for us when determining circuit behavior. As an example, we’ll examine the behavior of the circuit in
Figure 3.8.1 .
Figure 3.8.1. A generic LRC circuit. Let \(R=1\text{k}\Omega\text{,}\) \(C=1 \mu\text{F}\text{,}\) and \(L=1\text{mH}\) for our analysis.
Using Kirchhoff’s laws and the branch method, we find the following equations
\begin{align*}
\tilde{I}_1 - \tilde{I}_2 - \tilde{I}_3 \amp = 0 \\
\tilde{V}_\text{in} - R \tilde{I}_1 - \frac{1}{i \omega C} \tilde{I}_2 \amp = 0 \\
\frac{1}{i \omega C}\tilde{I}_2 - i\omega L \tilde{I}_3 \amp = 0 \text{.}
\end{align*}
Rearranging these equations
\begin{align*}
\tilde{I}_1 - \tilde{I}_2 - \tilde{I}_3 \amp = 0 \\
- R \tilde{I}_1 + \frac{i}{\omega C} \tilde{I}_2 \amp = - \tilde{V}_\text{in} \\
- \frac{i}{\omega C}\tilde{I}_2 - i\omega L \tilde{I}_3 \amp = 0
\end{align*}
facilitates writing these equations as a matrix equation
\begin{equation*}
\begin{pmatrix}
1 \amp - 1 \amp - 1 \\
-R_1 \amp \frac{i}{\omega C} \amp 0 \\
0 \amp -\frac{i}{\omega C} \amp - i\omega L
\end{pmatrix}
\begin{pmatrix} \tilde{I}_1 \\ \tilde{I}_2 \\ \tilde{I}_3 \end{pmatrix} =
\begin{pmatrix} 0 \\ -\tilde{V}_\text{in} \\ 0 \end{pmatrix}
\end{equation*}
which can be solved using Python:
Example 3.8.2 . Bandgap RLC Circuit.
Figure 3.8.3. Bandgap RLC Circuit. Plot the gain and phase curves for the circuit in
Figure 3.8.3 .
Answer . Solution .
If we examine the circuit in
Figure 3.8.3 , we find that it is exactly the same circuit as we examined in
Figure 3.8.1 except we are now measuring
\(V_\text{out}\) across the resistor instead of across the inductor and capacitor. This means that the matrix equation will be identical, as will our solutions for all of the currents.
Example 3.8.4 . RLC Circuit Analysis Using Differential Equations and Python.