The purpose of this Java applet is to understand the stability of different numerical methods for resolving the dynamics of a Spring-Mass system. The differential equation is a simple harmonic oscillator, x'' = - w^2 x - f x', where w is the frequency of the oscillation, and f is the dynamic friction coefficient. In this example the frequency is fixed at 1, and the friction can be varied by the user.
Instructions for running a simulation:
Understanding the results:
Suggested experiments:
Explanation of behaviour:
Verlet, Symplectic Euler A, Symplectic Euler B, are all symplectic numerical integrators. They work especially well with relatively large timesteps and no friction. Symplectic Euler A and B are adjoints of each other, and Verlet is the composition of the two. They have a stability threshold at twice the period of the motion, hence dt > 2.0 will break the methods. Backward Euler and Runge-Kutta 4 introduce artificial friction at larger stepsizes, and hence dissipate the energy. Forward Euler introduces artificial negative friction, making it unstable for problems without friction. The symplectic methods produce near periodic orbits over long time intervals. So although the energy may fluctuate, it does not significantly drift over long time intervals. This is basically the primary reason why Verlet method is so popular in molecular simulation. Another reason is that it is inexpensive, requiring only one force evaluation per step, and is second-order accurate. In contrast the two Symplectic Euler methods have the same cost, but are only first-order accurate.
Credit and Source:
This applet was created using the source provided by the Connected Curriculum Project. In particular, it was created by modifying "A Spring and Mass System" applet. In agreement with the license, this applet is being used for noncommercial purposes. You can download the source for this Java applet here. Please give proper credit to the CCP if you reuse this applet in any form.