An Euler-Cromer 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
An Euler-Cromer routine integrates a simple harmonic oscillator with ω=1rads−1, x(0)=1m, v(0)=0ms−1, exact solution x(t)=cos(ωt).
((a)) A unit test runs the routine to t=1s with h=0.001s. State the exact value x(1)=cos(1) to six significant figures, and say whether the test passes a tolerance of 2×10−3m, given a measured error of 4.2×10−4m at this step.
((b)) The Euler-Cromer map is area-preserving: the Jacobian determinant of one step is exactly 1 for any h. A property test computes this determinant numerically, by LU factorisation at h=0.01s, and checks ∣det−1∣ against tolerance 5ϵmach, with ϵmach=2−52. Compute the tolerance, and say whether a measured value of 1.1×10−16 passes it.
((c)) An order-of-accuracy test gives maximum errors e(0.02)=8.43×10−3m, e(0.01)=4.21×10−3m and e(0.005)=2.10×10−3m. Compute p^ from each consecutive pair using p^=ln[e(h)/e(h/2)]/ln2, and say whether the code is verified against Euler-Cromer's formal order pformal=1.