Skip to content
ScienceQuest
Mechanics Simulator School

Mass Spring Simulator

Oscillate a mass on a spring with adjustable stiffness, damping and driving force. See the three damping regimes and a real resonance curve with its peak.

Simulator

Drag the block to set where it is released, or move it with the up and down arrow keys. Space plays and pauses.

Natural period
T = 2π√(m/k). Independent of amplitude, and unchanged by gravity.
0.9935 s
Natural frequency
1.007 Hz
Damping regime
Set by the damping ratio: below 1 it oscillates, at 1 it returns fastest without overshooting, above 1 it crawls back.
Undamped
Damping ratio ζ
Critical damping for this mass and spring is 6.325 kg/s.
0
Static extension
How far gravity stretches the spring before it oscillates. This is how a lab measures k.
0.2453 m
Displacement
0 m
Parameters
kg
N/m

Stiffer springs oscillate faster. Period goes as 1/√k.

kg/s

Compare it with the critical value in the readouts to find the boundary.

m

Measured from equilibrium, so gravity is already accounted for.

N

Above zero the support is shaken and a resonance curve appears below.

  • Displacement (m)
Displacement from equilibrium against time over four natural periods, or 40 s if that is shorter, with the decay envelope the motion stays inside shown when it is damped, undriven and still oscillating.

Citing this tool

Last updated . Add the date you accessed it as well, which a citation of a page that can change asks for. If a specific result matters, cite the permalink from the tool’s share row instead of this page: it reproduces the exact parameters.

Teaching with this? You can put it on a class page or LMS for free, with no ads inside the frame. Get the embed code.

The equation

T=2πmkT = 2\pi\sqrt{\frac{m}{k}}

Hooke’s law (1678) with simple harmonic motion

Why the period ignores how far you pull it

A spring pulls back in proportion to how far it is stretched, F = −kx. Pull the mass twice as far and the restoring force doubles, so it accelerates twice as hard and covers twice the distance in the same time. The amplitude cancels, leaving T = 2π√(m/k), which contains no amplitude term at all.

That proportionality is the definition of simple harmonic motion, and it is exactly what a pendulum lacks. A pendulum’s restoring force goes as sin θ, which is only proportional to θ while θ is small, which is why its period does creep up with amplitude. Run the pendulum simulator at 90° and the two behave visibly differently.

Gravity moves the middle, not the timing

Hang the mass on and the spring stretches by mg/k before anything oscillates. For 0.5 kg on a 20 N/m spring that is 24.5 cm. It is tempting to think this changes the motion, and it does not: substitute x = mg/k + u into the equation of motion and the mg term cancels exactly, leaving the same equation in u. The mass oscillates about the new equilibrium with the same period it would have on a frictionless horizontal table.

This is why every displacement here is measured from equilibrium rather than from the unstretched spring, and why gravity appears in only one place: the static extension readout. That extension is not a footnote either, it is the standard way to measure a spring constant. Hang a known mass, measure how far it drops, and k = mg/e.

The three damping regimes, and the surprise

Add a resistance proportional to velocity and everything depends on how it compares with one particular value, the critical damping 2√(km). The ratio of the two is the damping ratio ζ.

  • Underdamped, ζ < 1. Still oscillates, with the amplitude decaying as e^(−ζω₀t). The period is slightly longer than the undamped one, by a factor 1/√(1 − ζ²).
  • Critically damped, ζ = 1. Returns to equilibrium as quickly as possible without ever crossing it. This is what a door closer and a car suspension aim for.
  • Overdamped, ζ > 1. Returns more slowly than critical. This is the part that catches people out: past the critical value, adding damping makes the return take longer, not shorter. Set the damping to three times critical and watch it crawl.

The boundary is sharp and the readouts name the critical value for whatever mass and spring you have chosen, so you can drive the damping to it and watch the last oscillation disappear.

Resonance, and why it does not peak at the natural frequency

Turn the driving force above zero and a second plot appears: steady-state amplitude against driving frequency. The peak is resonance, and its position is f₀√(1 − 2ζ²), which is always below the natural frequency f₀. With light damping the difference is negligible and calling the peak f₀ is harmless. At ζ = 0.3 it is already 9 percent low.

Past ζ = 1/√2 ≈ 0.707 the peak vanishes entirely and the response falls away monotonically from its value at zero frequency. There is no resonance to find. That threshold is the whole design goal of a well-damped instrument: a moving-coil meter needle that resonated would be useless.

