\documentclass[12pt]{article}
\usepackage[a4paper, bindingoffset=0.2in, %
							left=0.5in,right=0.5in,top=0.5in,bottom=0.5in,%
							footskip=.25in]{geometry}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{hyperref}


\title{PSet1 Report}
\author{<NAME>}
%\date{Oct. 15}

\begin{document}
	\maketitle
	\section{The Koch Fractal Set}
	I used the \texttt{Turtle} tool in the \texttt{python} library set to draw the \emph{koch fractal set}. I made a class called \texttt{Koch} that takes in the 
	\texttt{level} and \texttt{max\_level} as inputs and creates the koch fractal 
	recursively. Then,
	there's the \texttt{draw()} method in \texttt{Koch} that gets called recursively to draw the koch fractal.
	I drew it to level 5 and output used a snipping tool to take a sceenshot of it.(Fig\ref{fig:koch})
	\begin{figure}[h!]
		\centering
		\includegraphics[width=.9\linewidth]{../P1/koch.png}
		\label{fig:koch}
		\caption{Koch fractal set, drawn to level 5. The length is reaching the pixel size
			now.}
	\end{figure}
	\section{The Serpinski Fractal Set}
		\subsection{Deterministic}
		I created a class for \texttt{Serpinski} and a module to \texttt{add\_subset}. Then a module to recursively go through the \texttt{sub\_sets} and draws them using \texttt{plt.fill()}. This method is very
		inefficient. A better way is to append the coordinates to a single array recursively and then draw it. This
		way makes it much faster. plt is so damn slow! (:face\_palming).
		
		The generated set with 8 levels of subsets is shown in Fig\ref{fig:serpDet}.
		\begin{figure}[h!]
			\centering
			\includegraphics[width=.9\linewidth]{../P2/fractalstuff.jpg}
			\label{fig:serpDet}
			\caption{The level 8 serpinski fractal set.}
		\end{figure}
		\subsection{Randomized}
		Here I added a module to the \texttt{Serpinski} class called \texttt{is\_bound()} which takes
		the coordinates of the point and recursively justifies if the point is in the serpinski fractal
		boundary. If yes, then I save the point coordinates. After I successfully find 50000 dots, I 
		draw them using \texttt{plt.scatter(x, y, s=0.1)} where \texttt{s=0.1} refers to the markersize
		which is set to 0.1 pt. Now Here's the Simulation for the level 8 fractal from the previous
		subsection. (Fig \ref{fig:serpRAND})
		\begin{figure}[h!]
			\centering
			\includegraphics[width=0.9\linewidth]{../P3/fractalstuff.jpg}
			\label{fig:serpRAND}
			\caption{find 50000 radom particles for the level 8 serpinski fractal from 
				Fig\ref{fig:serpDet}}
		\end{figure}
	\section{Random Deposition}
	\subsection{Intro}
	In oder to work with Random Depostion, I made a function that generates the canvas,
	\texttt{n} times. This fucntion calls another function that generates the canvas
	\emph{once}. This, then, calls a function that deploys a particle using the rule that it's been
	given -- e.g. the Ballistic Deposition rule or the Competitve BD rule.
	
	\textbf{Equations to be used:}\\
	\emph{!! Note: $L$ is the length of the surface, $t$ is time, $w$ is width (roughness)}
	\begin{equation}
		w(L, t) = t^{\beta}, \, t \ll t_s
		\label{eq:beta}
	\end{equation}
	\begin{equation}
		t_s = L^z
		\label{eq:z}
	\end{equation}
	\begin{equation}
		w_s = t_s^\beta = L^{\beta z} = L^\alpha
		\label{eq:alpha}
	\end{equation}
	
	After generating the graphics once, I shutdown (\texttt{comment out}) the graphics part and do the calculations. I fit the curve using polyfit and reported the value for $\beta$
	\subsection{Random Deposition}
	The graphics to lay 25 layers is shown in Fig \ref{fig:RD25}
	\begin{figure}[h!]
		\centering
		\includegraphics[width=.9\linewidth]{../P4/canvas.jpg}
		\label{fig:RD25}
		\caption{Randomly deposit particles on the surface of length 200 and change  color every 2000 particles you deposit. Do this for 50000 particles}
	\end{figure}
	The value for $\beta$ using eq.\ref{eq:beta} is as follows:
	\begin{equation*}
		\beta = 0.44 \pm 0.02
	\end{equation*}
	And the plot is shown at Fig.\ref{fig:RD25beta}
	\begin{figure}[h!]
				\centering
		\includegraphics[width=.9\linewidth]{../P4/plot_for_beta.jpg}
		\label{fig:RD25beta}
		\caption{Take the stdev of height as roughness ($w(L, t)$) for every layer you deposit.
		do this 10 times and find the error of each layer. Then plot and fit using 
		\texttt{plt.errorbar} and \texttt{scipy.optimize.curve\_fit} respectively.}
	\end{figure}
	\subsection{Random Deposition with Surface Relaxation}
	The canvas for this part is shown in Fig\ref{fig:RDSR}.
	\begin{figure}[h!]
		\centering
		\includegraphics[width=.9\linewidth]{../P5/canvas.jpg}
		\label{fig:RDSR}
		\caption{deposit 100000 particles using the RDSR rule and output the data.}
	\end{figure}
	In order to reach saturation we need
	at least about 50000 particles. to make the plot (Fig\ref{fig:RDSRplot}) I ran the simulation 10 times with 800
	layer deposits total. The value for $t_s$ was output by looking at the graph and getting
	the data that was closest to the values we were looking for.
	The value found for beta is:
	\begin{figure}[h!]
		\centering
		\includegraphics[width=0.9\linewidth]{../P5/plot_for_beta.jpg}
		\label{fig:RDSRplot}
		\caption{Plot log-log of roughness over time for RDSR}
	\end{figure}
	\begin{equation*}
		\beta = 1.64 \pm 0.06
	\end{equation*}
	The values for length $L$, saturation width $w_s$ and saturation time $t_s$ is as follows:
	\begin{equation*}
		\begin{aligned}
			L		 &= [10, 50, 100, 150, 200, 250]\\
			t_s		&= [32, 3072, 16384, 49152, 131072, 1048276]\\
			w_s	  &= [0.6, 1.1, 1.678, 2.725, 2.789, 3.558] 
		\end{aligned}
	\end{equation*}
	
	These values are plotted using the file \texttt{plots.py}. Plot fittings also happen there.
	
	Values found for $beta$ and $z$ are as follows:
	\begin{equation*}
		\beta = 0.18 \pm 0.02, \qquad z = 2.97 \pm 0.24, \qquad \Rightarrow \alpha \simeq 0.547
	\end{equation*}
	plots for $beta$ and $z$ are found in Fig\ref{fig:beta_z}
	
	The theoretical value for $\beta$ is $0.24$ and alpha, $0.47$ which gives a percentile 
	error of $\eta_\beta = 25\%$ and $\eta_\alpha = \%$ respectively
	\begin{figure}[h!]
		\centering
		\includegraphics[width=.4\linewidth]{../P5/beta.jpg}
		\includegraphics[width=.4\linewidth]{../P5/z.jpg}
		\label{fig:beta_z}
		\caption{The left log-log plot is for $w_s$ over $t_s$ and the one on the right is for 
		$t_s$ over length$L$. These plots are to measure $beta$, $z$ and $alpha$ in RDSR}
	\end{figure}
	
	\subsection{Ballistic Deposition}
	The canvas for this part is shown in Fig\ref{fig:BD}.
