These exercises are not tied to a specific programming language. Example implementations are provided under the Code tab, but the Exercises can be implemented in whatever platform you wish to use (e.g., Excel, Python, MATLAB, etc.).

###Exercise 1: Forces acting on a charged particle and the equations of motion
Imagine that we have a particle of mass $m$, charge $q$, and velocity $\vec{v} = (v_x,v_y,v_z)$ with $v_z >> v_x, v_y$ entering a region of uniform magnetic field $\vec{B} = B_x \hat{x}$ and uniform electric field $\vec{E} = E_y \hat{y}$. As shown below, $B_x > 0$ and $E_y < 0$. The length of the field region along the $z$-axis is $L$.
![Alt Figure](images/ExB_Filter/ExB_Filter_geometry.png)
Neglecting any other forces (e.g., gravitational forces), show that the Cartesian components of the combined electric and magnetic forces are
$$
F_x = 0
$$
$$
F_y = qE_y + qv_zB_x
$$
$$
F_z = - qv_yB_x
$$
resulting in the equations of motion
$$
\ddot{x} = 0
$$
$$
\ddot{y} = {{q}\over{m}}\Bigl(E_y + v_zB_x\Bigr)
$$
$$
\ddot{z} = - {{q}\over{m}}v_yB_x
$$
where the dot accents indicate differentiation with respect to time. Note that the particle will not experience any transverse acceleration if $v_z = v_{pass} = -E_y/B_x$.
(a) Assume that $E_y = -105$ V/m and $B_x = 2.00\times 10^{-3}$ T, and that all other field components are zero. Calculate, by hand, the Cartesian components of the acceleration at the instant when a Li$^+$ ion of mass 7 amu and kinetic energy 100 eV enters the field region traveling along the direction
$\hat{u} = (\hat{x} + \hat{y} + 100\hat{z})/\sqrt{10002}$.
How will these acceleration components compare to those for a doubly ionized nitrogen ion (N$^+$)?
(b) Write a code to perform the calculation in part (a). Note that, as soon as the particle enters the field region, the velocity components will change, and therefore so will the forces. To calculate an accurate trajectory, it is necessary to repeatedly calculate the forces, a task for which the computer is very well suited.
(c) What do you expect the trajectory of this ion to look like as it traverses the field region? Explain your answer.
###Exercise 2: Computing the Trajectory
Solve the equations of motion to obtain the trajectory of the Li$^+$ ion from Exercise 1 while it traverses the field region from $z = 0$ to $z = L = 0.25$ m.
(a) On separate graphs, plot $x$, $y$, and $z$ versus time.
(b) Plot the trajectory in space. What does the trajectory of the ion look like? What did you expect (Exercise 1)? What happens if you reduce the initial kinetic energy of the ion by a factor of 100? A factor of 10,000?
(c) What is the kinetic energy of the ion at the end of its trajectory? How does it compare to its initial energy?
###Exercise 3: The $\vec{E} \times \vec{B}$ (Wien) Filter, Part 1
Regions of mutually perpendicular electric and magnetic fields can be used to filter a collection of moving charged particles according to their velocity. If we assume that a particle of velocity $v_{pass} = -E_y/B_x$ enters the field region traveling *exactly* along the $z$-axis, the particle will experience zero net force and therefore zero acceleration and zero deflection from the $z$-axis. If a small, circular aperture of radius $R$ is placed on the $z$-axis at $z = L$, then this particle will be transmitted through the aperture.
(a) Use your program from Exercise 2 to determine the maximum value of $v_{z,max} = v_{pass} + \Delta v$ for which an aperture of radius $R = 1.0$ mm will transmit the Li$^+$ ion (now assuming that $v_x = v_y = 0$). What is the value of $\Delta v/v_{pass}$?
(b) Repeat (a) for an aperture of radius $R = 2.0$ mm. What is the value of $\Delta v/v_{pass}$?
###Exercise 4: The $\vec{E} \times \vec{B}$ (Wien) Filter, Part 2
As an extension of Exercise 3, now assume that the particles entering the field region at the origin have a normal distribution of velocities directed purely along the $z$-axis. The center of the distribution is $v_{z,pass}$ and its width is $0.1v_{z,pass}$.
(a) Allow $40,000$ particles from this distribution to enter the field region at the origin. What is the resulting histogram of the scaled velocities $v_z/v_{z,pass}$ of the particles transmitted through a circular aperture of radius $R=1.0$ mm centered on the $z$-axis? How does it compare to the histogram of the initial velocities?
(b) Repeat part (a) for an aperture of radius $R=0.5$ mm.
It is worth noting that an actual source of ions will not only be characterized by a distribution of velocities, but also distribution of directions (no ion beam is strictly mono-directional, just like a laser beam is not strictly mono-directional). This is an additional fact that would have to be considered to accurately simulate the performance of a real Wien filter.