\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[a4paper,top=3cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage[colorlinks=true, allcolors=blue]{hyperref}
\usepackage{siunitx}
\usepackage{subcaption}
\usepackage{floatrow}
\newfloatcommand{capbtabbox}{table}[][\FBwidth]
\usepackage{blindtext}
\usepackage{esvect}
\title{Simulating Charged Particles in Magnetic Fields}
\author{Crystal Burgos, Ryan Culhane, Sara Idris}
\begin{document}
\maketitle
\section{Abstract}
This investigation set out to develop a Python program that could model the motion of multiple particles in an arbitrary magnetic field. The code we created uses Euler's method, along with necessary initial values and physical quantities, to approximate the motion of each particle for a set step size and number of iterations. The program we developed then plots the motion of each particle in the magnetic field, taking into account the electric forces between each particle.
\section{Introduction}
\subsection{Magnetic Fields}
Charges moving in a magnetic field will experience a force given by the relation below:
$$ F = q \vec{v} \times \vec{B}$$
where q is the charge of the particle, $\vec{v}$ is the velocity and $\vec{B}$ is the magnetic field vector.
\\ \\
This implies that if the particle is moving in the same direction as the magnetic field, there is no force exhibited on the particle. As the angle between the velocity vector and the magnetic field vector increases from \ang{0} to \ang{90}, the magnitude of the force exerted on the particle increases. By the nature of the cross product, the force is always perpendicular to both the magnetic field and the velocity of the particle.
\subsection{Electric Forces}
Coulomb's Law states that two charged particles exert an equal and opposite force on one another that is proportional to the charge on each particle and inversely proportional to the distance between particles squared. Furthermore, the force acts along the line connecting the two particles and is attractive if the charges are of opposite sign and repulsive if the charges are of the same sign. Symbolically, Coulomb's Law can be expressed as:
$$ \vv{F} = \frac{k_e q_1 q_2}{r^3}\vv{r} $$
where $k_e$ is the electrostatic constant, $q_1$ is the charge of one of the particles, $q_2$ is the charge of the other particle, and $\vv{r}$ is the vector from the first particle to the second and $r$ is its magnitude. Furthermore, electrostatic interactions obey the Law of Superposition and the net electric force on a particle is simply the sum of the forces exerted on that particle by all the other particles in the system.
\subsection{Euler's Method}
Euler's method is a mathematical process that allows us to approximate the value of functions using only the derivative and the initial conditions of the function. If the first derivative is known, then one can approximate the value of the function by assuming the slope is constant for a small step $\delta t$. At the initial value of the function $(x_0,y_0)$, the function will have a slope $f'(x_0,y_0)$, and the new $y$ position will be the product of the slope and the time step. At $x = x_0 + \delta t$ the slope can also be approximated as $f'(x_0+\delta t,y_0+\delta tf'(x_0,y_0))$ and the process can be repeated after each additional time step.
For example, let us use $f'(x,y)=y-x$ with the initial condition $y(0)=2$, time step $\delta t=1$, and interval $[0,5]$ to model the process. The initial set up is shown below:
\begin{table}[H]
\begin{center}
\caption{One Step of Euler's Method for $f'(x,y)=y-x$}
\begin{tabular}{c|c|c|c|c}
$t$ & $x_t$ & $y_t$ & $f'(x_t,y_t)$ & $rise_t$ \\
\hline
0 & 0 & 2 & 2 & 2 \\
1 & 1 & 4 & & \\
\end{tabular}
\end{center}
\end{table}
To fill Table 1, we first start at the initial condition where $x_0 = 0$ and $y_0 = 2$. At this point, the slope is $2-0=2$. The rise is the product of the slope and the step size, or $f'(0,2)*\delta t$, which is $2*1=2$. Then we can calculate $(x_1,y_1)$ by first adding the step size to $x_0$, which is $0+1=1$. To find $y_1$ we add $rise_0$ to $y_0$, or add $2+2=4$. Now we can repeat this process until we reach the end of the interval over which we want to approximate the function.
\begin{table}[H]
\begin{center}
\caption{Euler's Method for $f'(x,y)=y-x$ On [0,5] with step size 1}
\begin{tabular}{c|c|c|c|c}
$t$ & $x_t$ & $y_t$ & $f'(x_t,y_t)$ & $rise_t$ \\
\hline
0 & 0 & 2 & 2 & 2 \\
1 & 1 & 4 & 3 & 3 \\
2 & 2 & 7 & 5 & 5 \\
3 & 3 & 12 & 9 & 9 \\
4 & 4 & 21 & 17 & 17 \\
5 & 5 & 38 & 33 & 33 \\
\end{tabular}
\end{center}
\end{table}
Although Euler's method can only be used as an approximation, as the time step decreases, the approximation becomes more accurate. This algorithm is useful because it allows us to approximate the value of a function over an interval using only the initial conditions and the derivatives of the function.
\\ \\
In our investigation, given the initial charges, masses, positions, velocities, and a function for the magnetic field, we can find the acceleration of the particle and use the Euler method to model its motion.
\section{Implementation}
\subsection{Overview}
Our goal was to plot the motion of charged particles as they travel through a magnetic field and interact with each other. Below is a flow chart that diagrams our process.
\begin{figure}[H]
\begin{center}
Figure 1: Flow Chart of Coding Process
\includegraphics[width=0.8\textwidth]{newflchart.png}
\caption{Flow chart that illustrates the process by which we created our code.}
\end{center}
\end{figure}
The specifics of each step of this flow chart are outlined below.
\subsection{Particle Class}
To organize the particles in the field and our initial conditions, we created a class for our particles where we stored the initial x, y, and z positions as arrays, the velocities in the x, y, and z directions as arrays, the mass as a float, and the charge of the particle as a float.
\subsection{Magnetic Field Function}
After defining the initial conditions, we created a function that defined the x, y, and z components of the magnetic field as functions of a particle's position. We stored these components in numpy arrays.
\subsection{Electric Force Function}
We also defined a function that uses the positions of each particle as well as their charge to calculate the total electric force exerted on each particle by all the other charges in the system. Again, we stored the electric force components in numpy arrays.
\subsection{Force Function}
Then, we defined a function that calculated the force on the particle using the magnetic field function, and the particle's velocity and charge to compute the force due to the field and then added the electric and magnetic forces component-wise to find the total force on the particle.
\subsection{Acceleration Function}
Next, we created a function that determined the acceleration of the particle from the total force, the mass of the particle, and Newton's Second Law.
\subsection{Euler Method Implementation}
Then we defined a new function that performed one step in Euler's method by using kinematic equations to find the new x, y, and z positions using the acceleration for the corresponding direction and a time step of 0.0005. The new positions were then appended to the position arrays defined in each particle so we could keep track of the particle's position at each time. The same method was used to find the new velocities in the x, y, and z directions and update the velocity arrays.
\subsection{Plotting}
Afterwards, we created a for loop that would perform the one step Euler function 10,000 times, storing the particle's position, velocity, and acceleration at each step. We also used this function to plot the particle's motion on a 3D plot.
\subsection{Calibration}
Due to the computational resolution of Python, we could not model the mass and charges of our particles to be like that of elementary charges like electrons. Because these quantities are so small, (on the order of $10^{-31}$ and $10^{-19}$, respectively), many of our calculations get rounded to 0 or would approach infinity too quickly. As a result, we chose to keep our charges and masses on the order of $10^{-3}$ to $10^{-2}$ in magnitude. This way, our parameters are small enough, but not so small that we cannot detect noticeable changes. We also scaled the electric constant $k_e$ to 1000 for the same reason. Similarly, we used a time step t=0.0005 and repeated Euler's method 10,000 times in order to avoid making our position and velocity values too large, or cause the program to run for too long. Due to our rather arbitrary assignment of these variables, we have not included units in our reported masses and charges, but calculations were carried our assuming the values we report later are in SI units..
\section{Results}
To test our code we plotted the motion of the particle in 3 fields where we knew the expected motion of the particle.
\subsection{Particles in Zero Magnetic Field}
In the first case, we plotted the motion of three charged particles in zero magnetic field, neglecting the electric field. In this case, we expected the motion of the particle to be straight line since there was no field to exert a force on the particle.
\newpage
\begin{center}
Linear Motion in Zero Magnetic Field
\end{center}
\begin{figure}[H]
\begin{floatrow}
\ffigbox[9cm]{\includegraphics[width=9cm,height=6cm]{zerobonly.png}}{
\caption{Linear motion of 3 particles in a magnetic field of 0.}}\qquad
\capbtabbox{
\begin{tabular}{c|c}
Physical Quantity & Initial Value \\ \hline
Charge 1 & $1 \times 10^{-3}$ \\
Mass 1 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ 1 (Position Vector) & (2,0,0)\\
$\vv{v}_0 $ 1 (Velocity Vector) & (0,1,0)\\ \hline
Charge 2 & $1 \times 10^{-3}$ \\
Mass 2 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ 2 (Position Vector) & (1,1,1)\\
$\vv{v}_0 $ 2 (Velocity Vector) & (1,0,0)\\ \hline
Charge 3 & $1 \times 10^{-3}$ \\
Mass 3 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ 3 (Position Vector) & (2,2,2) \\
$\vv{v}_0 $ 3 (Velocity Vector) & (1,0,0) \\
$\vv{B}(x,y,z)$ & (0,0,0) \\
\end{tabular}
}{
\caption{Initial conditions of each particle and the magnetic field vector in the case to the left.}
}
\end{floatrow}
\end{figure}
As expected, the three particles move linearly, suggesting our program passes this test case.
\subsection{Uniform Circular Motion in Uniform Magnetic Field}
In this case, we plotted the motion of a particle in a uniform magnetic field with a velocity perpendicular to that of the magnetic field. The expected trajectory is circular motion because the magnetic field and velocity are perpendicular, so the force exerted by the field only changes the direction, not the magnitude of velocity.
\begin{center}
Uniform Circular Motion in Uniform Magnetic Field
\end{center}
\begin{figure}[H]
\begin{floatrow}
\ffigbox[9cm]{\includegraphics[width=9cm,height=6cm]{byisfivebonly.png}}{
\caption{Circular motion of a charged particle moving with a velocity perpendicular to a uniform magnetic field.}}\qquad
\capbtabbox{
\begin{tabular}{c|c}
Physical Quantity & Initial Value \\ \hline
Charge & $1 \times 10^{-3}$ \\
Mass & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) & (2,0,0) \\
$\vv{v}_0 $ (Velocity Vector) & (2,0,0)\\
$\vv{B}(x,y,z)$ & (0,5,0) \\
\end{tabular}
}{
\caption{Initial conditions of the particle and the magnetic field vector in the case to the left.}
}
\end{floatrow}
\end{figure}
Again, our program performed as expected. Interestingly, the particle does not trace the exact same circular path, which is a clear indication of the discrete nature of the Euler method and the somewhat limited resolution of our program.
\subsection{Spiral in Uniform Magnetic Field}
In this case we plotted the motion of a charged particle in a uniform magnetic field with one perpendicular component of velocity and one other component of velocity in the same direction as that of the magnetic field. The expected motion is a spiral because one component of velocity is perpendicular to the field so the particle should move in a circle, but the component of velocity in the other direction is unchanged by the magnetic field. Therefore, the particle should move in a circle in one plane and in a line in another plane, creating a spiral shape of motion.
\begin{center}
Spiral in Uniform Magnetic Field
\end{center}
\begin{figure}[H]
\begin{floatrow}
\ffigbox[9cm]{\includegraphics[width=9cm,height=6cm]{spiralbonly.png}}{
\caption{Spiral motion of a charged particle in a uniform magnetic field moving with one component of velocity perpendicular to the field and another component in the same direction as the field.}}\qquad
\capbtabbox{
\begin{tabular}{c|c}
Physical Quantity & Initial Value \\ \hline
Charge & $1 \times 10^{-3}$ \\
Mass & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) & (2,0,0) \\
$\vv{v}_0 $ (Velocity Vector) & (2,1,0) \\
$\vv{B}(x,y,z)$ & (0,5,0) \\
\end{tabular}
}{
\caption{Initial conditions of each particle and the magnetic field vector in the case to the left.}
}
\end{floatrow}
\end{figure}
\subsection{Particles in Non-Uniform Magnetic Field}
Seeing as our code passed the three test cases (neglecting the effects of electric forces), we decided to model particles' motion in more complex, non-uniform fields.
\\ \\
In the first case of non-uniform magnetic fields, we plotted the motion of two charged particles in a magnetic field where each component of the field depended on two of the position components. The electric forces between the particles are not accounted for in this plot.
\begin{center}
First Case in Non-Uniform Magnetic Field
\end{center}
\begin{figure}[H]
\begin{floatrow}
\ffigbox[9cm]{\includegraphics[width=9cm,height=6cm]{nonuniformbfieldBonly.png}}{
\caption{The first case of the motion of two charged particles in a non-uniform magnetic field.}}\qquad
\capbtabbox{
\begin{tabular}{c|c}
Physical Quantity & Initial Value \\ \hline
Charge 1 & $1 \times 10^{-3}$ \\
Mass 1 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) 1 & (0,0,0)\\
$\vv{v}_0 $ (Velocity Vector) 1 & (0,1,0)\\ \hline
Charge 2 & $1 \times 10^{-3}$ \\
Mass 2 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) 2 & (4,0,0)\\
$\vv{v}_0 $ (Velocity Vector) 2 & (1,-1,2)\\
$\vv{B}(x,y,z)$ & ($x-y$,$x-z$,$z-x$)\\
\end{tabular}
}{
\caption{Initial conditions of each particle and the magnetic field vector in the case to the left.}
}
\end{floatrow}
\end{figure}
The second case of a particle moving in a non-uniform magnetic field is the case of a particle in a field where the z-component is constant, but the other two components of the field depend on two components of the position vector.
\begin{center}
Second Case in Non-Uniform Magnetic Field
\end{center}
\begin{figure}[H]
\begin{floatrow}
\ffigbox[9cm]{\includegraphics[width=9cm,height=6cm]{nonuniformbfield2Bonly.png}}{
\caption{Second case of the motion of a charged particle in a non-uniform magnetic field.}}\qquad
\capbtabbox{
\begin{tabular}{c|c}
Physical Quantity & Initial Value \\ \hline
Charge & $1 \times 10^{-3}$ \\
Mass & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) & (3,0,5)\\
$\vv{v}_0 $ (Velocity Vector) & (2,1,3) \\
$\vv{B}(x,y,z)$ & ($4x-3y$,$\frac{x}{z}$,$3$)\\
\end{tabular}
}{
\caption{Initial conditions of each particle and the magnetic field vector in the case to the left.}
}
\end{floatrow}
\end{figure}
In the third case, a charged particle moves in a magnetic field always dependent on the position of the particle.
\begin{center}
Third Case in Non-Uniform Magnetic Field
\end{center}
\begin{figure}[H]
\begin{floatrow}
\ffigbox[9cm]{\includegraphics[width=9cm,height=6cm]{nonuniformbfield3Bonly.png}}{
\caption{Third case of the motion of a particle in a non-uniform magnetic field.}}\qquad
\capbtabbox{
\begin{tabular}{c|c}
Physical Quantity & Initial Value \\ \hline
Charge & $1 \times 10^{-3}$ \\
Mass & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) & (4,4,5) \\
$\vv{v}_0 $ (Velocity Vector) & (4,1,2)\\
$\vv{B}(x,y,z)$ & ($x^{\frac{1}{2}}$,$3+x-y-z$,$y-2$)\\
\end{tabular}
}{
\caption{Initial conditions of each particle and the magnetic field vector in the case to the left.}
}
\end{floatrow}
\end{figure}
The computational technique of Euler's method allows us to model the motion of particles in non-uniform, more complicated magnetic fields to the resolution of time steps of 0.0005.
\subsection{Multiple Particles in a Magnetic Field Affected by Electric Forces}
Now that we are confident in our ability to model particles' motion in magnetic fields, we chose to incorporate the interactions via the electric force that have an effect on the particles' motion.
\\ \\
In the first case, we observe the motion of two particles moving in a uniform magnetic field with and without accounting for the electric forces between the charges themselves.
\\ \\
Figure 8 below demonstrates the motion of the two particles in a uniform magnetic field without accounting for the electric forces between them.
\begin{center}
First Case in Uniform Magnetic Field Without Electric Forces
\end{center}
\begin{figure}[H]
\begin{floatrow}
\ffigbox[9cm]{\includegraphics[width=9cm,height=6cm]{nonuniformbfield4bonly.png}}{
\caption{The first case of the motion of two charged particles in a uniform magnetic field without accounting for the electric forces between them.}}\qquad
\capbtabbox{
\begin{tabular}{c|c}
Physical Quantity & Initial Value \\ \hline
Charge 1 & $1 \times 10^{-2}$ \\
Mass 1 & $1 \times 10^{-2}$ \\
$\vv{x}_0 $ (Position Vector) 1 & (2,0,0)\\
$\vv{v}_0 $ (Velocity Vector) 1 & (2,1,0)\\ \hline
Charge 2 & $1 \times 10^{-2}$ \\
Mass 2 & $1 \times 10^{-2}$ \\
$\vv{x}_0 $ (Position Vector) 2 & (2,0,3)\\
$\vv{v}_0 $ (Velocity Vector) 2 & (1,0,1)\\
$\vv{B}(x,y,z)$ & (0,5,0)\\
\end{tabular}
}{
\caption{Initial conditions of each particle and the magnetic field vector in the case to the left.}
}
\end{floatrow}
\end{figure}
Figure 9 below demonstrates the motion of the two particles in a uniform magnetic field after accounting for the electric forces between them. The effect of the electric forces are evident when you observe the changes in the y-axis intervals. Before accounting for the electric forces, the y-axis interval is [0,5] while after it is [0,30].
\begin{center}
First Case in Uniform Magnetic Field With Electric Forces
\end{center}
\begin{figure}[H]
\begin{floatrow}
\ffigbox[9cm]{\includegraphics[width=9cm,height=6cm]{nonuniformbfield4bande.png}}{
\caption{The first case of the motion of two charged particles in a uniform magnetic field after accounting for the electric forces between them.}}\qquad
\capbtabbox{
\begin{tabular}{c|c}
Physical Quantity & Initial Value \\ \hline
Charge 1 & $1 \times 10^{-3}$ \\
Mass 1 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) 1 & (2,0,0)\\
$\vv{v}_0 $ (Velocity Vector) 1 & (2,1,0)\\ \hline
Charge 2 & $1 \times 10^{-3}$ \\
Mass 2 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) 2 & (2,0,3)\\
$\vv{v}_0 $ (Velocity Vector) 2 & (1,0,1)\\
$\vv{B}(x,y,z)$ & (0,5,0)\\
\end{tabular}
}{
\caption{Initial conditions of each particle and the magnetic field vector in the case to the left.}
}
\end{floatrow}
\end{figure}
In the second case, we plot the motion of three charged particles in a uniform magnetic field.
\\ \\
The plot of the motion of the particles before accounting for the electric forces is shown in Figure 10.
\newpage
\begin{center}
Second Case in Uniform Magnetic Field Without Electric Forces
\end{center}
\begin{figure}[H]
\begin{floatrow}
\ffigbox[9cm]{\includegraphics[width=9cm,height=6cm]{uniformbfield5bonly.png}}{
\caption{The second case of the motion of two charged particles in a uniform magnetic field before accounting for the electric forces between them.}}\qquad
\capbtabbox{
\begin{tabular}{c|c}
Physical Quantity & Initial Value \\ \hline
Charge 1 & $1 \times 10^{-2}$ \\
Mass 1 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) 1 & (2,0,0)\\
$\vv{v}_0 $ (Velocity Vector) 1 & (2,1,0)\\ \hline
Charge 2 & $1 \times 10^{-2}$ \\
Mass 2 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) 2 & (2,0,3)\\
$\vv{v}_0 $ (Velocity Vector) 2 & (1,0,2)\\ \hline
Charge 3 & $-1 \times 10^{-2}$ \\
Mass 3 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) 3 & (-5,2,6)\\
$\vv{v}_0 $ (Velocity Vector) 3 & (1,0,1)\\
$\vv{B}(x,y,z)$ & (2,5,-3)\\
\end{tabular}
}{
\caption{Initial conditions of each particle and the magnetic field vector in the case to the left. Note that charge 3 is negative.}
}
\end{floatrow}
\end{figure}
The plot of the motion of the three particles after accounting for the electric forces is shown in Figure 11.
\begin{center}
Second Case in Uniform Magnetic Field With Electric Forces
\end{center}
\begin{figure}[H]
\begin{floatrow}
\ffigbox[9cm]{\includegraphics[width=9cm,height=6cm]{uniformbfield5bande.png}}{
\caption{The second case of the motion of two charged particles in a uniform magnetic field after accounting for the electric forces between them.}}\qquad
\capbtabbox{
\begin{tabular}{c|c}
Physical Quantity & Initial Value \\ \hline
Charge 1 & $1 \times 10^{-2}$ \\
Mass 1 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) 1 & (2,0,0)\\
$\vv{v}_0 $ (Velocity Vector) 1 & (2,1,0)\\ \hline
Charge 2 & $1 \times 10^{-2}$ \\
Mass 2 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) 2 & (2,0,3)\\
$\vv{v}_0 $ (Velocity Vector) 2 & (1,0,2)\\ \hline
Charge 3 & $-1 \times 10^{-2}$ \\
Mass 3 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) 3 & (-5,2,6)\\
$\vv{v}_0 $ (Velocity Vector) 3 & (1,0,1)\\
$\vv{B}(x,y,z)$ & (2,5,-3)\\
\end{tabular}
}{
\caption{Initial conditions of each particle and the magnetic field vector in the case to the left.}
}
\end{floatrow}
\end{figure}
In the third case, we plotted the motion of four particles, one of which had $\vv{0}$ initial velocity, in a uniform magnetic field before and after accounting for the electric forces between the particles. In the plot not accounting for the electric forces, it is expected that we will not see the charge that has initial velocity of $\vv{0}$ because it is not experiencing any force and according to Newton's First Law will just stay at rest.
\\ \\
Figure 12 shows the plot of motion of all four particles before accounting for the electric forces.
\newpage
\begin{center}
Third Case in Uniform Magnetic Field Without Electric Forces
\end{center}
\begin{figure}[H]
\begin{floatrow}
\ffigbox[9cm]{\includegraphics[width=9cm,height=6cm]{uniformbfield6bonly.png}}{
\caption{The third case of the motion of four charged particles in a uniform magnetic field before accounting for the electric forces between them. Note that charge 4 cannot be seen because it does not move.}}\qquad
\capbtabbox{
\begin{tabular}{c|c}
Physical Quantity & Initial Value \\ \hline
Charge 1 & $1 \times 10^{-2}$ \\
Mass 1 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) 1 & (2,0,0)\\
$\vv{v}_0 $ (Velocity Vector) 1 & (2,1,0)\\ \hline
Charge 2 & $1 \times 10^{-2}$ \\
Mass 2 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) 2 & (2,0,3)\\
$\vv{v}_0 $ (Velocity Vector) 2 & (1,0,2)\\ \hline
Charge 3 & $-1 \times 10^{-2}$ \\
Mass 3 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) 3 & (-5,2,6)\\
$\vv{v}_0 $ (Velocity Vector) 3 & (1,0,1)\\ \hline
Charge 4 & $-1.2 \times 10^{-2}$ \\
Mass 4 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) 4 & (-1,1,3)\\
$\vv{v}_0 $ (Velocity Vector) 4 & (0,0,0)\\
$\vv{B}(x,y,z)$ & (2,5,-3)\\
\end{tabular}
}{
\caption{Initial conditions of each particle and the magnetic field vector in the case to the left. Note that charge 4 has a negative charge 1.2 times greater than the other charges and no initial velocity.}
}
\end{floatrow}
\end{figure}
Figure 13 shows the motion of the particles after accounting for the electric forces.
\begin{center}
Third Case in Uniform Magnetic Field With Electric Forces
\end{center}
\begin{figure}[H]
\begin{floatrow}
\ffigbox[9cm]{\includegraphics[width=9cm,height=6cm]{uniformbfield6bande.png}}{
\caption{The third case of the motion of four charged particles in a uniform magnetic field after accounting for the electric forces between them. Note the slight motion of charge 4 (in red) that was absent from figure 12.}}\qquad
\capbtabbox{
\begin{tabular}{c|c}
Physical Quantity & Initial Value \\ \hline
Charge 1 & $1 \times 10^{-2}$ \\
Mass 1 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) 1 & (2,0,0)\\
$\vv{v}_0 $ (Velocity Vector) 1 & (2,1,0)\\ \hline
Charge 2 & $1 \times 10^{-2}$ \\
Mass 2 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) 2 & (2,0,3)\\
$\vv{v}_0 $ (Velocity Vector) 2 & (1,0,2)\\ \hline
Charge 3 & $-1 \times 10^{-2}$ \\
Mass 3 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) 3 & (-5,2,6)\\
$\vv{v}_0 $ (Velocity Vector) 3 & (1,0,1)\\ \hline
Charge 4 & $-1.2 \times 10^{-2}$ \\
Mass 4 & $1 \times 10^{-3}$ \\
$\vv{x}_0 $ (Position Vector) 4 & (-1,1,3)\\
$\vv{v}_0 $ (Velocity Vector) 4 & (0,0,0)\\
$\vv{B}(x,y,z)$ & (2,5,-3)\\
\end{tabular}
}{
\caption{Initial conditions of each particle and the magnetic field vector in the case to the left. Note that charge 4 has a negative charge 1.2 times greater than that of the other charges and has no initial velocity.}
}
\end{floatrow}
\end{figure}
Since charge 4 is experiencing only an electric force at first, it begins to move and once it has a velocity, it also begins to experience a magnetic force. When you compare Figure 13 to Figure 12, it can also be seen that charge 4 attracts charges 1 and 2, but repels charge 3 as expected.
\section{Conclusion}
The code we created in Python allowed us to model the motion of a charged particle in different magnetic fields and even allowed us to plot the motion of multiple particles in varying magnetic fields while also accounting for the electric forces between the particles. Nonetheless, there were still limitations to our code.
\\ \\
For instance, because of the computational resolution of Python, we could not plot the motion of particles with very small time steps less than 0.0001, a detail that could make our plots much more accurate. This effect can be seen in Figure 3 where the motion is not perfectly circular and does not trace the exact same path, as should be expected. As the time step approaches 0, the path should become more circular. In addition, we could use a different method of numerical integration instead of Euler's method. Methods like Runge-Kutta, for example, could enhance our code's accuracy in approximating the particles' motion. In future investigations this may be a worthy option to pursue but for this investigation we decided it was better to use a method we were already familiar with to aid the implementation process and allow us to incorporate the electric force effects.
\\ \\
We also were limited, due to time constraints, to plotting the motion of charged particles in magnetic fields that were uniform or dependent only on position. However, it could be interesting to plot the motion of charged particles in time-varying magnetic. We also only accounted for the electric forces between the particles in our field, but it could be useful to be able to plot the motion of multiple charged particles in both a magnetic and electric field.
\\ \\
Other limitations of our model include how it handles collisions and short range interactions. If we set two particles with opposite charges to collide with one another by giving them zero initial velocity, they keep moving past each other instead of colliding and coming to a stop as would be expected in such a symmetric situation.
\end{document}