% SIMIODETemplate-TeacherORStudent.tex and simiode.cls for LaTeX2e
% Version 29 July 2015.
%
% This class (simiode.cls) is a modification of that used by
% the journal PRIMUS - Problems, Resources, and Issues in
% Mathematics Undergraduate Studies.
%
% See http://www.tandfonline.com/loi/upri .
%
% The class was developed by  Marc Frantz with suggestions of the
% PRIMUS Editorial Board, especially John Thoo.
%
% This template is to be used with the  class file "simiode.cls".
%
% The latest version of this class and template files
% can be found at
%
%       <http://www.SIMIODE.org> in the Author section.
%
% A "Quick Start Guide" appears below.
%
% This file must be processed with version LaTeX2e or higher.
%
\documentclass{simiode}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% With this version of the tex file and the associated SIMIODE.cls file you can produce BOTH a Student Version and a Teacher Version of your modeling scenario or technique narrative.
%
% Basically the Student Version contains the title STUDENT VERSION along with the NAME OF SCENARIO, with no abstract, no keywords, no tags, no author identifiers, and no COMMENTS section. The Student Version contains only the STATEMENT of the modeling scenario with appropriate figures, data, instructions, and perhaps a bibliography appropriate for student resourcing, but nothing in the bibliography which would "give away" the nature of the modeling scenario, etc.
%
%The Teacher Version contains the material in the Student Version, namely the title NAME OF SCENARIO, now headed with   TEACHER VERSION, but also full author  identification, abstract, key words, tag words, and, following the STATEMENT, a section of COMMENTS which can be discussion of presentation  ideas, "solutions," techniques, etc.
%
% Authors can prepare a full Teacher Version using the notions immediately below  to create a pdf for review (but in review please eliminate all information about the author as we use a double-blind referee system. Such information will be restored when accepted and published in SIMIODE at www.simiode.org.
%
%***********   Toggle the following line to turn the teacher version on (1) or off (0). ***********
%
%
\def\TeacherEdition{0} % Toggle this line's value.
\newcommand{\teacher}[1]{\ifnum\TeacherEdition=1 #1 \fi}
%
%
% The \teacher{ } command wraps any text that will appear only in the teacher version of
% the document. See this file for examples. This has been done for you in the document below.
% Rename the pdf after you compile each final version.
% This option was created  by Eric Sullivan, Carroll College, Helena MT.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{amsmath,amssymb}
\usepackage{color}
\usepackage{graphicx}
\usepackage{hyperref}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% NOTE regarding double spacing %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Manuscripts should be submitted doubled spaced.  This is
% accomplished via the \baselinestretch command below.
% However, you may obtain an idea of how your article will
% look in final form, so that you can better plan your
% presentation.  To see your manuscript formatted very
% similarly to the on-line published format of  SIMIODE,
% comment the following line out by inserting a percent sign % (%) at its beginning.

\renewcommand{\baselinestretch}{1.3}

%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% NOTE regarding macros %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Any macros defined for your paper should be contained in
% the top matter. Likewise, any environment definitions such
% as \newtheorem or \newenvironment should also go in the
% top matter.
%
% Do not \input your macros as separate files within your
% final version because more files make it harder for the
% editors and users to keep track of and/or modify and
% append your paper.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Top matter is above and
% the beginning of the document below.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\newpage
% You only need to change the NAME OF SCENARIO in the next line and delete the footnote. See above for instructions on toggling from Teacher Version to Student Version.
\title{\ifnum\TeacherEdition=1 TEACHER VERSION  \else STUDENT VERSION \fi\\CONDENSATION}



\teacher{
    \keywords{condensation, simulation, first order, data, differential equation}

\tagwords{sum of square error, best fit, parameter estimation}
}


\markboth{Condensation}{Condensation}






\author{
\begin{minipage}[t]{4.5 true cm}
Chris McCarthy\\ 
Borough of Manhattan Community College\\
New York NY \teacher{} USA\\
\teacher{mccarthybmcc@yahoo.com}
\end{minipage}
\ \qquad \
\begin{minipage}[t]{4.5 true cm}
Brian Winkel\\ 
Director SIMIODE\\
Cornwall NY \teacher{12518} USA\\
\teacher{BrianWinkel@simiode.org}
\end{minipage}
}

% \makeStitle
% replaces: \makeStitle
% Choose only one of the following:
% \makeStitlePDFLaTex  % <--- use this for PDFLaTex (jpg and pdf image files etc.)
    \makeStitleLaTex    % <--- use this for LaTex (eps image files)



\teacher{
\begin{abstract}
We simulate the random motion of 200 particles in a 50 by 50 square in which a particle bounces off the two vertical and top walls and condenses  on the bottom wall. Animations are produced and data is offered for modeling with a differential equation in which parameters need to be estimated.
\end{abstract}
}

\teacher{

\vspace*{-.1 true cm}
\listkeywords

\vspace*{-.9 true cm}
\listtags
}

\section*{STATEMENT}

Consider  the random motion of 200 particles in a 50 by 50 square with vertices $(0,0), (0,50)$, $(50,50), (0,50)$ in a plane. At each iteration, $n = 0, 1, 2, \ldots$ each particle moves 1 unit in one direction only, due north, due east, due south, or due west, and it must move.

Particles are initially randomly distributed on points with integer coordinates, but not on the boundaries, i.e. from within the set $S = \{\, (m,n)\vert\, m,n \in \{1, 2, 3, 
\ldots, 49\}\, \}$ and at each iteration each particle moves. The number of condensed particles is tallied at each iteration.

If a particle comes in contact with the west, east, or north wall it bounces off by returning to the position just before the bump.  If the particle comes in contact with the south or bottom wall it condenses and stays exactly at the position of contact, thus depleting the number of particles which are still randomly moving in the square. In Figures~\ref{fig:1-47-SimPlotBoth1}-\ref{fig:1-47-SimPlotBoth9000} we show a snapshot of several iterations of the particles and the plot of the number of condensed particles at each iteration.

We provide several animations for different runs of the simulation  and we offer several data sets from such simulations.

\begin{enumerate}
\item Offer up a difference or differential equation which models $y(t)$ the number of condensed particles at iteration $t$.
\item Using the data set with step size 1 in Table~\ref{table:dataset} (and shown in Figure~\ref{fig:1-47-dataset}) or from one of the data sets provided estimate the parameter(s) in your model.
 
\begin{table}[!h]
\small
\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \hline
 Iteration & 0  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  1000  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  2000  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  3000  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  4000  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  5000  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  6000  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  7000  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  8000  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm} 
   9000  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  10000  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  11000  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  12000  \hspace*{-.2 true cm} \\ \hline
 \# Condensed & 1  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  75  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  103  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  121  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  129  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  136  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  150  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  160  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  170  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  173  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  179  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm} 
   182  \hspace*{-.2 true cm} &  \hspace*{-.2 true cm}  188  \hspace*{-.2 true cm} \\ \hline
\end{tabular}
\normalsize
\parbox{8.8 true cm}{\caption{\label{table:dataset} Sampled data  at increments of 1000 iterations from a simulation of duration 10,000 iterations, with step size 1.}}
\end{center}
\end{table}

\begin{figure}[!h]
\begin{center}
\includegraphics[width=9cm]{1-47-dataset.eps}


\parbox{9 true cm}{\caption{\label{fig:1-47-dataset} Plot of data in Table~\ref{table:dataset} of number of condensed particles at iterations, 1000, 2000, 3000, \ldots, 11,000, 12000.}}
\end{center}
\end{figure}

\item Confirm in some way the correctness of your model.
\end{enumerate}


\begin{figure}
\centering
\hspace{-1.5 true cm}\includegraphics[width=16cm]{1-47-SimPlotBoth1.eps}
\vspace*{-.15 true cm}
\parbox{13 true cm}{\caption{\label{fig:1-47-SimPlotBoth1} On the left we see the particles in the box at iteration 1 with 1 of the particles condensed  on the bottom wall and on the right we see a plot of the accumulated number of condensed particles at given iteration. In our depiction of the particles we do not show accumulating particles which are condensed, rather we presume they are taken away.}}


\vspace*{.3 true cm}
\centering
\hspace{-1.5 true cm}\includegraphics[width=16cm]{1-47-SimPlotBoth6000.eps}
\vspace*{-.15 true cm}
\parbox{13 true cm}{\caption{\label{fig:1-47-SimPlotBoth6000} On the left we see the particles in the box at iteration 6000 with 161 of the particles condensed  on the bottom wall and on the right we see a plot of the accumulated number of condensed particles at given iteration. In our depiction of the particles we do not show accumulating particles which are condensed, rather we presume they are taken away.}}


\vspace*{.3 true cm}
\centering
\hspace{-1.5 true cm}\includegraphics[width=16cm]{1-47-SimPlotBoth9000.eps}
\vspace*{-.15 true cm}
\parbox{13 true cm}{\caption{\label{fig:1-47-SimPlotBoth9000} On the left we see the particles in the box at iteration 9000 with 187 of the particles condensed  on the bottom wall and on the right we see a plot of the accumulated number of condensed particles at given iteration. In our depiction of the particles we do not show accumulating particles which are condensed, rather we presume they are taken away.}}
\end{figure}







\teacher{\newpage
\section*{COMMENTS}

A reasonable model is
\begin{equation}\label{eq:model}
y'(t) = k (200 - y(t))\qquad  y(0) = 0\, .
\end{equation}

This rate equation  says that the rate at which the particles hit the bottom wall and stick at time $t$, $y'(t)$,  should be proportional to how many particles  remain floating about at time $t$, which is given by $200 - y(t)$. If there are twice as many particles floating about, twice as many should hit the 
bottom wall per unit time. Here $k$ is the constant of proportionality. There are some interesting properties of $k$ one could observe in the simulations, e.g., if the speed of the particles increases (step size increases each iteration), $k$ should increase. Figuring out $k$ based upon theory could be an interesting problem! However, it is easier to estimate $k$  from the data.

We can solve (\ref{eq:model}) using separation of variables or technology:

\begin{equation}\label{eq:solve}
y(t) = 200 - 200 e^{-k t}\, . 
\end{equation}

To estimate $k$ we form the sum of square errors between our data and our model (\ref{eq:solve}) and minimize this sum as a function of the parameter $k$.

\begin{equation}\label{eq:sumk}
SSE(k)=\sum_{j=1}^n (y(t_i) - c_i)^2\, ,
\end{equation}
where $t_i$ is the number of the $i^{\rm th}$ iteration and $c_i$ is the number of particles condensed at the $i^{\rm th}$ iteration.

In Mathematica, using the FindMiniumum command we find that the least sum of square errors is 444.392 when the parameter, $k = 0.000278$.

We render a plot of the data and of the model on the same axes for comparison in Figure~\ref{fig:1-47-ModelAndData}.

\begin{figure}[!h]
\begin{center}
\includegraphics[width=9cm]{1-47-ModelAndData.eps}


\parbox{9 true cm}{\caption{\label{fig:1-47-ModelAndData} Plot of data in Table~\ref{table:dataset} of number of condensed particles at iterations, 1000, 2000, 3000, \ldots, 11,000, 12000 and our model with best fit parameter $k = 0.000278$.}}
\end{center}
\end{figure}


}




\end{document}


