\documentclass{article}

\title{Power Electronics Homework 1}
\author{Aidan Sharpe}

\usepackage{circuitikz}
\usepackage{amsmath}
\usepackage{listings}

\begin{document}
\maketitle
\date{}

\section{Initial Circuit}
\begin{center}
\begin{circuitikz}[american voltages]
\draw
(0,0) to [short] (1,0) to [empty diode, l=$D_1$] (3,0) to [open, v=$V_d$] (3,-2)
(3,0) to [short, american inductor, l=$L_1$, i=$i_L$] (6,0)
to [short, american resistor, l_=$R_1$, v^=$V_R$] (6,-2)
to [short] (0,-2) 
(0,0) to [vsourcesin, v_=$V_s$] (0,-2);
\end{circuitikz}
\end{center}

$$V_s(t) = 110 \sqrt{2} \cos(2\pi f t)$$
$$f = 60 \text{[Hz]}$$
$$L_1 = 20 \text{[mH]}$$
$$R_1 = 10 [\Omega]$$

\section{Diode is "On"}
\begin{center}
\begin{circuitikz}[american voltages]
\draw
(0,0) to [closing switch] (3,0) to [open, v=$V_d$] (3,-2)
(3,0) to [short, american inductor, l=$L_1$, i=$i_L$] (6,0)
to [short, american resistor, l_=$R_1$, v^=$V_R$] (6,-2)
to [short] (0,-2) 
(0,0) to [vsourcesin, v_=$V_s$] (0,-2);
\end{circuitikz}
\end{center}

$$V_d(t) = V_s(t) = V_L(t) + V_R(t)$$
$$V_L(t) = L_1 {d \over dt}i_L(t)$$
$$V_R(t) = R_1 i_L(t)$$
$$110 \sqrt{2} \cos(120\pi t) = 10 i_L(t) + 0.02 {d\over dt}i_L(t)$$
Apply Laplace Transform:
$$10 I_L(s) + 0.02 s I_L(s) + i_L(0) = {110 \sqrt{2} s \over 14400 \pi^2 + s^2}$$
Solve for $I_L(s)$:
$$I_L(s) (10 + 0.02 s) = {110 \sqrt{2} s \over 14400 \pi^2 + s^2}$$
$$I_L(s) = \frac{110\,\sqrt{2}\,s}{\left(\frac{s}{50}+10\right)\,\left(s^2+14400\,\pi ^2\right)}$$
Apply Inverse Laplace Transform:
$$i_L(t) = \frac{6875\,\sqrt{2}\,\cos\left(120\,\pi \,t\right)+1650\,\pi \,\sqrt{2}\,\sin\left(120\,\pi \,t\right)}{36\,\pi ^2+625}-\frac{6875\,\sqrt{2}\,{\mathrm{e}}^{-500\,t}}{36\,\pi ^2+625}$$
$$V_R = \frac{10\,\left(6875\,\sqrt{2}\,\cos\left(120\,\pi \,t\right)+1650\,\pi \,\sqrt{2}\,\sin\left(120\,\pi \,t\right)\right)}{36\,\pi ^2+625}-\frac{68750\,\sqrt{2}\,{\mathrm{e}}^{-500\,t}}{36\,\pi ^2+625}$$


\section{Diode Is "Off"}
\begin{center}
\begin{circuitikz}[american voltages]
\draw
(0,0) to [opening switch] (3,0) to [open, v=$V_d$] (3,-2)
(3,0) to [short, american inductor, l=$L_1$, i=$i_L$] (6,0)
to [short, american resistor, l_=$R_1$, v^=$V_R$] (6,-2)
to [short] (0,-2) 
(0,0) to [vsourcesin, v_=$V_s$] (0,-2);
\end{circuitikz}
\end{center}

\section{LTSpice}
\begin{figure}[h]
    \includegraphics[width=\textwidth]{simulation.png}
\end{figure}

\section{MATLAB}
\begin{lstlisting}[language=MATLAB]
syms s t
R_1 = 10;
L_1 = 0.02;
v_s = 110*sqrt(2)*cos(120*pi*t);

V_s = laplace(v_s);
I_L = V_s / (R_1 + s*L_1);
i_L = ilaplace(I_L);

v_o = i_L * R_1
\end{lstlisting}

\section{Large Inductor}
As the inductor gets proportionally larger than the resistor, the amplitude of the output voltage decreases and the phase shift increases.
\section{Large Resistor}
As the resistor gets proportionally larger than the inductor, the amplitude of the output approaches the amplitude of the input and the phase shift goes to zero.

\end{document}
