Download ModelDownload SourceembedLaunch Website


Intro Page

Relativistic Dynamics in 1D with a constant force

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 NON-relativistic 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 non-relativistic to relativistic dynamics. In order to generate results, we will see that we need to be careful when working with non-SI 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:

  • Execute a working simulation, and explain non-relativistic, constant force motion (Exercise 1)
  • Manipulate and explain the units that appear in the context of relativistic motion (Exercise 2)
  • Interpret plots of energy vs. time for non-relativistic motion (Exercises 2)
  • Observe and explain when the non-relativistic form of Newton’s 2nd Law breaks down (Exercise 3)
  • Derive the relativistic form of Newton’s 2nd Law (Exercise 4)
  • Modify a non-relativistic simulation to incorporate relativity (Exercise 5)
  • Produce and interpret plots for relativistic motion (Exercises 6, 7, 8)
  • Validate numerical results by comparing with an analytical solution (Exercise 7)
  • Apply simulated results to a particle accelerator (Exercises 9 and 10)
  • Rewrite code to store data in arrays using array indices rather than by appending data to arrays (Exercise 11)
Time to Complete 120 min
Exercise 1

Exercise 1:

The file ending with “Version1” contains code to simulate a proton in an electric field using the non-relativistic acceleration derived above. (This code uses the “Euler algorithm” described in the “Theory” section.) Execute this code, and look at the plots of position versus time and speed versus time. Explain why these plots have the shapes that they have.

Exercise 2

Exercise 2:

The file ending with “Version2” contains the same code as the file ending with “Version1” except that a few lines have been added in order to also calculate and plot the non-relativistic energy. Locate the line where the non-relativistic energy is calculated. (The same line appears both inside the loop and before the loop.) Explain why this line is correct. You will need to be very careful with the units and the factors of c2. Write down the equation for non-relativistic energy (including both rest energy and non-relativistic kinetic energy), and carefully argue why this line of code is correct.

Execute this code, and look at the plot of energy versus time. Why does this plot have the shape that it has? How large is the kinetic energy compared to the rest energy after the proton has been accelerating for 1 second?

Exercise 3

Exercise 3:

Again use the file ending with “Version2” but now increase the value of the maximum time from 1 second to 5 seconds. How large is the kinetic energy compared to the rest energy after the proton has been accelerating for 5 seconds? Look at the plot of speed versus time. Something should bother you! Explain what is wrong

Exercise 4

Exercise 4:

Derive the relativistic form of Newton’s 2nd Law,


from the equation F=dp/dt. See the “Theory” section for additional background.

Exercise 5

Exercise 5:

Save a copy of the file ending with “Version2” using a file name ending with “Version3”. In this new file, you are going to modify the code in order to take special relativity into account. This will involve the following steps:

  1. Compute the value of the Lorentz factor, γ.
  2. Use the Lorentz factor to compute the acceleration.
  3. Modify the equation for the energy (both before the loop and within the loop) in order to compute the relativistic energy. Hint: Once you have computed the Lorentz factor, the relativistic energy is actually very simple to compute, but be very careful of the units and factors of c2.

Execute your modified program, and fix any bugs!

Exercise 6

Exercise 6:

Execute your modified program (Version3) using a maximum time of 5 seconds, and look at the plot of speed versus time. Does the plot look better than the plot that you looked at in Exercise 3? It should! If it doesn’t, there is a bug in your code that needs to be fixed before you continue. Explain why the new plot of speed versus time has the shape that it has.

Exercise 7

Exercise 7:

Now that you have created a new program, you should attempt to validate your program (to test how accurate the numbers actually are). One simple way to do this is using the energy. From the work-energy theorem, the kinetic energy of the proton (starting from rest) is

and since the force is constant, the kinetic energy is simply the product of the (constant) force times the distance traveled. This “analytical” result (which does not involve any approximations) can be compared with the “numerical” kinetic energy from your program,

Add code to your program (after the program’s loop has completed) to compute the kinetic energy both analytically and numerically. Print both results, and make sure that they are similar. (If they aren’t you need to fix something!) Compute the percent error in the numerical kinetic energy. How large is the error? Increase the value of your program’s time step by a factor of 10. How does this affect the error? Why does this happen? (This code uses the “Euler algorithm” described in the “Theory” section.) Before you continue to the next exercise, make sure that the error is a small fraction of a percent.

Exercise 8

Exercise 8:

Increase the maximum time for your simulation until you are able to get the total energy of the proton up to 100 GeV. Discuss the shape of each of the three plots (position, speed, and energy). Why do they have the shapes that they have? (Incorporate the term “ultra-relativistic” into your answer.)

Exercise 9

Exercise 9:

Using an electric field of ϵ=1 Volt/meter, how much time does it take to accelerate a proton to an energy of 100 GeV? How far does it travel in that time? (Use your plots from Exercise 8.)

At the Large Hadron Collider (LHC), protons are accelerated to an energy of 8 TeV. Instead of using a longer simulation, extrapolate your results in order to determine how long it would take to accelerate a proton up to E=8 TeV using ϵ=1 Volt/meter. How far does the proton travel during this time? How many trips around the LHC would the proton make during this time? How does this distance compare to the circumference of the Earth’s orbit around the sun?


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 = 1e-8 # Time STEP in seconds

lorentz = 1 / sqrt(1 - v**2 / c**2) ## ADDED ##

E = lorentz * m ## MODIFIED ##

# Create arrays using initial values

tArray = array(t)

xArray = array(x)

vArray = array(v)

EArray = array(E)

lorentzArray = array(lorentz) ## ADDED ##

while t < 1e-5:

# The dynamics:

lorentz = 1 / sqrt(1 - v**2 / c**2) ## ADDED ##

a = Efield*c**2/(lorentz**3*m) ## MODIFIED ##

t = t + dt

x = x + v*dt

v = v + a*dt

E = lorentz * m ## MODIFIED ##

# Append the new values onto arrays

tArray = append(tArray, t)

xArray = append(xArray, x)

vArray = append(vArray, v)

EArray = append(EArray, E)

lorentzArray = append(lorentzArray, lorentz) ## ADDED ##

end = time()

print('Elapsed time:', end-start)

# 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_numerical-KE_analytical)/KE_analytical)

# Create plots


plot(tArray, vArray, linewidth=2)

xlabel('Time (sec)')

ylabel('Speed (m/s)')


ylim([0, 3.1e8])




plot(tArray, xArray, linewidth=2)

xlabel('Time (sec)')

ylabel('Position (m)')





plot(tArray, EArray, linewidth=2)

xlabel('Time (sec)')

ylabel('Energy (eV)')






Code Language Translator Run

Software Requirements


Android iOS Windows MacOS
with best with Chrome Chrome Chrome Chrome
support full-screen? 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



Fremont Teng; Loo Kang Wee; based on code by Larry Engelhardt

end faq

{accordionfaq faqid=accordion3 faqclass="lightnessfaq defaulticon headerbackground headerborder contentbackground contentborder round5"}




Other Resources


end faq

{accordionfaq faqid=accordion4 faqclass="lightnessfaq defaulticon headerbackground headerborder contentbackground contentborder round5"}

1 1 1 1 1 1 1 1 1 1 Rating 0.00 (0 Votes)