next up previous
Next: Things to do Up: DYNAMICAL PROBLEMS BY SOLUTION Previous: Formulation of Hamilton's equations

Adaptive step control in the Runge-Kutta method

The gravitational potential varies very rapidly near the Earth or Moon but relatively slowly at a great distance. For computational efficiency therefore one needs to use a small temporal stepsize h near the Earth and a greater one further away. If you write a computer program to solve this problem using runge.c directly (not recommended) you will find that it inevitably happens that the spacecraft gets too close to the Earth, the temporal stepsize is too great, the calculation overshoots and gives the spacecraft too great a kinetic energy and the spacecraft careers out of the Earth-Moon system at the speed of light.
What is needed is a routine that checks how rapidly the solution is varying and automatically adjusts the temporal step size appropriately, i.e. it adapts the step size to the problem. finteg.c (in the same directory as hamil.c) is such a routine for runge.c . The way finteg.c works is, you suggest a stepsize h, finteg.c uses runge.c to compute a solution for stepsizes h and tex2html_wrap_inline565 . From these solutions finteg works out how rapidly the solution error is changeing with h and knowing that in runge the error is fifth order, it computes the required h to keep the error below some tolerance tol say. Note that finteg.c is not in the standard form of C code. It has been translated directly from the Fortran version. It uses goto statements usually greatly deprecated in C programming. This is in keeping with the spirit of this course to use C as higher level language only and not e.g. to use pointers. If you would like to read a more detailed description of how finteg works, ask the lecturer for a copy of a handout.

In fact finteg is not the most sophisticated adaptive step size routine. It uses the same tolerance test for each of the variables so you don't want the different variables to differ in magnitude by too many orders of magnitude. In this problem this objective can be attained by using units of tex2html_wrap_inline581 in length and time in hours. You should do this. Check that in these units the numerical value of the gravitational constant is tex2html_wrap_inline585 (whereas in SI units tex2html_wrap_inline587 ).


next up previous
Next: Things to do Up: DYNAMICAL PROBLEMS BY SOLUTION Previous: Formulation of Hamilton's equations

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