\documentclass[conference]{IEEEtran}
\usepackage[siunitx]{circuitikz}
\usepackage{graphicx}
%\usepackage{lipsum}
\usepackage{color}
\usepackage{enumitem}
\usepackage{epsfig} 
\usepackage{mathptmx} 
\usepackage{times} 
\usepackage{amsmath}
\usepackage{amssymb}  
\usepackage{float}
\usepackage{hyperref}
%\usepackage{setspace}
%\usepackage{tikz}
\usepackage{circuitikz}
\usepackage{pgfplots}
\usepackage{textcomp}
%\usepgfplotslibrary{external}
%\tikzexternalize
%\usepackage[utf8]{inputenc}
%\usepackage[english]{babel}
%\usepackage{pgf}
\usepackage[final]{pdfpages}
\usepackage{pgfpages}
\usepackage[margin=0.4in]{geometry}
\usepackage{lmodern}
\usepackage{datetime}
\usepackage{ragged2e}
\input{border.tex}
\pgfpagesuselayout{boxed}

\hyphenation{op-tical net-works semi-conduc-tor}% correct bad hyphenation here

\font\myfont=cmr12 at 15pt 
\title{\myfont Simulating Boundary Conditions in Matlab}
\author{Aidan Sharpe 916373346}


\providecommand{\keywords}[1]{\textbf{\textit{Keywords---}} #1}
\providecommand{\e}[1]{\ensuremath{\times 10^{#1}}}
\setlength{\columnsep}{7mm}
\pgfplotsset{compat=1.15}
\begin{document}
\makeatletter
\@twocolumnfalse
\maketitle
\@twocolumntrue
\makeatother
\begin{abstract}
\end{abstract}

\section{Introduction and Background}
This lab focused on approximating simple electromagnetic scenarios using finite element analysis techniques. Through an iterative process, the approximations could be refined to any arbitrary tolerance. Reaching ever tighter tolerances, however, comes at the cost of exponentially more computing power. After a certain point, computing more iterations yields diminishing returns. To decrease error by an order of magnitude requires an order of magnitude more computing power, or at least the relationship is of similar scale. Unfortunately, if the initial error is very large, the amount of computation goes up exponentially for each order of magnitude higher in error.

\section{Part 1}
Part one introduced approximating the electric potential and the electric field strength in one dimension. Since the endpoints were known, continuously iterating over the distance, taking the moving average at each point, a decent approximation could be honed in on to arbitrary precision. In one dimension, the amount of computing power required to evaluate the approximation is minimal. The tolerance was set to 0.1, and the process completed successfully in less than half a second. 

\begin{figure}[h]
    \includegraphics[width=0.48\textwidth]{Part1.png}
    \caption{Approximated and actual electrostatic potential}
    \label{fig:part-1}
\end{figure}

The first graphic in figure \ref{fig:part-1} relates voltage to distance. The initial voltage at $x=0$ was 100[V] and the final voltage at $x=5$ was 0[V]. Since the tolerance was so low (0.1), only the red line, representing the approximated voltage is visible. Underneath the red line is a blue line that shows the actual voltage. In the second graphic in figure \ref{fig:part-1}, the actual electric field strength is shown in blue. Since the electric field strength is the negative gradient of electric potential, and voltage had a constant negative slope, the electric field strength is has a positive, constant value.

\section{Part 2}
Part two shifted from a one dimensional problem to a two dimensional one. Here, two metal plates with infinite length and a width of 4 meters were placed parallel to each other separated by two meters. They were connected along the left infinite edge by an insulating strip held at a potential of 100[V].

The code for this part took a very long time to run. Using the inbuilt timing functions, it took exactly 2276.92 seconds. Since the initial error was around $4\times10^4$ and the desired tolerance was $1\times10^{-3}$. That is seven orders of magnitude difference. While running, each iteration took about a quarter of a second. Given the total time, we can compute the total number of iterations to be around 8000.

After the algorithm completed, we were greeted with several figures depicting the electric potential and the electric field strength between the two plates.

\begin{figure}[h]
    \includegraphics[width=0.48\textwidth]{Part2-Heatmap-Potential.png}
    \caption{Electric potential between the plates}
    \label{fig:part-2-potential}
\end{figure}

Shown in figure \ref{fig:part-2-potential}, electric potential is clearly strongest close to the middle of the strip and goes to zero close to the plates or far from the strip.

\begin{figure}[h]
    \includegraphics[width=0.48\textwidth]{Part2-Heatmap-EField.png}
    \caption{Electric field strength between the plates}
    \label{fig:part-2-efield}
\end{figure}

While voltage is highest in the middle of the plates, the electric field is strongest close to the plates. This is because the voltage drops off most rapidly where the insulating strip meets the plates. Since electric field is higher when there is a sharper voltage drop, this makes intuitive sense.

\section{Part 3}
Part three analyzes the electric field and electric potential inside a rectangular region. In figure \ref{fig:part-3-efield}, the vectors are normal to the sides of the rectangle along the edges, and are strongest at the centers of each edge. This hints at a strong voltage drop near the centers of each boundary and a relatively constant voltage closer to the center. Based on the electric field alone, the electric potential would likely look like a dome made from an ellipse inscribed in the rectangle convolved with the surface of the rectangle itself.

\begin{figure}[h]
    \includegraphics[width=0.48\textwidth]{Part3-Vector-EField}
    \caption{Electric field inside the rectangle}
    \label{fig:part-3-efield}
\end{figure}

The approximated potential is shown in figure \ref{fig:part-3-potential}. The potential matches the dome shape, flat towards the middle, and dropping off more sharply towards the edges.

\begin{figure}[h]
    \includegraphics[width=0.48\textwidth]{Part3-Potential}
    \caption{Potential inside the rectangle}
    \label{fig:part-3-potential}
\end{figure}

\section{Part 4}
Adjusting the voltages at the boundary of the rectangle to be 20[V] when $x=0$, -5[V] when $y=0$, 10[V] when $x$ is at its maximum value, and -10[V] when $y$ is at its maximum value, gives the electric field shown in figure \ref{fig:part-4-efield}. The electric field is again weak in the middle, much weaker than before, and it is stronger near the corners this time. It is also stronger along the left and right sides than it is along the top and bottom. This hints at the shape of the potential. It should be of a similar shape to the previous rectangle, but much weaker for longer in the middle, and it should not drop off as sharply near the edges as before.

\begin{figure}[h]
    \includegraphics[width=0.48\textwidth]{Part4-Vector-EField}
    \caption{Electric field inside the new rectangle}
    \label{fig:part-4-efield}
\end{figure}

Looking at figure \ref{fig:part-4-potential}, the shape matches prediction. It should also be noted that the slope is much larger on the left than on the right. Looking back at the electric field in figure \ref{fig:part-4-efield}, this corresponds to a stronger electric field on the left compared to the right. Also notice the sign of the slopes of the electric potential: a negative slope corresponds to a vector in the positive x direction, and a positive slope corresponds to a vector in the negative x direction. This makes sense since the electric field is the negative gradient of the potential.

\begin{figure}[h]
    \includegraphics[width=0.48\textwidth]{Part4-Potential}
    \caption{Electric potential inside the new rectangle}
    \label{fig:part-4-potential}
\end{figure}

\section{Part 5}
Part five deals with linear varying potentials along a boundary. Now, rather than being constant, the potential will change along each boundary. Importantly, since this change is linear, the slope of the potential will be constant along the boundary. The potential is shown in figure \ref{fig:part-5-potential}.

For most values, electric field will be constant, but at the corners, the slope changes, so the filed will take on some value. This can be seen in figure \ref{fig:part-5-efield}.

\begin{figure}[h]
    \includegraphics[width=0.48\textwidth]{Part5-EField}
    \caption{The electric field inside a rectangle with non-constant boundary potential}
    \label{fig:part-5-efield}
\end{figure}

\begin{figure}[h]
    \includegraphics[width=0.48\textwidth]{Part5-Potential}
    \caption{The electric potential of a rectangle with non-constant potential}
    \label{fig:part-5-potential}
\end{figure}

\end{document}
