\section{PN junction}
\subsection{What are we even doing}
We stick together n and p doped regions, such that the doping effectively  becomes a step function.
This causes majority carriers (electrons in n region, holes in p region) to diffuse the minority carrier side,
resulting in a new equilibrium (\autoref{label:fig:pn_carrier_profile_equilibrium}).
\begin{figure}[h]
    \centering
    \begin{subfigure}[b]{.45\textwidth}
        \includegraphics[width=\textwidth]{imgs/pn_carrier_profile_equilibrium.png}
        \caption{Resulting carrier profile in thermal equilibrium}
        \label{label:fig:pn_carrier_profile_equilibrium}
    \end{subfigure}
    \hfill
    \begin{subfigure}[b]{.45\textwidth}
        \includegraphics[width=\textwidth]{imgs/pn_fermi_level_band_bending.png}
        \caption{Resulting carrier profile in thermal equilibrium}
        \label{label:fig:pn_fermi_level_band_bending}
    \end{subfigure}
\end{figure}

As can be seen in \autoref{label:fig:pn_fermi_level_band_bending},
the energy levels for conduction and valence bands bend, whereas the fermi level remains constant.



\subsection{Depletion approximation}
We assume p and n regions quasi-neutral,
and the intermediate space charge region to be completely depleted of carriers.
We further assume all transitions are expressed as step-functions.
This allows the following simplified equations:
\begin{align}
    \rho(x) & = \begin{dcases}
        0     & x<-x_p   \\
        -qN_a & -x_p<x<0 \\
        qN_d  & 0<x<x_n  \\
        0     & x_n<x
    \end{dcases} \\
    E(x)    & =\begin{dcases}
        0                                & x<-x_p    \\
        -\frac{qN_a}{\varepsilon}(x+x_p) & - x_p<x<0 \\
        \frac{qN_d}{\varepsilon}(x-x_n)  & 0<x<x_n   \\
        0                                & x_n<x
    \end{dcases}
\end{align}
Where $E$ is found using \eqref{label:eq:def_electric_field_integral}.

