Determination of optimal step size   Previous: The numerical step Up: Details of the simulation program

## Determination of optimal step size There are three possible outcomes of the step size comparison in the numerical integration:

• the step size should be reduced
• the step size should be increased
• the step size was acceptable

In practice, the step size is always either increased or decreased. There is a limit to how much it can be increased or decreased, however. It will not be increased by a factor of more than four in one iteration. It will not be decreased by a factor of more than ten in one iteration. If the step size needs to be decreased by more than a factor of ten, then the current iteration is considered to have failed, and the current step size is decreased. The calculations are then started over again.

Another test is made prior to integrating. This test either passes or fails the current step size. A constraint is made that when two particles pass ``through'' each other at the centre of mass, that they do it with a small step size. The reasons for this will be explained in the section . This constraint is maintained by failing the current step size (reducing it by half, and causing the calculations to be restarted) if the current step size times the velocity, causes the particle to pass its partner.

overshoot3Potential as a function of time, showing overshoot problem There is a third control on the step size that can be seen in the main loop above; the simulation is made to approach a change in pairing at a slow pace. In effect, the simulation is performing a binary search of the position space, to determine precisely where the sharp critical point in the potential function is. By approaching this point slowly, and passing through it with a very small step size, the error due to overshooting is minimized. Figure shows two overshoots that can happen. It would be fortunate if the two types cancelled, but this can not really be expected.

mcr@ccs.carleton.ca