A supplied program models a pendulum in the small-angle approximation
PHYSICS · Subjective · Fermi University Physics · Computational Physics · Research software practice, verification and validation · Simulating classical dynamical systems
Computational Physics, Ch A workspace that can be rerun next year
Problem
A supplied program models a pendulum in the small-angle approximation, integrating θ¨=−(g/L)θ with a step-by-step scheme of the kind Chapter 1 built. Line 6 of the listing computes the angular acceleration as a = -(g/L)*theta. Take L=0.90m, θ0=0.15rad (initial angular velocity zero) and g=9.8ms−2. The equation is treated as exact (no real-pendulum nonlinearity), so its solution is θ(t)=θ0cos(ωt) with ω=g/L, and the period is T=2π/ω.
(a) State the exact value of θ at one quarter of the period, t=T/4, and use it to write a known-answer test as a single assert statement, testing θ(T/4) against a tolerance of 1×10−3rad.
(b) Run at a step of Δt=0.01s, the correct program returns θ(T/4)=1.5×10−4rad. Show that the test in part (a) passes, quoting the margin.
(c) Line 6 is now changed to a = +(g/L)*theta (a sign slip). Find analytically the value the corrupted model gives for θ(T/4), with the same initial conditions, and determine whether the known-answer test of part (a) passes or fails, quoting the printed difference.