00.10.20.3m1a = (F - k*x - b*v) / m2v = v + a*dt3x = x + v*dtoilm = 2 kg
01234560.00.10.20.3time (s)x (m)CART POSITION x(t)b = 4b = 20F/k = 0.2 mpeak 0.305 m
Blocks: the wall, the damper (oil cylinder), the cart and the ruler; the spring is the zigzagArrows on the cart: the forces on it, drawn to scale (push F, spring kx, damper bẋ)Plot: the cart's position x(t), the exact solution of the equation of motionCode card: the equation of motion as three lines of PythonA 2 kg cart tied to a wall by a spring and a damper, pushed by a steady 10 N force. Newton's second law on the free-body diagram gives m·ẍ + b·ẋ + k·x = F(t); the plot below is that equation's solution. The model is ideal: a massless linear spring, a viscous damper whose force is exactly proportional to speed, and no friction from the table. Real parts only follow these laws over a limited range; the model is useful because it is simple and close enough.

The parts

  1. A 2 kg cart rolls on a smooth table. A spring and a damper tie it to a wall. A damper is a piston in oil, like a door closer: it resists motion. We want an equation that predicts where the cart goes.

The equation

Solving it

What is happening

# step 1/12 · setup
# about: Cart m = 2 kg, Wall (fixed), Spring k = 50 N/m, Damper b

mass     m = 2 kg      (the cart)
spring   k = 50 N/m     (how stiff)
damper   b = 4 N·s/m    (how much it resists speed)

Goal: an equation for x(t), the cart's
position over time. Its solution is
what the cart will do.

The cart, spring and damper are illustrative values (m = 2 kg, k = 50 N/m, b = 4 or 20 N·s/m, F = 10 N), chosen so ωn = 5 rad/s and ζ = 0.2 exactly. The frozen moment used to explain each force (x = 0.1 m, ẋ = 0.5 m/s) is an example state; every curve and every number while the equation runs is the exact solution of the equation of motion for these values. The Python steps the equation forward 1 ms at a time (semi-implicit Euler). It reaches the same peak, 0.305 m, as the exact solution drawn in the plot.