I’ll create a simulation of a Spring-Mass System that demonstrates both simple harmonic motion and damped oscillation with external forcing.
1 | import numpy as np |
Let me explain the key components of this simulation:
System Parameters:
- Mass $(m) = 1.0 kg$
- Spring constant $(k) = 10.0 N/m$
- Damping coefficient $(c) = 0.5 Ns/m$
- Natural frequency $(ωn) = √(k/m) ≈ 3.16 rad/s$
- Initial displacement = $1.0 m$
- Initial velocity = $0.0 m/s$
Three Cases Simulated:
- Simple Harmonic Motion (no damping, no forcing)
- Damped Oscillation (with damping, no forcing)
- Forced Oscillation (with damping and external force)
Mathematical Model:
- Based on Newton’s Second Law: F = ma
- Differential equation: $mẍ + cẋ + kx = F₀sin(ωt)$
- Solved using scipy’s
odeintfunction
Plot Analysis:
Top Plot (Simple Harmonic Motion):
- Shows perfect sinusoidal oscillation
- Energy continuously transfers between potential and kinetic
Middle Plot (Damped Oscillation):
- Amplitude decreases exponentially due to damping
- System eventually comes to rest
Bottom Plot (Forced Oscillation):
- Initial transient response followed by steady-state oscillation
- Shows resonance effects as forcing frequency matches natural frequency
Physical Insights:
- Energy conservation in simple harmonic motion
- Energy dissipation in damped systems
- Resonance phenomenon in forced oscillation
- Phase relationships between position and velocity
Result
Natural frequency: 3.16 rad/s Damping ratio: 0.08










