Energy in an Orbit

In this assignment you will add energy calculations and graphs to your flyby program.

Retrieve a working copy of your program. You can get your copy from where you saved it in WebAssign. The Earth is at the origin (< 0, 0, 0 >) and put the spacecraf initially 10 Earth radii to the left of the center of the Earth. Use the following initial conditions for the spacecraft to make an elliptical orbit around the Earth:

initial position of spacecraft = < -10*Earth.radius, 0, 0 > m,
initial velocity of spacecraft = < 0, 3.25e3, 0 > m/s,
and let deltat be 100 s

We'll concentrate on the energy associated with the two-body system consisting of the Earth plus the spacecraft.

To let the program run fast, either comment out any "rate" statement or set the rate to a high number, such as rate(500), which means "do 500 loops per second". Comment out the commands for the force and deltaR arrows. Also comment out any "print" statements that are inside the "while" loop.

Currently, Python interprets "1/2" as zero, because it does integer division and discards the remainder. This is inappropriate in physics computations and can lead to bugs that are hard to find, and in the future Python will interpret "1/2" as 0.5. To get this future behavior now, put the following line at the start of your program (there are two underlines before "future" and two underlines after "future"):

from  __future__  import division # two underlines before and two underlines after "future"

Plot graphs of energy

Before the "while" loop, prepare to make graphs of energy. The following statements go near the start of the program, after the "import division" statement:

from visual.graph import * # this invokes the graphing machinery
scene.y = 400 # move orbit window below graph (will not work on a Mac)

The following statements go in the object-creation section, before the start of the "while" loop, to create graphing curve objects:

Kgraph = gcurve(color=color.cyan)
Ugraph = gcurve(color=color.yellow)
KplusUgraph = gcurve(color=color.red)

Inside the "while" loop, calculate and plot the various energy terms as a function of time. There is a VPython function for finding the magnitude of a vector, which is convenient to use in this program.

pmag = mag(craft.p) # or whatever you've called the spacecraft's momentum
K = (calculate the current kinetic energy of the spacecraft; K for fixed Earth is zero)
U = (calculate the current potential energy of the Earth-spacecraft system)
Kgraph.plot(pos=(t,K))
Ugraph.plot(pos=(t,U))
KplusUgraph.plot(pos=(t,K+U))

Use while t < 25*24*60*60: so that the calculation runs through several complete orbits around the Earth (25 days).

What do you expect for the graph of (K+U), the red curve? If the graph does not behave as you expect, check your calculations.

When the program is running correctly, experiment with it and answer these questions as comments in your program

(1) As the kinetic energy of the system increases, what should happen to the potential energy of the system? Is that what your graph shows?
(2) As the kinetic energy of the system decreases, what should happen to the potential energy of the system? Is that what your graph shows?
(3) Pick some particular time when K is neither a minimum nor a maximum. On a strip of paper, mark the vertical distance from the x axis up to the K curve. Now move the strip down and measure up from the U curve to the K+U curve. Verify that the vertical distance from U up to K+U is the same as from 0 up to K. This works because adding U+K is graphically equivalent to moving from the U curve up to the U+K curve. Now pick some other time and convince yourself that you can read off the kinetic energy by looking at the height the K+U curve is above the U curve, even if the K curve weren't visible.
(4) What kind of a state is it when (K+U) is negative? Bound or unbound? What is meant by the word "bound"?
(5) Increase the initial speed and observe what happens to the value of (K+U). Find the initial speed that makes (K+U) be zero; write a comment in your program.
(6) What do you see the spacecraft do when you make (K+U) be greater than or equal to zero? What kind of a state is this? Bound or unbound?
(7) Calculate the initial speed that should make (K+U) be zero, and check that your result agrees with what you found in (5).
(8) If (K+U) is zero, what would the speed of the spacecraft be when it is very far from the Earth? Explain how you know. If (K+U) is greater than zero, what can you say about the speed of the spacecraft when it is very far from the Earth?
(9) What effect is there on the graph of (K+U) when you make the time step be quite large for computational speed, deltat = 4000 seconds? Why does this happen? What additional evidence do you have from the spacecraft's path that this computation is inaccurate? (This may be easier to see if you set the initial speed again to be 3.25e3 m/s.) Evidently a graph of (K+U) is a sensitive indicator of the accuracy of a computation. This can be used to check whether a program is working properly.

Be sure you have answered all questions as comments in your program.

Plot against separation instead of time

Comment out the plotting of energy against time and insert the plotting of energy against the separation distance (magnitude of the vector from the Earth to the spacecraft). Let deltat be 100 seconds again, for accuracy. This is the kind of energy graph most commonly used in scientific and engineering work. Again choose the initial speed to be 3.25e3 m/s.

(10) When the separation distance is a maximum, is the kinetic energy zero? Small? Large? What about U?
(11) When the separation distance is a minimum, is the kinetic energy zero? Small? Large? What about U?

Be sure you have answered all questions as comments in your program.

You will submit this program to WebAssign, and there will be some questions about what you observe.