\begin{figure}[h!]
	\centering
	\includegraphics[width=.9\linewidth]{../P6/canvas.jpg}
	\label{fig:BD}
	\caption{deposit 20000 particles using the BD rule, change colors every 2000 particles and output the data.}
\end{figure}
In order to reach saturation we need
at least about 50000 particles. to make the plot (Fig\ref{fig:BDplot}) I ran the simulation 10 times with 800
layer deposits total. The value for $t_s$ was output by looking at the graph and getting
the data that was closest to the values we were looking for.
The value found for beta is:
\begin{figure}[h!]
	\centering
	\includegraphics[width=0.9\linewidth]{../P6/plot_for_beta.jpg}
	\label{fig:BDplot}
	\caption{Plot log-log of roughness over time for BD with surface length 200 and 1000 layers laid. Data taken for every $2^n$ particles laid}
\end{figure}
\begin{equation*}
	\beta = 0.44 \pm 0.02
\end{equation*}
The values for length $L$, saturation width $w_s$ and saturation time $t_s$ is as follows:
\begin{equation*}
	\begin{aligned}
		L		 &= [10, 50, 100, 150, 200, 250]\\
		t_s		&= [64, 1024, 3072, 4096, 8192, 32768]\\
		w_s	  &= [1.5, 4.40, 5.5, 7.2, 7.5, 9.0] 
	\end{aligned}
\end{equation*}

These values are plotted using the file \texttt{plots.py}. Plot fittings also happen there.

Values found for $beta$ and $z$ are as follows:
\begin{equation*}
	\beta = 0.30 \pm 0.04, \quad z = 1.75 \pm 0.17  \Rightarrow \alpha \simeq 0.521
\end{equation*}
plots for $beta$ and $z$ are found in Fig\ref{fig:BDbeta_z}

The theoretical value for $\beta$ is $0.21$ and alpha, $0.48$ which gives a percentile 
error of $\eta_\beta = 43\%$ and $\eta_\alpha = 8.5\%$ respectively
\begin{figure}[h!]
	\centering
	\includegraphics[width=.4\linewidth]{../P6/beta.jpg}
	\includegraphics[width=.4\linewidth]{../P6/z.jpg}
	\label{fig:BDbeta_z}
	\caption{The left log-log plot is for $w_s$ over $t_s$ and the one on the right is for 
		$t_s$ over length$L$. These plots are to measure $beta$, $z$ and $alpha$ in BD}
\end{figure}
	
	\subsection{Competitive Ballistic Deposition}
	The dynamics of this system is very similar to that of BD. The canvas plot is shown in Fig\ref{fig:CBD}
	\begin{figure}[h!]
		\includegraphics[width=0.9\linewidth]{../P7/canvas.jpg}
		\label{fig:CBD}
		\caption{The plot for laying  8000 particles using the CBR rules and  initial conditions. Chnage color every 2000 particles.}
		\end{figure}

		The plot for the Distance is available in Fig\ref{fig:CBDdist}. I generated the canvas 10 times and got the mean and sdtev and error for plot.
		\begin{figure}[h!]
			\includegraphics[width=.9\linewidth]{../P7/dist_plot.jpg}
			\label{fig:CBDdist}
			\caption{Distance of the index of the right most and left most part of the canvas that is active. over time. Collect data for every 200 particles laid. I generated the canvas 10 times and got the mean and sdtev and error for plot.}
	\end{figure}

\end{document}