next up previous
Next: Adaptive step control in Up: DYNAMICAL PROBLEMS BY SOLUTION Previous: The flight path of

Formulation of Hamilton's equations for the problem

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 tex2html_wrap_inline481 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:

displaymath451

displaymath452

The mass tex2html_wrap_inline487 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 :

displaymath453

The unknown variables in Hamilton's equations are the position coordinates, usually denoted tex2html_wrap_inline493 (here tex2html_wrap_inline481 and n=2) and the canonically conjugate momentum coordinates tex2html_wrap_inline499 . Canonical here means standard or formal. The canonically conjugate momentum coordinates are related to, but not the same as, the actual momentum (defined as tex2html_wrap_inline501 ) 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:

displaymath454

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 tex2html_wrap_inline511 are defined as the partial derivatives:

displaymath455

In the present case, where the position coordinates tex2html_wrap_inline513 are tex2html_wrap_inline481 the canonically conjugate momentum coordinates tex2html_wrap_inline517 are related to the real momentum coordinates tex2html_wrap_inline519 by:

displaymath456

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 :

displaymath457

and uses the definition of tex2html_wrap_inline511 to eliminate the explicit dependence of H' on tex2html_wrap_inline527 and derive the Hamiltonian function tex2html_wrap_inline529 . Hamilton's equations then become:

displaymath458

displaymath459

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 tex2html_wrap_inline513 ( tex2html_wrap_inline481 ) and tex2html_wrap_inline511 ( tex2html_wrap_inline537 and tex2html_wrap_inline539 ) which can be conveniently written in the form:

displaymath460

displaymath461

displaymath462

displaymath463

The gravitational forces contained in the last two equations are explicitly time dependent, since tex2html_wrap_inline541 and tex2html_wrap_inline543 .
s1 and s2, the distances of the spacecraft of mass tex2html_wrap_inline487 from the Earth and the Moon respectively, arise in the expression for gravitational potential in the Lagrangian function. From geometry, the values are:

displaymath464

displaymath465

Writing C code for this problem similar to what we did before we define the 4-element array tex2html_wrap_inline551 to contain the computed variables tex2html_wrap_inline553 .
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 tex2html_wrap_inline487 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.


next up previous
Next: Adaptive step control in Up: DYNAMICAL PROBLEMS BY SOLUTION Previous: The flight path of

Keith Jones
Sun Jan 23 14:17:38 EST 2000