Spring-Mass-Damper System with External Forcing
Simulate the forced harmonic oscillator \(m\ddot{y}+c\dot{y}+ky=F(t)\) — observe resonance, beats, impulse response, and transient behaviour in real time.
Governing Equation
The simulation models a mass \(m\) attached to a spring with natural (rest) length \(L_0\) [m] and stiffness \(k\), subject to viscous damping \(c\) and an external force \(F(t)\). Let \(x\) denote the total extension from the fixed support. Newton's second law gives
The static equilibrium satisfies \(k(x_{\rm eq}-L_0)=mg\), so \(x_{\rm eq}=L_0+mg/k\). Defining displacement from static equilibrium \(y=x-x_{\rm eq}\) eliminates gravity and reduces the equation to
The rest length \(L_0\) sets the visual scale of the animation. Larger \(L_0\) provides more canvas space for large-amplitude oscillations. The natural frequency is \(\omega_0=\sqrt{k/m}\) and the damping ratio is \(\zeta=c/(2\sqrt{km})\).
Classification by Damping Ratio
- Underdamped \((\zeta<1)\): oscillations with exponentially decaying amplitude. Discriminant \(c^2-4mk<0\).
- Critically damped \((\zeta=1)\): fastest return to equilibrium without oscillation.
- Overdamped \((\zeta>1)\): slow exponential return, no oscillation.
Observable Phenomena
- Resonance (undamped): When \(\omega_\text{forcing}=\omega_0\) and \(c=0\), amplitude grows without bound as \(t\sin(\omega_0 t)\).
- Resonance (damped): Amplitude peaks near \(\omega_0\) but remains bounded; the steady-state amplitude is \(F_0/(c\omega_0)\) at exact resonance.
- Beats: When the forcing frequency is close but not equal to \(\omega_0\), the solution exhibits slow oscillation of amplitude — a beating pattern at frequency \(|\omega-\omega_0|/2\).
- Transient and steady state: The general solution is the sum of the homogeneous (transient) and particular (steady-state) solutions. For \(c>0\), the transient decays and only the steady-state remains.
Special Forcing Functions
Expression examples: 5*cos(2*t), 3*delta(t-10), u(t-5)*cos(2*(t-5)), 2*delta(t-10)+u(t-35)*cos(2*(t-35)).
Numerical Integration
- Velocity Verlet (Störmer method): Symplectic integrator used for non-stiff systems (\(c^2-4mk\le5\)). Fixed step \(\Delta t=0.01\,\text{s}\).
- Backward Euler / BDF-2: A-stable implicit methods for stiff (heavily overdamped) systems.
- Impulse handling: The delta function impulse is applied as a direct velocity jump.
How to Use
- Adjust \(m,c,k,L_0\) and initial conditions using sliders or value boxes. The equation updates automatically.
- Increase \(L_0\) to lengthen the spring and allow larger initial displacements \(y_0\).
- Enter any expression for \(F(t)\) in the forcing function field. Use
tas the time variable. - Select an example from the dropdown to load preset parameters.
- Click Reset to restart. Click Pause/Resume to freeze and continue.