Advertisement

A Comparison of Numeric Integration Schemes

Runge Kutta vs. Euler - On the Influence of time step sizes on the accuracy of numerical simulations

Magnetic pendulum revisited

The next test will deal with a magnetic pendulum simulation. The basic principles of the magnetic pendulum are explained in Video 1. The model used in this test is shown in Image 5. The simluation was solved with different integration schemes for a lot of different time step sizes. The results will then be compared and analysed with regard to time step sizes and accuracy.

Video 1: Explanation of the magnetic pendulum; © 2007 Aldo Cavini Benedetti
Model setup
Image 7: The second test used a Magnetic pendulum model with 10 Magnets.

But before we do so lets have a look at two sample points. The movement of the pendulum is chaotic but chaotic behavior doesnt mean you can't calculate it, it just means that the calculation error increases exponentially with time. So you can't calculate very much into the future because eventually even small variations in the initial conditions will grow and produce results that are totally different. The next test will investigate traces produced by different integration schemes. For this test the initial conditions of all integration schemes were identic so any error in the traces is the direct result of inaccuracies of the integration scheme. As you can see in image 8 There are some points in the simulation domain with virtually no difference between the edifferent results whilst there are other points were virtually every scheme produces a different result (Image 9).

pendulum trace sample
Image 8: There are starting points for which all integration schemes provide almost identic results.
chaotic pendulum trace sample
Image 9: Other starting points yield different results for almost all integration schemes.

Simulation results

With this background it's interesting to see how a complete calculation will look like. First lets start with the resulting image. The following images were calculated with a time step size of h=0.015 s.

integration results
Image 10: Overview of all results obtained with different integration schemes.

Large parts of the simulation domain show a chaotic behaviour, the central part and some structures are reproduceable regardless of the integration scheme. On a first glance all solutions look remarkably similar but maybe we should have a closer look how similar they are:

differential image
Image 11: Greyscale image in which the value of a pixel indicates how many different results were obtained. White means all 10 integration schemes produced the same result, black means all produced different results. Pixelcolors were taken from the results of the RK5 scheme.
results filtered with differential image
Image 12: The resulting image with pixels only shown if 9 out of 10 integration schemes produced the same result.

It is obvious that there are regions close to the magnets where most or all integration schemes yield the same end result. These are regions close to a magnet in which the pendulum doesn't really have much of a choice. If you get farther away from the centre (black regions) the results usually differ. Especially paths having many close encounters with Magnets exhibit strong chaotic behaviour. This is due to the force being proportional to the inverse square of the distance to the source. Consequently even small differences in the positions will have a dramatic effect on the path taken later on. And that is the very nature of chaotic behaviour.

Whatever you simulate in the future keep in mind that even the best integration scheme is always just an approximation of the truth. Using different simulation runs with slightly changed parameters and initial conditions can show you certain trends and provide statistic data on how reliable those trends are. This is usually done with so called Monte Carlo simulations but that is an entirely different topic.

back      next

You might also like: