S07 — Mass and dampers
§1.2 to §1.5 asked where the wheel is. §1.6 asks what it does: release the corner
and it swings. That needs mass, and mass turns a set of algebraic constraints into a
differential–algebraic equation. The model is otkd's examples/quarter-car: a chassis
on a vertical slide, the double-wishbone corner hung from it, a coil-over that is a
spring with no damper, and the tyre held on a road plane. This notebook asks how otkd
integrates it, how to tell the integration is right, what the energy test cannot see,
and what a damper would add.
Book page: §1.6 Mass and dampers, Walkthrough, in books/maths-applied. The
quarter-car numbers are otkd's own: the committed 3 s run the book draws, and live
runs on the same model files, cached after the first.
The question. Released from its design pose, the quarter car swings for ever. How does otkd integrate a linkage with mass so that it stays a linkage, how do you know the integration is right, and what would a damper change?
By the end you can:
- write a mechanism as , , and check that a multiplier is a force
- reduce the index to the acceleration level, solve the saddle-point system, and say why the reduced system drifts
- measure the order of RK4's energy error on the real model, and say why projection keeps the constraint at round-off
- say what an energy test cannot detect, with otkd's unrotated inertia tensor as the example
- predict a damped quarter car's modes, overshoot and settling, and say why §1.6 leaves the damper out
Assumes: M01 (order), M05 (modes), M06 (time stepping and stability), M08 §3–§4 (the KKT saddle point; the moving corner).
How to use it: predict before you reveal, commit before you check, and move the controls until the equation's behaviour stops surprising you.
Warm-up: remember
1. A linkage with mass
Setting: the problem, its sets and its symbols
Problem. Given the moving bodies , the constraint map , the mass matrix , the forces and the design pose , find and such that and for every , with and . The data are ; the unknowns are and .
| Symbol | In | Meaning |
|---|---|---|
| the moving bodies; the ground is fixed | ||
| one body | ||
| number of pose coordinates, seven per body | ||
| number of constraint rows: joint rows, the road contact, one quaternion norm per body | ||
| time and the end of the run (s); the committed run has = 3 s | ||
| the poses: per body a position (m) and a unit quaternion (dimensionless) | ||
| their first and second time derivatives (per s, per s²) | ||
| the design pose: positions zero, quaternions the identity | ||
| the constraint map (m for a length row, dimensionless for an angle or norm row) | ||
| its Jacobian | ||
| the mass matrix, symmetric (kg, kg m²) | ||
| the velocity-product term a pose-dependent brings (generalised force: N, N m) | ||
| gravity and the coil spring, as a generalised force (N, N m) | ||
| the coil's compliance, 10⁻⁵ m/N; the coil row is a force, not a constraint | ||
| the multipliers: each row's reaction (N for a length row) | ||
| wheel travel relative to the chassis (mm, positive in bump) and camber (degrees, otkd's sign) |
How these symbols connect
Each moving body in contributes seven coordinates to , and the constraint map restricts to the poses the joints, road contact and unit-quaternion norms allow. The applied forces (gravity and the compliant coil of compliance ) and the constraint reactions drive over from rest at . Because mixes metres with dimensionless quaternion entries and mixes lengths with dimensionless rows, every product pairs each multiplier's units with its row's units to give generalised forces in N and N m; from , the kinematic readouts (mm) and (degrees) report the wheel motion.
Symbol-by-symbol notes
$q(t)$ and $q_0$ — mixed-unit pose vector
Each body occupies a seven-entry slice: three translational coordinates in m followed by four dimensionless unit-quaternion components. At every translation is zero and every quaternion is the identity , so the mechanism starts in its design pose with .
$M(q)$ and $C(q, \dot q)$ — configuration-dependent inertia
Because a body's orientation changes with , its rotational block in depends on the pose. Differentiating in time produces both and the velocity-product vector , which is quadratic in and vanishes at rest ().
$\Phi$, $\Phi_q$ and $\lambda$ — constraints versus spring rows
The rows of hold only the hard joint constraints, the road contact and the quaternion norms; the coil spring is excluded from and enters through its compliance . Each multiplier has units of energy per unit of row (N for a length row in m, N m for a dimensionless angle or norm row), so always lands in generalised-force units.
$c$ — compliance, not stiffness
Compliance is the reciprocal of spring rate, measured in m/N rather than N/m. A compliance of corresponds to a coil stiffness of (100 kN/m).
$s(t)$ and $\theta_c(t)$ — sign conventions
Wheel travel is measured in mm relative to the chassis, positive into bump (the wheel moving up towards the body). Camber uses otkd's sign convention, positive when the top of the wheel leans inboard.
Start with what the book draws. otkd releases the quarter car from its design pose, at rest, with only gravity acting: the coil carries no load at that pose, so the chassis falls, the coil compresses, and the wheel travels from 0 to 212.8 mm into bump and back, once every 0.625 s (1.60 Hz). Camber goes from 0 to -9.53° (otkd's sign, and the book's: positive with the top of the wheel outboard). There is no damper, so it repeats for the whole 3 s.
The unknowns and the rows. otkd gives each of the 4 moving bodies a pose of seven numbers (a position and a unit quaternion), so has entries. The joints give 23 hard rows (the contact with the road is one of them) and the quaternions 4 norm rows: constraints . The coil is a spring row: a force, not a constraint. So the mechanism has freedom (otkd's check: mobility 1, redundancy 0), the heave of the chassis with everything else following it.
The equations. Lagrange's equations with multipliers: each constraint row exerts a force along its own gradient, with an unknown size ,
is the mass matrix, the velocity-product term a configuration-dependent brings, gravity and the coil, and the forces that keep the arms, the joints and the tyre on their rows. Differential equations for , algebraic ones for the pose: a differential–algebraic equation. Move the slider through the committed run.
At = 0.300 s: travel 211.8 mm, camber -9.450°, chassis heave -211.8 mm. With one freedom, camber is a function of travel alone, so the two curves keep step.
2. Index reduction: from to one linear solve
Setting: the problem, its sets and its symbols
Problem. Given a state with and , find such that and . Then, for a step , integrate with RK4 on these accelerations over s, with and without projection, and record the residual .
| Symbol | In | Meaning |
|---|---|---|
| the moving bodies, and one of them | ||
| pose coordinates (seven per body) and constraint rows | ||
| pose (m; quaternions dimensionless), its velocity and acceleration | ||
| the constraint map and its Jacobian | ||
| mass matrix (kg, kg m²), velocity-product term and applied force (N, N m) | ||
| , the right side at acceleration level (m/s² for a length row) | ||
| the multipliers, unknown with (N for a length row) | ||
| the saddle-point matrix, symmetric | ||
| body 's mass (kg) and its centre of mass's vertical acceleration (m/s²) | ||
| the car's weight, (N) | ||
| the RK4 step (s) | ||
| , the largest residual (m for a length row, dimensionless for a norm) |
How these symbols connect
At any admissible state with and , differentiating the constraints twice yields and stacks with the equations of motion into the linear system . Solving for supplies the acceleration field that RK4 integrates at step size , while simultaneously returns the reactions checked against the vertical force balance . Monitoring along the unprojected and projected runs tests how closely the numerical trajectory stays on .
Symbol-by-symbol notes
$\gamma(q, \dot q)$ — acceleration-level right-hand side
Differentiating once more in time gives , so is quadratic in and vanishes at rest. Its units match (m/s² on a length row, s on a dimensionless row).
$K$ — the saddle-point matrix
Assembled as the block matrix , is symmetric and indefinite because its lower-right block is zero. It is nonsingular whenever has full row rank and is positive definite on the tangent space .
$W$, $m\lt em>b$ and $a\lt /em>{b,z}$ — independent force-balance check
Here is the total weight of all moving bodies (positive in N) and is the vertical component of body 's centre-of-mass acceleration computed from . Summing uses only Newton's second law for the whole car, providing an external check on the road-contact multiplier.
$r(t)$ — max-norm constraint residual
Defined as , the infinity norm combines length rows (m) and dimensionless angle or quaternion-norm rows into one non-negative scalar. Comparing across s tracks how the constraint residual responds to step refinement.
$\lambda$ — sign of a reaction multiplier
Because the equations of motion carry , the sign of depends on the direction in which row increases. A negative value on a contact row means the reaction pushes against the gradient .
The DAE cannot go to an ODE solver as it stands: contains neither nor , so nothing fixes . Differentiate the constraint along the motion. Once: , the velocity must be tangent to the constraint. Twice:
Now stack it with the dynamics. At each state, and solve one symmetric saddle-point system (M08 §3's KKT shape, with in place of the Hessian):
Two differentiations gave an equation for that, with the dynamics, fixes algebraically; a third would give . The original system has index 3, the reduced one index 1, and an ODE solver can integrate with from this solve. otkd builds without a Hessian: two Jacobian evaluations, a central difference along .
The multiplier is a force. At the design pose the saddle matrix ( 55) has 28 positive and 27 negative eigenvalues, one negative per constraint (condition number 3.1e+06). At release the contact row's multiplier is λ = -139.00. Check it with nothing but Newton's second law for the whole car: the only vertical external forces are gravity and the road (the chassis slide carries no vertical force), so the road pushes up with = 139.00 N, where = 3109.8 N and is each body's centre-of-mass acceleration from the same solve. The two agree: is the contact force in newtons, negative because the row's gradient points into the road.
Along a 20 ms run of the same model: the load at the contact patch is something the motion produces, not an input. It peaks at 6684 N at the far end of the swing, 2.15 times the car's weight, and the coil at 11228 N.
source: `open_textbook.otkd.problem.dynamics.accelerations` — `solvers/otkd/src/open_textbook/otkd/problem/dynamics.py:259`
def accelerations(
problem: Problem,
q: np.ndarray,
qdot: np.ndarray,
*,
loads: list[tuple[str, str, np.ndarray]] | None = None,
gravity: np.ndarray | None = None,
theta: np.ndarray | None = None,
) -> Accelerations:
"""Solve the saddle-point system for the acceleration and every reaction."""
g = problem.numbers()
theta = problem.theta0() if theta is None else theta
rows = [i for i, row in enumerate(problem.rows) if row.group != SPRING]
mass = mass_matrix(problem, q, g)
force = forces(problem, q, qdot, g, theta, loads, gravity)
force = force - velocity_products(problem, q, qdot, g)
constraint, gamma = acceleration_terms(problem, q, qdot, g, theta)
size = problem.n + len(rows)
system = np.zeros((size, size))
system[: problem.n, : problem.n] = mass
system[: problem.n, problem.n :] = constraint.T
system[problem.n :, : problem.n] = constraint
rhs = np.concatenate([force, gamma])
try:
solution = np.linalg.solve(system, rhs)
except np.linalg.LinAlgError:
solution, *_ = np.linalg.lstsq(system, rhs, rcond=None)
multipliers = solution[problem.n :]
reactions = {problem.rows[index].name: float(value) for index, value in zip(rows, multipliers)}
return Accelerations(qddot=solution[: problem.n], reactions=reactions, force=force)
source: `open_textbook.otkd.problem.dynamics.acceleration_terms` — `solvers/otkd/src/open_textbook/otkd/problem/dynamics.py:245`
def acceleration_terms(problem: Problem, q: np.ndarray, qdot: np.ndarray, g: np.ndarray, theta: np.ndarray):
"""`Φ_q` and `γ`, the two pieces of the acceleration-level constraint."""
rows = [i for i, row in enumerate(problem.rows) if row.group != SPRING]
jac = problem.jacobian(q, g, theta)[rows]
speed = float(np.linalg.norm(qdot))
if speed == 0.0:
return jac, np.zeros(len(rows))
step = 1e-6 / speed
plus = problem.jacobian(q + step * qdot, g, theta)[rows]
minus = problem.jacobian(q - step * qdot, g, theta)[rows]
gamma = -((plus - minus) / (2.0 * step)) @ qdot
return jac, gamma
Reveal result (lock in your prediction above first)
| h (ms) | largest |Φ| at 0.2 s, unprojected | ratio to the step before | observed order | projected, largest over the run | | --- | --- | --- | --- | --- | | 20 | 1.34e-06 | | | 7.7e-14 | | 10 | 8.61e-08 | 15.5 | 3.96 | 6.1e-16 | | 5 | 5.46e-09 | 15.8 | 3.98 | 7.8e-16 |
Drift. The reduced system says . Integrate that twice and : any error the integrator leaves in or is a legitimate solution of the reduced equations, so it stays and accumulates. The residual grows through the run and falls by about per halving: RK4's global error, seen through the constraint. At 20 ms it passes in 0.2 s (metres in a length row, a fraction in a quaternion norm), and nothing in the reduced system stops it growing. The projected run sits at round-off at every step (points at are exact zeros, clipped for the log axis). The cure is §3.
When index reduction and the saddle-point solve breaks
- Assumes: has full row rank and is positive on its null space, so the saddle matrix is nonsingular
- When it fails: a redundant row makes it singular and the multipliers non-unique (otkd's check faults any redundancy in a dynamics study); near a toggle it is ill-conditioned; and even when it solves, it enforces only , so drifts
- Check: the saddle matrix's inertia ( positive, negative eigenvalues) and the constraint residual along the run
3. RK4, projection, and the energy test
Setting: the problem, its sets and its symbols
Problem. Given with , , a step and a window , find the RK4 iterates , each projected by onto , and the energy drift with its observed order .
| Symbol | In | Meaning |
|---|---|---|
| the state: poses (m; quaternions dimensionless) and velocities | ||
| , with from §2's saddle-point solve | ||
| the design pose, released at rest | ||
| the step (s) | ||
| the step index | ||
| the RK4 stages | ||
| the end of the window (s) | ||
| , the states the linkage allows | ||
| otkd's projection: Gauss–Newton on , then a linear correction of | ||
| total energy (J): kinetic plus coil and gravity potential | ||
| the coil row's extension (m) and its compliance (m/N) | ||
| gravity (m/s²) and body 's centre of mass (m) | ||
| the largest energy error over the window (J) | ||
| the observed order of the energy error | ||
| RK4's amplification factor on , with |
How these symbols connect
Packing into turns §2's saddle-point solve into the first-order vector field , which RK4 advances from in steps of using four stage vectors . After each step, the projection maps the iterate back onto the constraint manifold so both positions and velocities satisfy the linkage constraints. Evaluating the total energy (in J, from kinetic energy, the coil's and , and gravity at ) across gives the peak drift , whose halving ratio defines the observed order .
Symbol-by-symbol notes
$\mathcal M$ and $P$ — constraint manifold and two-stage projection
The manifold enforces both (position level) and (velocity level). The projection restores them in order: first minimum-norm Gauss–Newton steps return to , and then one linear minimum-norm update projects onto at the corrected pose.
$E = E\lt em>k + E\lt /em>p$, $g_{\text{coil}}$ and $\mathbf g$ — energy terms and datum
Potential energy sums the coil's elastic term and the gravitational term , with pointing downwards in world coordinates. Because gravity uses the geometry file's origin as its height datum, depends on that origin, whereas differences do not.
$D(h, T)$ and $p$ — window drift and observed order
For a chosen end time , is the largest absolute energy discrepancy over all steps with . Comparing against gives the empirical order ; very short windows include only a few steps and can sit in a pre-asymptotic regime.
$R(z)$ — linear test-equation amplification factor
On the scalar linear test equation with dimensionless step , one RK4 step multiplies by the degree-4 polynomial . On an undamped linear oscillator is purely imaginary, so measures single-step amplitude change while measures phase error.
$k\lt em>1, \dots, k\lt /em>4$ — stage derivatives, not states
Each stage holds a time derivative evaluated at an intermediate state, so matches the mixed units of . Computing the four stages calls §2's saddle-point solve four times per step.
The step. Write the state as and the index-1 system as , where returns with from §2's solve. Classical RK4 takes four stages,
four saddle-point solves a step, with a local error and a global one (M01's order, M06's stepper).
The projection. After each step otkd pulls the state back: a few Gauss–Newton steps (minimum-norm least squares) on and the quaternion norms, then one linear correction of onto . A Baumgarte term (adding to the acceleration row) is the softer alternative; it trades constraint drift for tuning constants and energy drift.
The energy test. With no damper and no friction the constraints do no work, so is constant along the true motion: kinetic, plus the coil's , minus for each body. Its drift over a run is a check on the integration that needs no reference solution. A check is only as good as its order: measure it (M01).
Reveal result (lock in your prediction above first)
| h (ms) | projected drift (J) | projected order | unprojected drift (J) | unprojected order |
|---|---|---|---|---|
| 20 | 2.98e-03 | 1.38e-03 | ||
| 10 | 1.56e-04 | 4.25 | 6.22e-05 | 4.47 |
| 5 | 8.82e-06 | 4.15 | 3.09e-06 | 4.33 |
Order 4, with or without the projection. The projection moves the state by about the local error, a step, so it costs no order: both columns agree. M08 §6 measured order 5 for the energy on a linear oscillator. There RK4 is with ; the energy sees only the amplitude, and , so per step and over a run. Phase error costs nothing on a linear oscillator, because every phase has the same energy. On the quarter car the coil's motion ratio and the gravity potential vary with the pose, so the step's error has a part across the energy surface, and the energy inherits the order of the method. Move down: over the first few steps the projected run's orders are erratic and can read well above 5, the pre-asymptotic rows of M01 §3, while the unprojected run stays between 4.3 and 4.6. Over the full 0.2 s, with real motion in the window, both read between 4.1 and 4.5 and fall towards 4 as shrinks.
Which energy to divide by. = 932.6 J in otkd's report, almost all of it gravitational potential measured from , a datum set by the geometry file's origin, not by the physics. The book's 3 s run at 5 ms quotes 6.3e-08 of the starting value, that is 5.9e-05 J. Against the energy the motion actually exchanges (the peak kinetic energy, 174 J on the 20 ms run) it is 3.4e-07: still small, and now a number that would not change if the road were moved.
source: `open_textbook.otkd.problem.dynamics.integrate` — `solvers/otkd/src/open_textbook/otkd/problem/dynamics.py:369`
def integrate(
problem: Problem,
q: np.ndarray,
qdot: np.ndarray,
*,
duration: float,
steps: int,
loads: list[tuple[str, str, np.ndarray]] | None = None,
gravity: np.ndarray | None = None,
theta: np.ndarray | None = None,
) -> Trajectory:
"""Classical RK4 with projection after every step.
Projection is not an ornament: RK4 drifts off `Φ = 0` by `O(h⁴)` per step, which over a few
hundred steps is a visible violation of a rigid link. Projecting `q` onto `Φ = 0` and `q̇` onto
`Φ_q q̇ = 0` after each accepted step keeps the constraint error at roundoff and is what makes
the energy test meaningful — the alternative, a Baumgarte term, trades constraint drift for
energy drift.
"""
if steps < 2 or duration <= 0:
raise SolverError("an integration needs a positive duration and at least two steps")
g = problem.numbers()
theta = problem.theta0() if theta is None else theta
h = duration / (steps - 1)
q = np.array(q, dtype=float)
qdot = np.array(qdot, dtype=float)
def derivative(state_q, state_v):
# A linear combination of unit quaternions is not a unit quaternion, so the intermediate
# RK4 stages leave the gauge surface. Renormalising before evaluating the acceleration
# keeps every stage on it; without this the constraint reaction leaks through the radial
# direction and the energy drifts by an amount that does not shrink with the step.
stage = state_q.copy()
for body in problem.moving:
start = problem._qstart[body] + 3
norm = float(np.linalg.norm(stage[start : start + 4]))
if norm:
stage[start : start + 4] /= norm
return state_v, accelerations(problem, stage, state_v, loads=loads, gravity=gravity, theta=theta).qddot
times = np.linspace(0.0, duration, steps)
states = np.zeros((steps, problem.n))
velocities = np.zeros((steps, problem.n))
energies = np.zeros(steps)
constraints = np.zeros(steps)
rows = [i for i, row in enumerate(problem.rows) if row.group != SPRING]
for index, time in enumerate(times):
if index > 0:
k1q, k1v = derivative(q, qdot)
k2q, k2v = derivative(q + 0.5 * h * k1q, qdot + 0.5 * h * k1v)
k3q, k3v = derivative(q + 0.5 * h * k2q, qdot + 0.5 * h * k2v)
k4q, k4v = derivative(q + h * k3q, qdot + h * k3v)
q = q + (h / 6.0) * (k1q + 2.0 * k2q + 2.0 * k3q + k4q)
qdot = qdot + (h / 6.0) * (k1v + 2.0 * k2v + 2.0 * k3v + k4v)
q, qdot = _project(problem, q, qdot, g, theta)
states[index] = q
velocities[index] = qdot
energies[index] = energy(problem, q, qdot, gravity, loads)[2]
constraints[index] = float(np.max(np.abs(problem.evaluate(q, g, theta)[rows])))
return Trajectory(t=times, q=states, qdot=velocities, energy=energies, constraint=constraints)
source: `open_textbook.otkd.problem.dynamics._project` — `solvers/otkd/src/open_textbook/otkd/problem/dynamics.py:349`
def _project(problem: Problem, q: np.ndarray, qdot: np.ndarray, g: np.ndarray, theta: np.ndarray):
"""Put the state back on the manifold: `Φ(q) = 0` and `Φ_q q̇ = 0`."""
rows = [i for i, row in enumerate(problem.rows) if row.group != SPRING]
for _ in range(4):
values = problem.evaluate(q, g, theta)[rows]
if np.max(np.abs(values)) < 1e-13:
break
jac = problem.jacobian(q, g, theta)[rows]
step, *_ = np.linalg.lstsq(jac, -values, rcond=None)
q = q + step
for _ in range(2):
jac = problem.jacobian(q, g, theta)[rows]
drift = jac @ qdot
if np.max(np.abs(drift)) < 1e-13:
break
step, *_ = np.linalg.lstsq(jac, -drift, rcond=None)
qdot = qdot + step
return q, qdot
When RK4 with projection, checked by the energy breaks
- Assumes: the step resolves the fastest mode and the model is conservative
- When it fails: above on an undamped mode the energy grows; with a damper or a driven input the energy is not conserved, so its drift no longer measures the integration
- Check: halve the step: the drift should fall by about , and the constraint stay at round-off
4. What the energy test cannot see
Setting: the problem, its sets and its symbols
Problem. Given a body with mass and inertia tensor about its centre of mass in design axes, and the 20 ms run , find for each the largest gap ; and at the pose of largest travel, with , the change in when becomes .
| Symbol | In | Meaning |
|---|---|---|
| the moving bodies, and one of them | ||
| body 's unit quaternion, the identity at design | ||
| its rotation from the design orientation | ||
| the map from quaternion rates to world angular velocity | ||
| world-frame angular velocity (rad/s) | ||
| mass (kg) and inertia tensor, symmetric positive definite (kg m²) | ||
| derivatives of the centre of mass (m) and of over the body's seven pose numbers | ||
| the body's block of the mass matrix (kg, kg m²) | ||
| per body block, the missing rotation | ||
| the angle body turns from design (degrees) | ||
| the largest rotational-energy error (J) |
How these symbols connect
For each body , its unit quaternion determines both the rotation from the design orientation and the map taking quaternion rates to world-frame angular velocity . Combining , , and builds the mass-matrix block , while rotating into world axes via shifts the full mass matrix by . Across the 20 ms trajectory, comparing unrotated and rotated rotational energies yields the peak discrepancy (J) alongside the turn angle , and re-solving §2's system at rest with measures the effect on .
Symbol-by-symbol notes
$\mathsf q_b$ vs $q$ — one body's quaternion vs the full pose
Sans-serif is the four-component unit quaternion of a single body (with ), not the full -vector of poses . Its scalar component gives the total rotation angle from the design orientation.
$R(\mathsf q\lt em>b)$ and $R I\lt /em>b R^{\mathsf T}$ — rotating an inertia tensor
Because is given in body design axes, transforming it into world axes at orientation uses the congruence , which preserves symmetry and positive definiteness. At the design orientation , the two tensors coincide.
$W(\mathsf q\lt em>b)$ and $J\lt /em>\omega$ — world-frame angular velocity map
Since is expressed in world axes (rad/s), it pairs directly with the world-frame inertia tensor in . Padding with a zero block for the body's position coordinates gives .
$M_b$ and $\Delta M$ — body block vs full-system perturbation
Each is the diagonal block of for body 's seven coordinates. The correction is likewise block-diagonal across bodies and alters only the quaternion sub-block of each moving body.
$e_b$ — rotational-energy discrepancy
Measured in joules over all states of the 20 ms run, compares otkd's unrotated rotational energy against the world-frame value at the same pose and angular velocity. Evaluating both formulas on the same trajectory isolates the effect of omitting .
otkd builds each body's 7×7 block of the mass matrix as
with the derivative of the centre of mass over all seven pose numbers and
the map from quaternion rates to the world-frame angular velocity. The
rotational energy in world axes is ,
with the body's rotation from its design pose; otkd uses as given. The two
agree when , at the design orientation, and .agents/todo.md item 233 records
the gap. The question is whether it matters for the quarter car. Over the 20 ms run
the bodies turn from design by at most: chassis 0.0° (it
slides on a prismatic joint), lower arm 29.8°, upper arm
44.2°, upright 11.1°.
Reveal result (lock in your prediction above first)
lca: turns up to 29.8°, rotational energy up to 0.468 J, error up to 5.6e-15 J (1.2e-12 per cent).
| body | largest turn (°) | largest rotational energy (J) | largest error (J) |
|---|---|---|---|
| chassis | 0.0 | 0 | 0.0e+00 |
| lca | 29.8 | 0.468 | 5.6e-15 |
| uca | 44.2 | 0.316 | 1.3e-14 |
| up | 11.1 | 0.114 | 4.8e-04 |
The chassis does not turn at all. The arms turn about hinge axes fixed in the chassis, so their stays on the axis their rotation leaves alone, and the unrotated tensor is exact for them: the error is round-off. Only the upright, whose spin axis moves as it cambers and steers, sees the missing rotation: 4.8e-04 J, against a peak kinetic energy of 174 J for the whole car (2.7e-06).
Does it change the motion? At the far end of the swing, with set to zero so that only matters, solve §2's system with otkd's and again with the rotated tensor. Chassis acceleration (upwards): 11.789636 against 11.789790 m/s²; contact force 6683.148 against 6683.195 N; largest change in any acceleration 1.3e-05 of the largest. For this model item 233 is a relative effect near , below the precision of what §1.6 quotes (a period to the millisecond, camber to 0.001° out of 9.5°). It would not be for a body that tumbles, or a chassis free to roll.
source: `open_textbook.otkd.problem.dynamics.mass_matrix` — `solvers/otkd/src/open_textbook/otkd/problem/dynamics.py:100`
otkd's mass matrix: _inertia(numbers.inertia) enters unrotated.
def mass_matrix(problem: Problem, q: np.ndarray, g: np.ndarray) -> np.ndarray:
"""The 7×7 mass block per moving body, assembled into the full matrix."""
model: Model = problem.model
dynamics = model.geometry.dynamics
if dynamics is None:
raise SolverError("this model has no `dynamics:` block, so it has no mass")
matrix = np.zeros((problem.n, problem.n))
for body in problem.moving:
numbers = dynamics.bodies.get(body)
if numbers is None:
raise SolverError(f"body {body!r} has no mass, so the model has no dynamics")
block = _body_indices(problem, body)
offset = _centre_of_mass(problem, numbers)
matrix[block, block] = _body_block(offset, _inertia(numbers.inertia), float(numbers.mass), q[block])
return matrix
When the energy test as evidence breaks
- Assumes: the mass matrix, forces and energy are the physics you meant
- When it fails: a consistent error in the model (the unrotated tensor) is conserved as faithfully as the truth, so the test passes
- Check: compute one quantity independently of the code under test, here against the code's kinetic energy
5. What a damper would add
Setting: the problem, its sets and its symbols
Problem. Given masses , rates , a damper rate and a road step for , find with and ; then the eigenvalues of , the overshoot and the settling time .
| Symbol | In | Meaning |
|---|---|---|
| body and wheel masses (kg), from otkd | ||
| otkd's swing period from §1 (s) | ||
| wheel rate, (N/m) | ||
| tyre rate, the sketch's own (N/m) | ||
| damper rate (N s/m) | ||
| , the body's damping ratio on a rigid tyre (dimensionless) | ||
| body and wheel heights from rest (m) | ||
| road height (m); the step is 10 mm | ||
| mass (kg), damping (N s/m) and stiffness (N/m) matrices | ||
| first-order form with | ||
| eigenvalues of (1/s) | ||
| a mode's natural frequency (rad/s) and damping ratio | ||
| overshoot, | ||
| the time after which stays within 2% of (s) |
How these symbols connect
The sprung and unsprung masses and §1's swing period fix the mass matrix and wheel rate , while the sliders set the tyre rate and reference damping ratio (hence ) to form and . Rewriting in first-order form yields the eigenvalues of , giving each coupled mode's frequency and damping ratio . Advancing the response to the road step over s produces , summarised by its dimensionless overshoot and 2% settling time .
Symbol-by-symbol notes
$\zeta$ vs $\zeta_i$ — slider parameter vs modal damping ratio
The slider value is a dimensionless parameterisation of taken from the single-mass rigid-tyre oscillator. Once the wheel mass and tyre rate are present, each coupled mode of the matrix has its own damping ratio , which need not match .
$c$, $C$ and $K$ — symbols reused from §1–§2
In this linear sketch is a viscous damper rate in N s/m (not §1's coil compliance in m/N), is the constant damping matrix (not §1's velocity-product vector), and is the stiffness matrix (not §2's saddle-point matrix).
$y$, $A$ and $b$ — first-order state-space form
Stacking heights and velocities as gives and . Because is constant, the step response advances exactly by the matrix exponential .
$\lambda\lt em>i$ and $\omega\lt /em>i$ — complex pairs vs real eigenvalues
Eigenvalues of the real matrix come either in complex conjugate pairs (oscillatory, ) or as negative real numbers ( in ). Their units are s (rad/s for ).
$\sigma$ and $t_s$ — step-response summaries
Overshoot is dimensionless (displayed as a percentage) and measures how far the body rises past the step , with if never exceeds . The settling time is the earliest time after which holds to the end of the 4 s run.
otkd's quarter car has a rigid tyre and no damper, so it swings for ever. To see what a damper does, use M05's linear two-mass chain and add one. Body = 300 kg and wheel = 17 kg are otkd's (the arms and upright lumped at the wheel). The wheel rate = 30.3 kN/m is chosen so that, on a rigid tyre, the body's period is otkd's 0.625 s: . The tyre rate and the damper are the sketch's own; otkd has neither. With and a road height ,
The damper's force depends on the rate of compression, . Write it as , ; the eigenvalues of are the modes. With they are from (M05). With damping each pair becomes , so a mode's own damping ratio is . The slider sets , the ratio the body alone would have on a rigid tyre. The input is a 10 mm step in the road at .
Reveal result (lock in your prediction above first)
Undamped modes (200 kN/m tyre): bounce 1.49 Hz, hop 18.5 Hz. At ζ = 0.30: overshoot 53.5%, inside 2% of the step after 1.69 s.
| eigenvalue | frequency (Hz) | modal ζ |
|---|---|---|
| -2.34 ± 9.25i | 1.52 | 0.245 |
| -53.90 ± 100.74i | 18.18 | 0.472 |
The smallest overshoot on the sweep is 28.8% at ζ = 0.9, not zero: even at critical damping the body overshoots, because the road reaches it through the damper as well as the spring, and the wheel arrives with its own hop. Past the minimum the damper is stiff enough to tie body and wheel together; set ζ = 2 and the table shows what replaces the two modes: a pair bouncing on the tyre near = 4.0 Hz, whose own damping ratio falls as rises, and real (overdamped) eigenvalues. Set ζ = 0: overshoot near 100%, the undamped swing of §1.
Why §1.6 leaves the damper out. Three reasons, each about what the section can check rather than what is realistic.
- The energy test needs a conservative model. With a damper, falls by design, and the check becomes an energy balance, , with the dissipation integrated alongside the motion by a quadrature whose error now mixes with the integrator's. The clean number §3 measured is gone.
- The damper rate is a design choice the chapter has no data for. Every value of ζ gives a different transient (the sweep above), and §1.2–§1.5 contain nothing that would fix one.
- It is a model choice, not a missing feature. otkd's
forcesalready carries for every spring row, with from a joint'sdamping; no example declares one. A damped quarter car is the same topology with one more number, and a different test.
source: `open_textbook.otkd.problem.dynamics.forces` — `solvers/otkd/src/open_textbook/otkd/problem/dynamics.py:193`
Gravity, loads, and each spring row's tension plus its damping.
def forces(
problem: Problem,
q: np.ndarray,
qdot: np.ndarray,
g: np.ndarray,
theta: np.ndarray,
loads: list[tuple[str, str, np.ndarray]] | None = None,
gravity: np.ndarray | None = None,
) -> np.ndarray:
"""Gravity, applied loads, and the springs and dampers' internal forces."""
model = problem.model
dynamics = model.geometry.dynamics
if dynamics is None:
raise SolverError("this model has no `dynamics:` block, so it has no forces")
force = np.zeros(problem.n)
weight = np.asarray(dynamics.gravity if gravity is None else gravity, dtype=float)
for body in problem.moving:
numbers = dynamics.bodies.get(body)
if numbers is None:
raise SolverError(f"body {body!r} has no mass, so the model has no dynamics")
block = _body_indices(problem, body)
w, x, y, z = q[block][3:7]
jv = _point_jacobian(_centre_of_mass(problem, numbers), w, x, y, z)
force[block] += jv.T @ (numbers.mass * weight)
for body, point, applied in loads or []:
point_jac, _ = problem.point_derivatives(body, point)
force += np.asarray(point_jac(*q, *g), dtype=float).reshape(3, problem.n).T @ np.asarray(applied)
point_jac = None
values = problem.evaluate(q, g, theta)
jac = problem.jacobian(q, g, theta)
for index, row in enumerate(problem.rows):
if row.group != SPRING:
continue
joint, component = row.name.split(".", 1)
compliance = problem.compliance(g).get((joint, component), 0.0)
gradient = jac[index]
tension = values[index] / compliance if compliance else 0.0
damping = _damping(model, joint, component)
force -= (tension + damping * float(gradient @ qdot)) * gradient
return force
When one damping ratio per mode breaks
- Assumes: the modes are well separated, so each keeps its own frequency and damping
- When it fails: a heavy damper couples body and wheel; the modes merge into a body-on-tyre mode whose damping falls as the damper stiffens
- Check: the eigenvalues of the first-order system, with modal damping per mode
Practice
Hint 1
The damping ratio of one mass on a spring and damper is .
Hint 2
, so .
Mixed practice: which method, and why?
Check yourself (closed book)
Keep these:
- A linkage with mass is , : a DAE of index 3, and each multiplier is a force you can check with Newton's law.
- Differentiate the constraint twice and solve one saddle-point system per stage; the reduced system holds only , so it drifts at the method's order.
- Project after each step: the constraint returns to round-off and RK4 keeps order 4.
- On a nonlinear model RK4's energy error is order 4, not the linear sketch's 5; divide it by an energy the motion exchanges, not by a datum-dependent .
- The energy test verifies the integration of the model you wrote, so a consistent error such as an unrotated tensor passes it; for the quarter car that error is tiny.
- A damper moves each mode's eigenvalue to the left, but a stiff one locks body to wheel: overshoot has a minimum near critical, and the energy test is lost.
Your connection
Name a simulation you trust because it conserves something. Which error would that conserved quantity be blind to?
Answers
Practice A. from a ratio of about 19: order 4 in the step.
Practice B. N s/m.
Practice C. , about 11.3 m/s² upwards.
Mixed practice. static equilibrium; time stepping with projection; Monte Carlo.
Where the maths is derived
Optional. These notes give the intuition and application; the sources below give the full derivations and proofs.
§2 Index reduction and the saddle-point solve
- Hairer and Wanner (1996), Solving Ordinary Differential Equations II: the index of a differential-algebraic system, constrained mechanical systems, index reduction and the drift it causes, and projection back onto the constraints.
- Benzi, Golub and Liesen (2005), Numerical solution of saddle point problems: the block system for the acceleration and the multipliers: when it is nonsingular, and its inertia.
§3 RK4, projection and the energy test
- Hairer, Lubich and Wanner (2006), Geometric Numerical Integration: projection methods, first integrals, and why a non-symplectic method's energy error grows with time.
§4 What the energy test cannot see
- otkd, the model, its exports and a generated solver: the mass matrix, the velocity-product term and the integrator (
docs/dynamics.md).
§5 What a damper would add
- Milliken and Milliken (1995), Race Car Vehicle Dynamics: ride frequencies, wheel rates and dampers from the vehicle engineer's side; further reading.
Compiled from notebooks/suspension/s07_mass_and_dampers.py — run locally with cd notebooks && uv run marimo edit suspension/s07_mass_and_dampers.py for live Python scratch cells.
Back to the book: 1.6 Mass and dampers · Chapter 1 Review