Damped Harmonic Oscillator Calculator

Introduction

A damped harmonic oscillator is one of the most useful models in physics and engineering because it turns a surprisingly wide range of real systems into the same understandable story. A car suspension, a machine mounted on rubber feet, a seismically isolated floor, a microphone diaphragm, and even an electrical RLC circuit can all be interpreted as something that wants to oscillate, but also loses energy as it moves. This calculator lets you explore that story directly. You enter a mass, a spring stiffness, a damping coefficient, optional starting conditions, and an optional sinusoidal drive. The page then precomputes the motion, animates the response on a canvas, shows how the displacement and velocity evolve, and tracks where the energy goes.

The most helpful part of a calculator like this is not just the final number at one moment in time. It is the pattern. When damping is small, the motion rings for a long time and the oscillations decay gradually. When damping is moderate, the peaks shrink faster. When damping becomes very large, the system may stop oscillating altogether and instead creep back toward equilibrium. If you add a periodic external force, you can also study resonance, which is the reason some systems react violently near a particular frequency while others remain controlled. By watching the animation and the energy bars together, you can see the same physical idea from several angles at once: the mass moves, the spring stores and releases energy, and the damper steadily removes mechanical energy from the system.

This page is meant for practical learning, quick checks, and intuition building. It uses SI units, gives immediate feedback when you change inputs, and allows CSV export for deeper analysis in spreadsheets or code. If you are a student, the calculator can help connect textbook formulas to visible motion. If you are an engineer or hobbyist, it offers a fast way to test how sensitive a design is to stiffness, damping, or forcing frequency before moving on to a more detailed model.

Model, formulas, and what each input means

The simulator uses the standard linear mass-spring-damper equation with optional sinusoidal forcing. In plain language, the mass resists acceleration, the spring pulls toward equilibrium, the damper resists velocity, and the external force can keep feeding energy into the motion. The governing equation is

m d2x dt2 + c dx dt + k x = F0 sin ( ωd t )

Here m is the mass in kilograms, k is the spring constant in newtons per meter, c is the viscous damping coefficient in kilograms per second, x is displacement in meters, and v is velocity in meters per second. The drive force is entered through F(t)=F0sin(ωdt). If the forcing amplitude is zero, the motion is free vibration determined only by the initial conditions. If the forcing amplitude is nonzero, the motion becomes forced vibration and the relationship between the drive frequency and the natural frequency starts to matter a great deal.

ωn = km , ζ = c2mk

The natural frequency ωn tells you how quickly the system would oscillate if there were no damping and no forcing, while the damping ratio ζ classifies the shape of the response. That classification is often the quickest way to understand what you are seeing on the screen:

  • ζ<1: underdamped motion oscillates while its amplitude decays over time.
  • ζ=1: critically damped motion returns to equilibrium as quickly as possible without oscillating.
  • ζ>1: overdamped motion returns without oscillation but more slowly than the critically damped case.

Three related formulas are useful when you want a little more intuition without diving into a full vibration textbook. The decay rate of the free response is often written as α=c2m. In the lightly damped case, the envelope of the oscillation follows xenv(t)=Ce-αt, which is why the peaks get smaller in a smooth exponential way rather than dropping by a fixed amount every cycle. For forced vibration with light damping, the resonant response tends to occur near ωrωn1-2ζ2, which helps explain why damping shifts and softens the peak rather than simply shrinking every motion equally.

The calculator assumes a single moving degree of freedom. The position is measured relative to the equilibrium location, written as x=0. You can set the starting state with the initial displacement x0 and initial velocity v0. Air resistance, seal friction, material hysteresis, and other losses are all represented by the single coefficient c, so this is intentionally a simplified linear model. The time step Δt controls the numerical integration. Smaller steps usually improve accuracy, especially when the system is stiff or the forcing varies rapidly.

For the actual computation, the simulator rewrites the motion as a first-order system. Newton's second law is evaluated as

mdvdt=F(t)-cv-kx, with the kinematic relation dxdt=v. That gives the pair

dxdt=v, dvdt=F(t)-cv-kxm. The page also follows the energy flow using Ek=12mv2 for kinetic energy, Ep=12kx2 for spring energy, and Pd=cv2 for dissipated power. The cumulative work supplied by the forcing is written as W=F(t)vdt, so the simulation can monitor the energy-balance expression Ek+Ep+Ed-(E0+W).

The numerical scheme is a classical fourth-order Runge-Kutta method. With each step of size Δt, the code samples the derivatives several times and combines them through

s(t+Δt)=s(t)+Δt6(k1+2k2+2k3+k4)

That method is accurate enough for an interactive page, and its local error scales with Δt5. In practice, that means a smaller step can greatly improve the quality of the motion and the energy accounting. If you choose very large k or very large c, keep an eye on the result and consider reducing Δt if the response looks jagged or unstable.

How to use the calculator and read the results

Start by choosing the physical properties of the oscillator. Mass controls inertia, so larger mass usually means slower motion. Spring constant controls stiffness, so larger values raise the natural frequency and make the system resist displacement more strongly. Damping coefficient sets how aggressively energy is removed. Initial displacement and initial velocity tell the simulator how much spring energy and kinetic energy are present at the start. If you leave the forcing amplitude at zero, you are studying free decay. If you enter a nonzero forcing amplitude and a drive frequency, you are asking how the oscillator responds to continuous sinusoidal input.

  • Mass (m, kg) changes how hard the system is to accelerate.
  • Spring constant (k, N/m) sets stiffness and influences natural frequency.
  • Damping coefficient (c, kg/s) controls how quickly oscillations die out.
  • Initial displacement and velocity define the starting state.
  • Forcing amplitude F₀ and drive frequency ωd create steady-state forcing and resonance effects.
  • Time step Δt balances smoothness, numerical stability, and speed.

Once the parameters look right, press Play to animate the precomputed solution, Pause to stop, and Reset to jump back to the initial state. The status line reports whether the simulation is ready, and the figure caption reports the current time, displacement, velocity, and energy-balance error. The three progress bars give a fast visual sense of where the energy is at that moment: kinetic energy peaks near the equilibrium crossing, spring energy peaks near the turning points, and dissipated energy grows steadily as the damper does work. The CSV button exports the sampled trajectory, which is useful if you want to make your own plots, compute spectra, or compare several parameter sets in Python, MATLAB, Excel, or another tool.

If you are interpreting the result for design or study, do not focus only on one peak. Look for a pattern over time. Ask whether the displacement envelope decays, whether it settles without overshoot, whether forcing produces a persistent steady-state amplitude, and whether the energy-balance error remains small. Those questions matter because they separate genuine physical behavior from numerical artifacts. A stable, well-chosen step size should give a smooth curve and a tiny energy mismatch. The table below summarizes the usual damping regimes so you can connect the value of ζ to the shape of the response you see on the page.

Regime Damping ratio What you usually see Typical examples
Underdamped 0 < ζ < 1 Oscillations with a shrinking envelope Lightly damped structures, instruments, many suspensions
Critically damped ζ = 1 Fast return to equilibrium without overshoot Positioning systems, some control applications
Overdamped ζ > 1 No oscillation, but a slower return than the critical case Strong shock isolation or deliberately sluggish motion

Worked example

Suppose you model a 1 kg mass attached to a spring with k = 20 N/m and damping c = 0.5 kg/s. Let the starting conditions be a 0.1 m displacement and zero initial velocity, with no external forcing. The calculator then gives

  • ωn=2014.47 rad/s
  • ζ=0.521200.056

That damping ratio is much less than one, so the system is clearly underdamped. In other words, the mass oscillates back and forth while the envelope decays slowly. You can write the entered values directly as k=20, c=0.5, x0=0.1, and v0=0. If you run that case with Δt=0.02, the animation shows the block pass through equilibrium repeatedly while the dissipated-energy bar rises. The envelope decay is associated with the time constant τ=2mc, which equals about 4 s for this example. The oscillation frequency is slightly lower than the undamped natural frequency; one common expression for the damped natural frequency is ωd=km-c24m2. In this section that symbol refers to the damped natural frequency, not the user-entered drive frequency.

To see resonance, keep the same mass and spring but turn on forcing with a nonzero amplitude. Then choose a drive frequency close to the natural frequency. The transient response may still decay, but a steady-state oscillation will remain because the external force keeps adding energy. In a lightly damped system the steady-state amplitude can become large near resonance. If you raise the damping coefficient, the resonant peak drops and broadens. That is why damping is so important in real products: it may not change the equilibrium position, but it strongly changes how violently a system responds to disturbance and forcing.

Assumptions, limits, and sensible use

This calculator is intentionally simple and educational. It assumes a linear spring, linear viscous damping, a single moving coordinate, constant parameters, and small enough motion that geometric nonlinearities do not matter. Real components can depart from those assumptions in several ways. Dry friction is not the same as viscous damping. Rubber mounts can have frequency-dependent losses. Springs may stiffen, soften, or bottom out. Structures can have multiple modes that couple together. External forcing may be irregular rather than perfectly sinusoidal. None of those effects are captured here. The page is best used for learning, screening, and first-pass estimates rather than certified engineering design.

Even within this linear model, numerical choices matter. Very stiff systems or very aggressive damping can require a smaller time step, and any computer model should be checked against expected scales and, when possible, analytic results. If the animation looks erratic, reduce the time step and verify your units. A mass entered in kilograms, a spring constant in newtons per meter, and damping in kilograms per second must all be physically consistent. For related explorations, you may also want to compare a pure spring case in the Mass-Spring Oscillation Calculator, an electrical analogy in the RLC Circuit Damping Calculator, or motion without spring restoring force in the Projectile Motion Calculator.

Enter parameters and press Play.
Simulation summary will appear here.

Kinetic energy

Spring potential energy

Dissipated energy

Resonance Arena Mini-Game

React to changing drive frequencies by dialing in damping fast enough to keep the steady-state amplitude below the damage threshold. Each round turns the frequency-response formula into an arcade-style challenge. Use pointer dragging on the slider, or use the arrow keys while the page is active.

Keep amplitude inside safe band

Click to Play, tune damping in time, and survive all 80 seconds.

Best run: 0

Embed this calculator

Copy and paste the HTML below to add the Damped Harmonic Oscillator Calculator & Interactive Simulation to your website.