b2KIT

Spring-Mass System Simulator

Simulate spring-mass systems with damping and driving forces. Visualize displacement, velocity, and energy over time. Explore resonance.

Tested tool guide Tested browser tools Checked August 16, 2026

What Spring-Mass System Simulator does, with a checked example

Enter mass, spring stiffness, and damping, add an optional sinusoidal driving force, and the page plots displacement, velocity, and the kinetic, potential, and total energy against time while the motion evolves. Free oscillation shows the exponential ring-down; a driving force shows the transient settling into steady motion. Most users are surprised by resonance's signature: with damping present, the largest amplitude arrives at a drive frequency slightly below the natural frequency omega0 = sqrt(k/m), while the 90-degree phase lag between displacement and force lands exactly at omega0.

Worked example

A concrete input and expected output from the current implementation.

Input

m = 1 kg, k = 4 N/m, c = 1 N*s/m, drive F = 1*cos(2t) N (omega = 2 rad/s, equal to omega0), start from rest at x = 0

Expected output

After a transient that dies out with time constant 1/(zeta*omega0) = 2 s (zeta = 0.25), the trace settles to x(t) = 0.5*sin(2t) m: amplitude 0.50 m, velocity in phase with the force, displacement lagging it by exactly 90 degrees. By t = 8 s the motion is within about 2% of that steady state.

At omega = omega0 the term k - m*omega^2 vanishes, so the steady amplitude is F0/(c*omega) = 1/(1*2) = 0.5 m and the phase lag is exactly 90 degrees. The plot shows the full solution, so the early trace also carries the decaying transient on top of this sinusoid.

How the result is produced

1

What the simulator solves

The system follows m*x'' + c*x' + k*x = F0*cos(omega*t): inertia, a damping force proportional to velocity, Hooke's-law spring force, and the optional drive. The dimensionless ratio zeta = c/(2*sqrt(k*m)) decides the free motion: zeta < 1 rings down sinusoidally, zeta = 1 returns without overshoot fastest, zeta > 1 creeps back without oscillating. Displacement, velocity, and the energy curves all come from this one solution, so they stay mutually consistent.

2

Resonance and phase lag

Driven steadily, the motion settles to a sinusoid at the drive frequency with amplitude F0/sqrt((k - m*omega^2)^2 + (c*omega)^2) and phase lag given by tan(delta) = c*omega/(k - m*omega^2). The amplitude peaks near omega0, and the peak's sharpness is set by the quality factor Q = 1/(2*zeta). Below resonance the displacement nearly tracks the force; at omega0 it lags by exactly 90 degrees; far above, it approaches 180 degrees and moves opposite the force. Sweeping the drive frequency is how the page maps this response curve.

Good uses

  • Set m, k, and c for a real object on a spring (a suspension, a door closer, a mounted sensor) and read off whether it will wobble, return cleanly, or creep back after a disturbance, and at what rate.
  • Find the danger zone for a machine running at a fixed speed: set the drive frequency to the operating rpm and compare the steady amplitude at running speed with the response near omega0, where forces are magnified roughly Q times.
  • Check a hand-computed homework solution: enter the same m, k, c, F, and initial conditions as the problem and compare the plotted x(t) and energy traces with the analytic expression term by term.

Limits and checks

  • Damping input units: if the field takes the coefficient c, its value depends on the unit system (N*s/m in SI), and it is the ratio zeta = c/(2*sqrt(k*m)) that decides under-, critical-, or overdamped. Typing a ratio such as 0.25 where a coefficient is expected gives zeta = 0.0625 for m = 1, k = 4, and the plots look entirely different.
  • The amplitude maximum sits at omega0*sqrt(1 - 2*zeta^2), below omega0 whenever damping is present. At zeta = 0.25 that is about 6.5% below omega0, so a coarse frequency sweep can step right over the peak; the 90-degree phase lag at omega0 remains the reliable marker.
  • The model is strictly linear, so with c = 0 and the drive exactly at omega0 there is no steady state and the amplitude grows without bound. That is the model's limit, not a physical prediction: real springs harden, friction is often not velocity-proportional, and something always limits the swing.

Common questions

Why does the biggest response come below the natural frequency?

Damping shifts the amplitude peak down to omega0*sqrt(1 - 2*zeta^2). For zeta = 0.25 that is sqrt(0.875), about 0.935 times omega0, roughly 6.5% lower. The velocity amplitude and the 90-degree phase lag stay pinned at omega0, and as zeta shrinks the peak slides back toward omega0, so the shift only matters at stronger damping.

Why does the total-energy trace stop falling once the drive is on?

In steady state the driving force adds exactly as much energy per cycle as damping removes, so total energy holds constant instead of decaying. You can watch the balance on the energy plot: kinetic energy peaks at each equilibrium crossing, potential energy at each turning point, and their sum settles to a flat line once the initial transient has died out.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools