A velocity Verlet routine integrates a simple harmonic oscillator with , ,
PHYSICS · Multi-part · Fermi University Physics · Mathematical Methods for Physics · Computational Physics · Research software practice, verification and validation
Scientific Computing for Physicists, Ch Is the equation solved right? Testing, debugging and code verification
Problem
A velocity Verlet routine integrates a simple harmonic oscillator with ω=2rads−1, x(0)=1m, v(0)=0ms−1, whose exact solution is x(t)=cos(ωt).
((a)) A unit test runs the routine with h=0.001s for 1000 steps to t=1s and compares x(1) with the exact value. State the exact value to six significant figures, and say whether the test passes a tolerance of 1×10−6m, given that the measured error at this step is 3.0×10−7m.
((b)) A property test runs the routine forward for N=2000 steps and then backward for 2000 steps with the same h, and checks that the state returns to its start. Each of the 2000 forward-backward step pairs contributes a rounding error of order ϵmach=2−52; take the property-test tolerance as 10Nϵmach/2, relative to the amplitude 1m. Compute the tolerance, and say whether a measured return-difference of 9.7×10−17 (the larger of the position and velocity differences) passes it.
((c)) An order-of-accuracy test on the same problem gives maximum errors e(0.02)=1.21×10−4m, e(0.01)=3.03×10−5m and e(0.005)=7.58×10−6m. Compute the observed order p^ from each consecutive pair using p^=ln[e(h)/e(h/2)]/ln2, and say whether the code is verified against velocity Verlet's formal order pformal=2.