• No results found

A simple program, called o r b it , that computes orbits for the Kepler problem using various numerical methods is outlined in Table 3.2. The Euler method, described in Section 2.1, computes the comet’s trajectory as

rn-H — rn + rvn (311)

Table 3.2: Outline of program o r b i t , which computes the trajectory of a comet using various numerical met hods.

• Set initial position and velocity of the comet.

• Set physical parameters (m. G M , etc.)

• Loop over desired number of steps using specified numerical method.

- Record position and energy for plotting.

- Calculate new position and velocity using:

* Euler method (3.11), (3.12) or;

* Euler-Cromer method (3.13), (3.14) or;

* Fourth-order Runge-Kutta method (3.28), (3.29) or;

* Adaptive Runge-Kutta method.

• Graph the trajectory of the comet.

• Graph the energy of the comet versus time.

See pages 91 and 96 for program listings.

where a is the gravitational acceleration. Again, we discretize in time and use the notation f n = J ( t = (n — 1 )t) , where r is the time step.

The simplest test case is a circular orbit. For an orbital radius of 1 AU, Equation (3.5) gives a tangential velocity of 2iv AU/yr. Fifty data points per orbital revolution should give us a smooth curve, so r = 0.02 yr (or about one week) is a reasonable time step. W ith these values, the o r b i t program, using the Euler method, gives the results shown in Figure 3.2. We immediately see th at the orbit is not a circle, but an outward spiral. The reason is clear from th e energy graph; instead of being constant, the total energy is continuously increasing. This type of instability is also observed in the Euler method for the simple pendulum (see Section 2.2).

Fortunately, there is a simple solution to this problem—the Euler-Cromer method computes the trajectory as

Notice th at the only change from the Euler method is th at we first compute the new velocity, vn+ i , and then use it in the calculation of the new position. For the same initial conditions and time step, the Euler-Cromer method gives much better results, as shown in Figure 3.3. The orbit is nearly circular, and the total energy is conserved. The kinetic and potential energies are not constant,

vn+i = v n + r a ( r n ) r n+1 = r n + r v n+i

(3.13) (3.14)

90

30 20

S 10

Ì

}-10

W-20

-30

Kinetic Potential Total

1 2

Time (yr)

Figure 3.2: Graphs of trajectory and energy from the o r b i t program using the Euler method. Initial radial distance is 1 AU and the initial tangential velocity is 27r AU/yr. The time step is r = 0.02 yr; 200 time steps are computed.

Results disagree with theoretical prediction of a circular orbit with constant total energy.

30

20' ' 10

2 - 1 0

LU

I-

-30-K natie I

Potente

Total

2 Time (yr)

Figure 3.3: Graphs of trajectory and energy from the o r b i t program using the Euler-Cromer method. Parameters are given in Figure 3.2. The results are in qualitative agreement with theoretical prediction of a circular orbit with constant total energy.

■ - Kinaiic

1 2 . 3 4

Time (yr)

Figure 3.4: Graphs of trajectory and energy from the o r b i t program using the Euler-Cromer method. Initial radial distance is 1 AU and the initial tangential velocity is 7r AU/yr. The time step is r = 0.02 yr; 200 time steps are computed.

Due to numerical error, the comet achieves escape velocity—final position is about 35 AU and the total energy is positive.

but this problem may be improved by using a smaller time step. The o r b i t program also gives you the option of using Runge-Kutta methods, which are described in the next two sections.

Although the Euler-Cromer method does a good job for low eccentricity orbits, it has problems with more elliptical orbits, as shown in Figure 3.4. Notice th at the energy becomes positive; the satellite acquires escape velocity. If we lower the time step from r = 0.02 yr to 0.005 yr we obtain better results, as shown in Figure 3.5. These results are still not perfect; the orbit should be a closed ellipse, yet it has a noticeable spurious drift.

At this point you may be asking yourself, “Why are we studying this prob­

lem? The analytic solution is well known.” It is true th at there are more interesting celestial mechanics problems (e.g., the effect of perturbations on the orbit, the three-body problem). However, before doing the complicated cases we should always check our algorithms on known problems. Suppose th at we introduced a small drag force on the comet. We might be fooled into believ­

ing th at the precession in Figure 3.5 was a physical phenomenon rather than a numerical artifact.

Clearly, the Euler-Cromer method does an unacceptable job of tracking the more elliptical orbits. The results improve if we drop the time step, but then it takes forever to track a few orbits. Suppose that we wanted to track comets for possible E arth impacts. A comet striking E arth could be more destructive than nuclear war. Many comets have extremely elliptical orbits and periods of hundreds of years. This threat from outer space motivates our study of more advanced methods for solving ordinary differential equations.

90 35.7458

Figure 3.5: Graphs of trajectory and energy from the o r b it program using the Eulcr-Cromer method. Parameters are as in Figure 3.4 except the time step is smaller (r = 0.005 yr). Results are better, yet the orbit has a spurious precession.

EXERCISES

1. Suppose that a planet suddenly lost all of its orbital velocity; of course, it would plunge directly into the Sun. Show that Earth would reach the core of the Sun in about 65 days. [Pencil]

2. Prove that for the Kepler problem the Euler-Cromer method, conserves angular momentum exactly. [Pencil]

3. Modify the o rb it program so that instead of running for a fixed number of time steps, the program stops when the satellite completes one orbit, (a) Have the program compute the period, eccentricity, semimajor axis, and perihelion distance of the orbit.

Use the Euler-Cromer method and test, the program with circular and slightly elliptical orbits. Compare the measured eccentricity with

_ f 2 E H

e ~ \ + G 2M 2m a

(b) Show that your program confirms Kepler’s third law. (c) Confirm that {K ) =

—{V)[2, where {K) and (K) are the time-average kinetic and potential energy (virial theorem). [Computer]

4. For an ellipse, the radial position varies with angle as r(*) = 1 - ecosflA

Modify the o rb it program to compute and plot the absolute fractional error in r{6) versus time. Using the Euler-Cromer method, obtain results for an initial radial dis­

tance of 1 AU, an initial tangential velocity of 7r AU/yr, and time steps of r = 0.01, 0.005, and 0.001 yr. [Computer]

5. Modify the o rb it program to use the Verlet method. Run the modified program and produce graphs corresponding to Figures 3.2-3.5. [Computer]

6. The Euler-Cromer method must use a small time step for the more elliptic orbits.

Using an initial radial distance of 35 AU (Hailey’s comet) and various values for the

aphelion velocity, find the largest value of r for which the total energy is conserved to about 1% per orbit. Assemble a graph of r versus initial velocity, and estimate the time step needed to track Hailey’s comet. [Computer]

7. The Lorentz force on a charged particle is F = <j(E + v x B ) where E and B are the electric and magnetic fields acting on the particle and q is the particle’s charge. Write a program to simulate the motion of an electron in uniform, perpendicular electric and magnetic fields. Show that the motion is helical in form, with a pitch that depends on the initial particle velocity and with a drift velocity Udrift = E x B / B 2. [Computer]

3.2 RUNGE-KUTTA METHODS