With no damping at all and driving exactly at resonance, the amplitude grows without limit. The curve here leaves a gap at that frequency rather than capping it at some invented ceiling, because a finite peak would teach that resonance has a maximum.

Where this model stops describing reality

Three assumptions, all of them reasonable and all of them breakable. The spring obeys Hooke’s law, which holds up to its limit of proportionality; stretched past its elastic limit, which comes at or after that, it deforms permanently. The damping is proportional to velocity, which describes a body moving slowly through a fluid and not dry friction, where the force is roughly constant and the amplitude decays linearly rather than exponentially. And the spring itself is massless, which stops being true when the spring weighs a noticeable fraction of the load; the usual correction is to add a third of the spring’s mass to m.

Common mistakes

  • Using the extended length instead of the extension. In k = mg/e, e is how much longer the spring got, not how long it is.
  • Expecting a heavier mass to oscillate faster. It oscillates slower. Period goes as √m, so four times the mass doubles the period.
  • Thinking more damping always settles things sooner. Broadly true well below critical, but the quickest settling to within 2 percent comes a little under it, at ζ around 0.8, and past critical more damping only slows it.
  • Quoting the natural frequency as the resonant frequency. Fine for light damping, wrong by a measurable margin otherwise.
  • Mixing grams with newtons per metre. A mass of 500 g with k in N/m gives a period out by a factor of √1000, about 32.
  • Comparing a driven amplitude before the transient has died. The steady-state figure is what the formula predicts, and it takes a few time constants to get there.

Model and assumptions

Method
Runge-Kutta 4th order
Largest step
0.002 s
Repeatability
Deterministic. The same link gives the same numbers on any machine.

What it assumes

  • Hooke’s law is exact, so the restoring force is strictly proportional to displacement at any amplitude.
  • Displacement is measured from the equilibrium position, not from the unstretched length, which is what removes gravity from the equation.
  • Damping is viscous and linear in velocity, and the drive is a pure cosine.

Where it stops holding. A real spring stiffens or softens away from equilibrium, and dry friction does not scale with velocity.

Numerical accuracy

Estimated error
1.0e-9 m in the displacement, about 1.3e-8 of the largest value reached
How that was obtained
Running the same problem again at half the step changed the answer by at most 9.8e-10 m over 10 s, about ten cycles. Richardson extrapolation of that difference gives the figure above.
Observed order
4.00, measured from a second halving rather than assumed
Conditions
0.5 kg, 20 N/m, 80 mm release, undriven and undamped, the shipped defaults
Mass Spring Simulator: the amplitude of a driven, damped spring against driving frequency, with its highest point marked.
The amplitude of a driven, damped spring against driving frequency, with its highest point marked, computed by the simulator’s own model. Image © ScienceQuest, CC BY 4.0. Free to reuse with credit and a link to this page; how to reuse it. Download PNG

Common questions

Does gravity change the period of a vertical spring?

No. Gravity stretches the spring to a new equilibrium, by mg/k, and the oscillation then happens about that point with exactly the period T = 2π√(m/k) it would have horizontally. Substituting x = mg/k + u into the equation of motion cancels the gravity term completely. That static extension is worth measuring for its own sake, since it is how a lab finds k, and it is reported here for that reason.

What are the three damping regimes?

They are separated by the critical damping value, 2√(km). Below it the system is underdamped and oscillates with a decaying amplitude. Exactly at it the system is critically damped and returns to equilibrium as fast as possible without ever crossing it. Above it the system is overdamped and returns more slowly than critical, which is the counterintuitive part: adding damping past critical makes the return take longer, not shorter.

Is the resonant frequency the same as the natural frequency?

Only when there is no damping. The amplitude peaks at f₀√(1 − 2ζ²), which is always below the natural frequency f₀, and once the damping ratio ζ passes 1/√2, about 0.707, the response has no peak at all and simply falls away from its value at zero frequency. Quoting f₀ as the resonant frequency is a common shortcut and it is wrong for anything noticeably damped.

Why does the period not depend on how far I pull it?

Because the restoring force is proportional to the displacement. For simple harmonic motion that proportionality makes the period independent of amplitude: pull it twice as far and it moves twice as fast, covering twice the distance in the same time. That is exactly what fails for a pendulum at large angles, where the restoring force stops being proportional to the displacement.