projects / spring-pendulum
Spring-Pendulum Simulation
A case study in turning a coupled nonlinear model into an interactive web tool: define the equations, choose a stable numerical method, and expose the right controls so users can learn from parameter changes.
1) Model and governing equations
The state is represented by where is spring length and is angular displacement from the vertical. The model includes gravity, spring restoring force, and damping in radial and angular directions.
These equations produce rich motion regimes depending on initial conditions and stiffness-to-mass ratio.
2) Numerical solution strategy
The simulator uses a fixed-step RK4 integrator with user-controlled and end time . RK4 offers a practical balance: significantly better local accuracy than Euler while keeping implementation simple and predictable for browser playback.
The trajectory quality depends on timestep choice. Smaller improves fidelity but increases compute and rendering load. Larger timesteps run faster but can smooth out fast dynamics and reduce trust in the trace.