About
Developed by Larry Engelhardt
In these exercises, you will determine the motion of a proton in a uniform electric field. We will begin by simulating a proton in an electric field using the NONrelativistic version of Newton’s 2nd Law. Then we will modify this simulation to take special relativity into account. In the process, we will observe the transition from nonrelativistic to relativistic dynamics. In order to generate results, we will see that we need to be careful when working with nonSI units. In particular, we will need to pay close attention to factors of eV and $c$.
Subject Area  Modern Physics 

Level  Beyond the First Year 
Available Implementations  IPython/Jupyter Notebook and Python 
Learning Objectives 
Students will be able to:

Time to Complete  120 min 
Exercise 10:
At the LHC, protons are accelerated using much larger electric fields, $\u03f5=5\times {10}^{6}$ Volts/meter. Use your program to simulate a proton at the LHC being accelerated by this large electric field. (Tip: You will need to significantly change the values of both the time step and the maximum time.) Discuss your results.
Exercise 11 (RELEVANT FOR PYTHON OR MATLAB, NOT RELEVANT FOR ALL PROGRAMMING LANGAUGES):
You might have noticed that your program becomes very slow if you have a very large number of time steps. Part of this is unavoidable; each time step requires the computer to do some processessing. However, much of the computation time is consumed by appending new values onto the arrays.
Rewrite your program so that, instead of repeatedly appending to the arrays, you create large empty arrays before the loop; then in each iteration of the loop, you record the new numbers in the appropriate element of the array. Observe and discuss how this affects the computation time.
# relativisticDynamicsVersion3.py
from pylab import *
from time import time
start = time()
c = 2.998e8 # Speed of light in m/s
m = 0.938e9 # Mass in eV/c^2
Efield = 5e6 # Electric field in Volts per meter
x = 0 # Position in meters
v = 0 # Velocity in meters/second
t = 0 # Time in seconds
dt = 1e8 # Time STEP in seconds
tMax = 1e3
N = int(tMax / dt)
tArray = zeros(N)
xArray = zeros(N)
vArray = zeros(N)
EArray = zeros(N)
lorentzArray = zeros(N)
for i in range(N):
# The dynamics:
lorentz = 1 / sqrt(1  v**2 / c**2)
a = Efield*c**2/(lorentz**3*m)
t = t + dt
x = x + v*dt
v = v + a*dt
E = lorentz * m
# Write the new values into the arrays
tArray[i] = t
xArray[i] = x
vArray[i] = v
EArray[i] = E
lorentzArray[i] = lorentz
end = time()
print('Elapsed time:', endstart)
# The following lines are added for Exercise 7
KE_numerical = lorentz * m  m
KE_analytical = Efield*x
print('Numerical KE: ', KE_numerical)
print('Analytical KE:', KE_analytical)
print('Percent Difference:', 100*abs(KE_numericalKE_analytical)/KE_analytical)
# Create plots
figure(1)
plot(tArray, vArray, linewidth=2)
xlabel('Time (sec)')
ylabel('Speed (m/s)')
grid(True)
ylim([0, 3.1e8])
savefig('ultrarelativistic_v_vs_t.png')
show()
figure(2)
plot(tArray, xArray, linewidth=2)
xlabel('Time (sec)')
ylabel('Position (m)')
grid(True)
savefig('ultrarelativistic_x_vs_t.png')
show()
figure(3)
plot(tArray, EArray, linewidth=2)
xlabel('Time (sec)')
ylabel('Energy (eV)')
grid(True)
savefig('ultrarelativistic_E_vs_t.png')
show()
Translations
Code  Language  Translator  Run  

Software Requirements
Android  iOS  Windows  MacOS  
with best with  Chrome  Chrome  Chrome  Chrome 
support fullscreen?  Yes. Chrome/Opera No. Firefox/ Samsung Internet  Not yet  Yes  Yes 
cannot work on  some mobile browser that don't understand JavaScript such as.....  cannot work on Internet Explorer 9 and below 
Credits
Fremont Teng; Loo Kang Wee; based on codes by Larry Engelhardt
end faq
Version:
 https://www.compadre.org/PICUP/exercises/exercise.cfm?I=103&A=RelativisticDynamics1DConstantForce
 http://weelookang.blogspot.com/2018/06/picuprelativisticdynamicsin1dwith.html
 http://weelookang.blogspot.com/2018/06/relativisticdynamicsin1dwith.html
Other Resources