We looked at two examples of central forces, the central harmonic oscillator and the Keplerian force field. For both of these cases the orbits can be found exactly (analytically) as a function of time, which is to say that we can solve for the orbit. This is not so in general however. Usually, for any realistic potential field, the orbit is complicated and does not admit of simple or general solutions, even if the potential does not change with time.
The most famous case of a simple system leading to very complicated orbits is called the three-body-problem. Newton solved the two-body-problem (i.e. two point masses moving in their mutual gravitational field), but was unable to solve the three-body-problem. Many people have worked on this problem since Newton, and it is in fact still a very active field even today, three hundred years later! The arrangement of three bodies turns out to be very sensitive to the initial positions and/or velocities of the three bodies and displays what is now known as chaotic behaviour.
In this lecture we will examine the numerical techniques used to
solve for orbits when the analytic solution is not known. This is the way
that orbits for spacecraft (such as those that went to the Moon) and stars in
the potential field of the Galaxy must be calculated.
The potential is time independent i.e. ∂Φ/∂t = 0.
Let the force (per unit mass) acting on the star be given by F(x,y,z) at the position r(x,y,z) so that
F = −dΦ(r)/dr
In 3-D Cartesian coordinates we can decompose the force into three components F = F(Fx,Fy,Fz), where
Fx = −∂Φ/∂x
Fy = −∂Φ/∂y
Fz = −∂Φ/∂z.
and note that these are partial derivatives.
The equations of motion of the star are (force = mass x acceleration)
d2x/dt2 = −∂Φ/∂x,
with similar forms in y and z.
Now we will consider a star at the position
P(x0,y0,z0) at time t = 0 with velocities
(dx0/dt, dy0/dt, dz0/dt) which we denote by
(u0,v0,w0).
The true (unknown) path of the star is shown in green. At P we can use the velocities and position to project the stellar path forward to Q after a time Δt. The actual position of the star after this time is R, and there will always be a small difference (error) between R and Q. In many situations, as we shall see, by choosing Δt small enough one can make this error arbitrarily small, and compute an orbit to any desired accuracy. |
To a first approximation, we can compute that the star will move to a new position Q(x1,y1,z1) after a short time Δt based on the velocity of the star at P:
x1 = x0 + u0 Δt
y1 = y0 + v0 Δt
z1 = z0 + w0 Δt.
Furthermore, we can compute the change in the velocities during the interval Δt based on the acceleration due to the force acting on the star at P
u1 = u0 + FxΔt
v1 = v0 + FyΔt
w1 = w0 + FzΔt.
We now have an estimate for the position and velocity of the star at Q. One can repeat (iterate) this procedure to predict the position and velocity of the star as a function of time. Mathematically, this is termed an initial value problem. We solve the equations of motion for a single case by integrating the equations numerically rather than finding the general analytical solution.
The method described above is called Euler's method. A large range of physical problems can be solved using methods based on this technique, and as a consequence a lot of effort has gone into developing fast and accurate versions of the technique; basically, higher order approximations than Euler's linear method are used, and they are known as Runge-Kutta methods. They are much more accurate than the Euler method, which is used here merely to demonstrate the idea. We'll look at those after applying Euler's method to a simple case, simple harmonic motion in 2-D.
The simple 2-D harmonic oscillator potential is
Φ(r) = &Omega2r2/2 + const,
and the equation of motion in x is (where r = r(x,y) = sqrt(x2 + y2))
d2x/dt2 = Fx = −dΦ/dr . dr/dx = −&Omega2r . x/r = −&Omega2x
with a similiar equation in y.
We insert this form into the equations above and solve the equations numerically. The equations in the X-coordinate for the nth step in the integration are:
xn+1 = xn + unΔt
un+1 = un − Ω2xnΔt.
A similar form holds for the y-coordinate.
These equations give us a scheme for "numerically integrating" the
orbit. Two examples of the numerical procedure follow, firstly using GNUPLOT
and then using QBASIC.
The right hand column column plots out the difference between the exact solution and the numerical solution as a funtion of time, t. You can experiment with using a different number of steps (change imax in the program). This has the effect of making the step size larger or smaller (the step size is denoted by the variable dt. The larger the number of steps the longer the solution takes to compute and the more accurately it matches the analytical solution.
Here are the files:
shmorbit.gnp, integrate-shmorbit.gnp, shmorbit.gnp integrate-shmorbit.gnp,shmorbit.gnp
# reset all paramters
# starting position in x, u (u=dx/dt) at time t =
0.0
# step (loop) counter
# time step
# total time of integration
# SHM force law
set xrange [-15:15]
print "the real orbit is plotted with o"
# start running the integration
|
shmtime.gnp
# reset all paramters
# starting position in x, u (u=dx/dt) at time t =
0.0
# step (loop) counter
# time step
# total time of integration
# SHM force law
set xrange [0:2.1]
print "the difference between the real orbit and the
"
# start running the integration
|
integrate-shmorbit.gnp
t = t + dt
epsilon_x = -pi/2
xt = Ax*sin(omega*t-epsilon_x)
# plot the point with "o" at the position after the
"at"
# dummy statement (do not remove) to fool gnuplot
# this is the actual loop
|
integrate-shmtime.gnp
t = t + dt
epsilon_x = -pi/2
xt = Ax*sin(omega*t-epsilon_x)
# plot the difference between the true and estimated
r_est = sqrt(x**2+y**2)
# dummy statement (do not remove) to fool gnuplot
# this is the actual loop
|
Note that using QBASIC is much faster than using the GNUPLOT programs above,
but GNUPLOT lets you watch the orbit in real time. Much faster still is to use
a compiled language, such as fortran, C, C++, VisualBasic etc. etc. Such
languages will compute orbits of this type hundreds of times faster than the
interpreted languages which are used here.
REM program to calculate the orbit of a star
in REM a harmonic potential x = 5!
i = 0
omega = 5! OPEN "orbit.out" FOR OUTPUT AS #1 PRINT #1, t, x, y FOR i = 1 TO imax t = t + dt
PRINT #1, t, x, y NEXT i END |
Results of a calculation of a simple harmonic orbit with an exact analytical solution are shown below. The star starts at x=5.0, y=0.0 with velocities u=0.0, v=50.0. The force law is F(r) = −Ω2 r with Ω = 5.0. The exact solution is shown by the green line and has the form
x(t) = 5 sin(Ωt+π/2)
y(t) = −10 cos(Ωt+π/2)
The lower left panel shows an iterative solution with 10 steps per time unit (Δt = 0.1), clearly a very poor solution. As N increases to N=20 and N=200 the solutions get closer and closer to the exact solution. The upper right panel shows a zoomed region (indicated by the red box in the upper-left panel), showing that the solution with N=200 is still slightly different to the exact solution.
Consider an equation of motion of the form
x'' = f(t,x,x'),
and that we want to solve for x(t) from initial conditions :
x(t0) = x0 x'(t0) = x'0.
Here, x'' is the 2nd derivative with respect to time t, x' is the first derivative, and the initial position is x0 and initial velocity is x'0 at time t = t0.
Let us expand the position coordinate x as a Taylor series in time, t, for a small step in time, dt.
x(t+dt) = x(t) + dt x'(t) + dt2 x''(t)/2 + dt3 x'''(t)/6 + ...
If we retain second order terms only, we get the following approximations:
x(t+dt) = x(t) + dt x'(t) + dt2 x''(t)/2
x'(t+dt) = x'(t) + dt x''(t).
Comparison with the Euler method above will show that we have improved it by including all the second order terms. There is actually only one change to be made to the Euler method - the equation which computes the change in the position includes new term, while the equation for the change in the velocity is the same as in the Euler case.
Exercise #1: Modify the program to take into account second order terms (using the Runge-Kutta method). How much more accurate is the orbit for the simple harmonic case? |
&Phi(r) = −GM/r
and the force acting at r is
F(r) = −GM/r2
in 3-D cartesian coordinates the force has components Fx, Fy, Fz where
Fx = dΦ/dx . dx/dr = −2GMx/r3
with similiar expressions in the other two components.
Inserting these into Eqns (1) above we derive the numerical form to be solved.
Here is a BASIC program to solve to orbit.
REM program kepler.
REM This program integrates the equations
REM initial values of variables t = 0!
REM step (loop) counter
REM number of points along the orbit
REM time step
REM total time of integration
REM keplerian force law c = 3000! OPEN "c:/gnuplot3.7/kepler.dat" FOR OUTPUT AS #1 REM OPEN "kepler.dat" FOR OUTPUT AS #1
r = SQR(x * x + y * y) PRINT #1, t, x, y, r FOR i = 1 TO imax r = SQR(x * x + y * y)
PRINT #1, t, x, y, r NEXT i END
|
Exercise #2: This program is quite
interesting to experiment with. What happens with small changes to the program
may surprise you. Start by changing the initial position or velocity of the
star; after that, experiment with different step sizes. How sensitive is the procedure to the adopted step size? What indications are there that an orbit may have been computed completely incorrectly? Recalling that certain quantities are conserved as a particle moves along its orbit, suggest a method to help decide whether an orbital calculation is reliable or not. |
A yet more accurate integrator is the RKN, or Runge-Kutta-Nystrom method. It extends the (2nd order) RK method above, and is a fourth ourder method, taking into account all terms to dt4. From the step n to step n+1, the following quantities are evaluated:
An = dt f(t,xn,x'n)/2
βn = dt (x'n + An/2)/2
Bn = dt f(t+dt/2,xn+βn,x'n+An)/2
Cn = dt f(t+dt/2,xn+βn,x'n+Bn)/2
δn = dt(x'n + Cn)
Dn = dt f(t+dt,xn+δn,x'n+2Cn)/2.
This is more general than we need, since the force on the particle depends only on its position, so these reduce to :
An = dt f(xn)/2
βn = dt (x'n + An/2)/2
Bn = dt f(xn+βn)/2
Cn = dt f(xn+βn)/2
δn = dt(x'n + Cn)
Dn = dt f(xn+δn)/2.
The steps involved in getting from the from nth step to the (n+1)th step in the integration are:
xn+1 = xn + dt (vn + Kn)
where Kn = (An + Bn + Cn)/3
vn+1 = vn + Jn
where Jn = (An + 2Bn + 2Cn + Dn)/3.
Exercise #3: This is a more challenging exercise. Write a program which solves the Kepler orbit using the Runge-Kutta-Nystrom method. You can modify the QBASIC program, or write your own in some other language if you want. How much more accurate/stable is this method compared to the Euler and Runge-Kutta integrators? |