Kinetic energy
—
A damped harmonic oscillator is a simple model of a vibrating system that loses energy over time. In this calculator, the system is a single mass attached to a spring and a damper (dashpot). The spring stores energy, the mass carries kinetic energy, and the damper removes energy as heat or friction.
This model appears in many contexts: a car suspension, a building in an earthquake, a microphone diaphragm, or an RLC electrical circuit. By adjusting the parameters and playing the animation, you can see how displacement, velocity, and the different energy components evolve with time.
The motion of the mass is described by a second‑order differential equation. The calculator uses the standard linear mass–spring–damper model with optional sinusoidal forcing:
Here, m is mass (kg), c is damping coefficient (kg/s), k is spring constant (N/m), x is displacement (m),
Two important derived quantities are the natural frequency and damping ratio:
The damping ratio tells you the qualitative behavior:
The calculator also tracks energy terms:
Use the input fields above to configure the system:
After choosing values, select Play to run the simulation, Pause to stop it, and Reset to return to the initial conditions. The plots show displacement and velocity over time, along with kinetic, spring, and dissipated energies. Use the CSV download to export the time‑series for analysis in tools such as Excel, Python, or MATLAB.
Suppose you model a 1 kg mass on a spring with k = 20 N/m and c = 0.5 kg/s, with initial displacement x₀ = 0.1 m and zero initial velocity, and no external forcing (F₀ = 0). The calculator computes:
The displacement will oscillate with a frequency slightly less than ωn, and the amplitude will gradually decrease due to damping. In the energy plot, the sum of kinetic and spring energies decays monotonically as energy is transferred to the damper (dissipated energy curve increases).
If you now set F₀ to a non‑zero value and choose ωd close to 4.47 rad/s, the steady‑state amplitude of motion will grow, demonstrating resonance. Increasing c reduces the resonant peak and broadens the frequency response.
| Regime | Damping ratio (ζ) | Qualitative motion | Typical use cases |
|---|---|---|---|
| Underdamped | 0 < ζ < 1 | Oscillatory with decaying amplitude | Suspensions, lightly damped structures, acoustics |
| Critically damped | ζ = 1 | Fastest return to equilibrium without overshoot | Precision positioning, some control systems |
| Overdamped | ζ > 1 | Slow, non‑oscillatory response | Highly damped supports, shock isolation where oscillation is undesirable |
Focus on the following when reading the plots:
With the CSV export, you can compute additional quantities such as frequency spectra, phase plots (x versus v), or compare multiple parameter sets programmatically.
This simulator is designed for education and preliminary insight, not for certified engineering design. The underlying model assumes:
Always check whether this simplified model is appropriate for your application before drawing design‑level conclusions.
From automobile suspensions to seismically isolated buildings, countless machines rely on the balance between inertia, spring stiffness, and damping. A traditional damped harmonic oscillator calculator reports only a displacement value, concealing how energy sloshes between kinetic and elastic stores while friction steals a portion every cycle. This interactive version keeps the original purpose of computing motion but augments it with a canvas that shows a block bobbing on a spring. As you adjust parameters like mass or forcing amplitude, the animation and energy bars update instantly, clarifying why an overly soft shock absorber leads to bouncy rides or why a lightly damped bridge oscillates for minutes after a gust of wind.
The model treats a single degree‑of‑freedom system consisting of mass , spring constant , and viscous damping coefficient . Position and velocity are measured along the spring’s axis with the equilibrium at . Optional sinusoidal forcing can drive the oscillator. Initial conditions and set the starting state. Air resistance and structural damping are modeled with the single coefficient ; nonlinear effects, large deflections, and temperature‑dependent stiffness are ignored. All quantities use SI units: kilograms, newtons, meters, and seconds. Input validation rejects non‑finite or negative mass and spring values, and the time step is clamped between 0.001 and 0.1 s to maintain numerical stability.
The dynamics follow Newton’s second law applied to the mass: . Introducing yields a first‑order system:
, . Kinetic and potential energies are and , while the power dissipated by damping is . The work performed by the driving force accumulates as , allowing an energy balance check .
The simulator advances the state with a classical fourth‑order Runge–Kutta method. For each step of size , four derivative estimates sample the forces at the beginning, two midpoints, and the end. The weighted average updates position and velocity simultaneously. RK4 offers a good compromise between speed and accuracy; the local error scales with , so halving the step roughly reduces the global error by a factor of sixteen. Nevertheless, very stiff systems with large or may require smaller steps to avoid overshoot. The code clamps the user‑selected and recomputes the trajectory whenever inputs change, debounced by 400 ms to prevent excessive re‑simulation during typing.
Consider a 1 kg mass attached to a spring with N/m and damping kg/s. Starting from m and , with no external forcing, the simulator predicts oscillations that decay with a time constant ≈ 4 s. Running the animation with s shows the block initially move toward the origin, overshoot, and settle after a few cycles. The energy bars reveal kinetic energy peaking as the block passes equilibrium and shrinking as damping converts it to heat. Downloading the CSV confirms the analytic period of about 1.4 s derived from .
The table contrasts the baseline oscillator above with two variations: increased damping and a driven case. Values are extracted from the simulation after five seconds.
| Scenario | c (kg/s) | F₀ (N) | Max |x| (m) | Energy drift (J) |
|---|---|---|---|---|
| Baseline | 0.5 | 0 | 0.10 | ≈0 |
| Heavier damping | 2.0 | 0 | 0.04 | ≈0 |
| Driven | 0.5 | 1.0 | 0.12 | <0.001 |
Doubling the damping coefficient reduces the peak displacement to 4 cm, while a modest sinusoidal drive at the natural frequency slightly increases the amplitude without introducing significant numerical energy error.
The canvas displays a horizontal spring anchored to the left wall with a colored block on the right. The block’s position corresponds to the instantaneous displacement, scaled to fit the viewport. A blue trail traces its recent path. Beneath the canvas, striped orange, blue, and gray bars show kinetic energy, spring potential energy, and cumulative dissipated energy, respectively, with text labels so color perception is unnecessary. The caption narrates time, displacement, velocity, and the small energy‑balance error. Focus the canvas with the keyboard and press the space bar to toggle play and pause. The hidden “Simulation summary” div mirrors these numbers for screen readers.
Several idealizations keep the model tractable. Damping is purely viscous and linear, whereas real shock absorbers can exhibit velocity‑squared or hysteretic behavior. The spring obeys Hooke’s law without yielding or coil bind. Forcing is limited to a single sinusoid; arbitrary waveforms or impacts are not included. The system moves only in one dimension, ignoring torsional or lateral modes. Numerical integration assumes the parameters remain constant and may lose accuracy for extremely stiff or poorly scaled inputs. Despite these simplifications, the simulator captures the essential trade‑offs that govern many engineering designs.
Ambitious users could extend the code to include nonlinear damping, piecewise spring behavior, or multiple degrees of freedom coupled in series. Plotting velocity versus displacement would generate a phase‑space portrait that highlights spiraling toward rest. Another extension is to add a second mass and spring, exploring resonance and modal beating. Because the project uses only vanilla JavaScript, editing the source to experiment with control strategies or feedback loops is straightforward. For related explorations, see the Mass‑Spring Oscillation Calculator, compare electrical analogs with the RLC Circuit Damping Calculator, or examine motion without springs in the Projectile Motion Calculator.
Standard treatments of damped oscillations appear in H. Goldstein, C. Poole, and J. Safko, Classical Mechanics, and R. C. Hibbeler, Engineering Mechanics: Dynamics. These texts discuss linear systems, energy methods, and the effect of damping on resonance. The numerical technique follows the RK4 algorithm described in any introductory computational physics resource.
—
—
—
React to changing drive frequencies by dialing in damping fast enough to keep the steady-state amplitude below the damage threshold. Each round translates the response curve into an arcade-style targeting challenge.