Here we briefly outline the formulation of Hamilton's equations for this problem
but note that facility with Hamiltonian mechanics is not assumed in this course.
At the end of this section you will be presented with a set of working equations
to integrate.
It is convenient to solve the problem using plane polar coordinates
as illustrated
in the diagram below. The suffix 1 is used when referring to a property of Earth and
2 when referring to the Moon.
Thus the initial position coordinates of Earth and Moon are:
The mass
of the spacecraft is negligible compared to Earth and Moon so the motion of the
spacecraft has no effect on them. Thus r1 and r2 are constant and :
The unknown variables in Hamilton's equations are the position coordinates, usually
denoted
(here
and n=2) and the canonically
conjugate momentum coordinates
. Canonical here means
standard or
formal. The canonically conjugate momentum coordinates are related to, but not
the same as, the actual momentum (defined as
) coordinates. The relation
between canonical momentum coordinates and momentum coordinates depends on the particular
coordinate system chosen.
To determine the canonical momentum coordinates one forms the Lagrangian function:
where T is the kinetic energy and V the potential energy. Note that the potential V
may depend explicitly on the time t. Then the canonical momentum coordinates
are defined as the partial derivatives:
In the present case, where the position coordinates
are
the
canonically conjugate momentum coordinates
are related to the
real momentum coordinates
by:
When computing, one needs to calculate the canonically conjugate momentum.
Then to calculate real momentum and kinetic energy one needs the above translation.
One now defines the Hamiltonian function H' as :
and uses the definition of
to eliminate the explicit dependence of H'
on
and derive the Hamiltonian function
. Hamilton's
equations then become:
Hamilton's equations are a system of differential equations of the first order
and thus suitable to be directly integrated by Runge-Kutta methods.
Proceeding thus we obtain Hamiltons equations for
(
) and
(
and
) which can be conveniently written
in the form:
The gravitational forces contained in the last two equations are explicitly time
dependent, since
and
.
s1 and s2, the distances of the spacecraft of mass
from the Earth and
the Moon respectively, arise in the expression for gravitational potential in
the Lagrangian function. From geometry, the values are:
Writing C code for this problem similar to what we did before we define the 4-element
array
to contain the computed variables
.
Make a separate directory to work this problem. Copy the file hamil.c from
the directory /home/physics/staff/kjones/student/orbit. Check that it contains
C code for the above derivatives in the form required by runge.c. Note that
the mass
of the spacecraft has been taken as 1kg. Thus the computed momentum
components are velocity components. Note also
that the variables in hamil.c are double precision. Copy also the double precision
version of runge.c from the same directory. Note also the global variables used
in hamil.c and remember to generate them in your calling program. In the main program
use double precision for the computed variables. Note however that plplot
likes single precision floating point (type float) so you need to generate
extra plotting arrays of type float.