This programming lab is a continuation of the accelerator programming lab where a proton is accelerated from the electric field between two charged plates. The only difference between the earlier programming lab and this programming labis that we are going to think about the ** potential difference** between the two charged plates.

The situation is exactly the same as before. A proton (mass = 1.0, charge = +1) is accelerated between two plates with an electric field with a strength of +5. As before, the electric field unit is ** not** the usual Newtons per Coulomb. Instead, the electric field is defined so that a field of 1.0 will accelerate a proton at $1 \, \rm m/s^2$. It's really not any more complicated than that, but you can read through this discussion of units if this seems like a weird thing to do.

**Step. 1.** Check out this nice animation of an proton being accelerated through two charged plates

Thinking about the problem in terms of forces, the relevant equations are: $$v_{xf} = v_{xi} + a_x \Delta t$$ $$v_{xf}^2 = v_{xi}^2 + 2 a_x \Delta x$$ $$F_x = q E = m a_x$$

and it should be clear from the animation that the initial x velocity ($v_{xi}$) is non-zero.

Thinking about the problem in terms of potential difference, the relevant equations are: $$\Delta V = E d$$ $$\Delta KE = q \Delta V$$ $$KE = \frac{1}{2} m v_x^2$$ $$\Delta KE = KE_f - KE_i$$

where $d$ is the distance between the plates. It should be clear from the animation that the initial kinetic energy is non-zero (because $v_{xi}$ is non-zero).

**The purpose of this programming lab is to show that the potential difference way of thinking about the problem is just as useful as thinking about the problem in terms of forces, and maybe even more useful, if the energy is what we care about!!!**

**Step 2. Open up the accelerator code in an editor**

Click on this link to open the accelerator code in a p5.js editor

**Important! Create an account with the editor or sign in to an existing account. Then click "Duplicate" so you can have your own version of the code!**

You can also use your code from the previous exercise so long as you change the charge of the particle back to +1 and the mass of the particle back to 1.0

**Step 3.** The final velocity at the end of the animation is 55.5 meters per second. The initial velocity was 10 meters per second and the acceleration occurs over 300 meters. **Go back to the previous programming lab and remember how you were able to explain why the final velocity is 55.5 meters per second.** In the last programming lab we thought about the problem in terms of forces. Write down the equation that explains the 55.5 meters per second in what you turn in for this lab.

**Step 4.** The potential difference between the plates is $\Delta V = E d$ where $E$ is 5 and $d$ is 300 meters. The potential difference is therefore $\Delta V = E d = 1500$. Choose a different value for $E$, and choose a different value for $d$ by changing the variables `x_plate_left`

and `x_plate_right`

. Make sure that the new values of $d$ multiply to $\Delta V = 1500$ and make sure $d < 750$ or else one of the plates will be off-screen. Check to see if approximately the same final velocity (55.5 meters per second) is achieved. (The final velocity should be the same because the potential difference is the same. This is one reason why the potential difference is such a useful concept.) **When you turn in this lab make sure your code has the values of $E$ and $d$ that you chose and write down the measured value of the velocity to confirm that this worked.**

**Step 5.** With your new values for $E$ and $d$, check to see what happens if the charge of the particle is doubled. Set `q = 2.0`

instead of `1.0`

. Does the charge of the particle affect the final velocity? why or why not? Do you get the same final velocity with the original values of $E$ and $d$? Is it faster or slower?

**Step 6.** With your new values for $E$ and $d$, check to see what happens if the mass of the particle is `2.0`

instead of `1.0`

and change the charge of the particle back to 1.0. As mentioned in the last programming lab, this is like changing the particle from a proton to a deuteron. Predict the final velocity and check to see if your expectation is proven right. **Do this calculation two ways: (1) thinking about the problem in terms of forces, as in the previous programming lab, and (2) thinking about the problem in terms of the potential difference.** You should be able to show that both approaches give essentially the same answer.

In the **comments section in the dropbox on carmen** you should answer the questions asked in this programming lab:

**1. Write down the equation that gave 55.5 meters per second from the previous programming lab (Step 3)**

Feel free to look back at the last programming lab and just put this same equation here

**2. Choose new values for $E$ and $d$ (Step 4a)**

Make sure that the code you submit contains the new values for $E$ and $d$. These should multiply to $\Delta V = Ed = 1500$ and make sure $d < 750$ or else one of the plates will be off screen.

**3. State whether you get approximately the same final velocity with the new values of $E$ and $d$ (Step 4b)**

This is just a yes or no question. The answer should be yes (as mentioned in step 4) or else you've done something wrong.

**4. Say whether increasing the charge of the particle increases the final speed (Step 5)**

This is just a yes/no question. Make sure you change $E$ and $d$ before you test this.

**5. Change the mass and show two ways to calculate the final velocity (Step 6)**

You can calculate the final velocity using forces or using the change in potential. Write down the equations as best you can in the comments. Don't just show the result. You should get approximately the same answer.