Practice steering a driven oscillator toward resonance. Adjust the driving frequency to keep the oscillation amplitude inside the highlighted band before the countdown expires. The target band changes after each successful lock, so react quickly and ride the resonance wave.
Click the overlay to begin, then steer the drive frequency with arrow keys or the buttons.
Keyboard: Left/Right adjust ω by ±0.2 rad/s, A/D adjust by ±0.05 rad/s, R resets to ωₙ. Hold the amplitude inside the glowing band long enough to score before the timer hits zero.
From car suspensions to seismographs, masses attached to springs appear throughout engineering and daily life. Real devices rarely oscillate forever; friction and air resistance sap energy, while periodic forces like engine vibrations or ocean waves drive motion. The simulator above preserves the original calculator’s goal of predicting natural frequency and period but upgrades it with a live model of a damped, driven oscillator. As you tweak mass, spring stiffness, damping, and driving force, a block sloshes back and forth on an HTML5 canvas while striped bars track kinetic energy, elastic potential, and cumulative energy dissipated by friction. You can freeze the motion, change the time step, and export the time series, turning a static formula into an experimental sandbox.
The model treats a point mass attached to a massless spring with constant and a linear damper with coefficient . The block starts at displacement with zero velocity and may experience a sinusoidal driving force of amplitude and angular frequency . Gravity acts vertically but the motion is constrained along a frictionless horizontal rail so gravitational potential energy does not change. Units are strictly SI: kilograms, newtons per meter, newton‑seconds per meter, meters, and seconds. Inputs are validated to be finite numbers, with non‑positive masses or stiffnesses rejected, damping and time step clamped to non‑negative ranges, and extreme amplitudes limited to ±1 m to keep the spring in view.
Newton’s second law balances forces on the mass:
with . Kinetic and potential energies follow
, .
The damper converts mechanical energy into heat at a rate
The coupled first‑order system for and rarely admits closed solutions once damping and forcing enter, so the simulation employs the classical fourth‑order Runge–Kutta (RK4) method. For a state vector at time and step size , RK4 evaluates four derivative estimates … and combines them as
The method’s local truncation error scales with , making it stable for modest step sizes. The input field lets you clamp between 0.0005 and 0.1 s. Smaller steps capture sharp transients and reduce energy drift at the cost of computation. The ΔE readout beside the energy bars reveals accumulated numerical error by comparing instantaneous to the initial total energy.
Consider a 1 kg mass on a 20 N/m spring with 0.5 N·s/m damping, initially displaced 0.1 m. With no external drive, the natural frequency is rad/s and the period s. Press Play and the block swings, the orange kinetic bar peaking as it passes equilibrium and the blue potential bar dominating at the turning points. Over time the gray dissipation bar grows as friction bleeds energy, eventually bringing the mass to rest. If you set N and rad/s, the system resonates: despite damping, the forcing replenishes lost energy and the amplitude stabilizes near 0.2 m.
The table contrasts the baseline case above with two variants: heavy damping and a lighter mass. Values are extracted from the simulation after transient effects settle.
| Scenario | m (kg) | c (N·s/m) | Steady Amplitude (m) | ΔE after 5 s (%) |
|---|---|---|---|---|
| Baseline | 1 | 0.5 | 0.20 | 0.8 |
| Heavy damping | 1 | 2 | 0.08 | 0.5 |
| Lighter mass | 0.5 | 0.5 | 0.35 | 1.2 |
Increasing the damping coefficient shrinks the steady amplitude dramatically, while halving the mass raises the natural frequency and allows stronger resonance, albeit with slightly larger energy drift at the same time step.
The canvas shows a wall on the left, a zig‑zag spring, and a square mass whose position represents . When the mass moves right, the spring stretches; when it moves left, the coils compress. The striped orange bar denotes kinetic energy, the blue bar elastic potential, and the gray bar cumulative dissipation. Because the bars use both texture and text labels, color perception is unnecessary. The caption beneath the canvas reports time, displacement, and energies in words so screen‑reader users receive the same information. Keyboard users can focus the canvas and press the space bar to toggle play and pause.
The model assumes a perfectly linear spring and damper. Real springs stiffen or soften with large deflections, and dampers may depend on velocity in more complicated ways. The driving force is purely sinusoidal; real engines or waves may impose non‑harmonic forcing. Numerical integration introduces small energy drift, especially with large time steps or stiff parameters. Because the simulation is one‑dimensional, it cannot capture torsional or multi‑degree‑of‑freedom effects common in complex machines. Despite these simplifications, the simulator captures the essential physics of resonance and damping.
Extensions could include multiple masses coupled by springs, nonlinear restoring forces, or stochastic driving terms that mimic thermal noise. Plotting phase space ( versus ) would reveal spirals for damped systems and limit cycles under steady forcing. Another avenue is implementing adaptive step size control to maintain constant error while maximizing performance.
For deeper study, consult H. Goldstein’s Classical Mechanics or J. L. Meriam’s Engineering Mechanics: Dynamics. To explore static spring properties, visit the Hooke’s Law Spring Calculator, compute work input with the Work Done by Force Calculator, or examine projectile motion through the Projectile Motion Simulator.