This works for conservative systems, but what happens when we want to simulate a block sliding to a halt due to friction? The standard action functional doesn’t work, because the friction force is non-conservative.
Traditionally, D’Alembert’s Principle is a generalization of the least action that allows any force, including non-conservative forces like friction. The idea is to add “virtual work” done from any additional force. So,
(∫0T(K(q,q˙)−V(q))dt)∘=virtual work fromany additionalforces∫0T⟨fnc(q,q˙)∣q˚⟩dt⟹dtd∂q˙∂K−∂q∂K=−∂q∂V+fnc
Definition (Rayleigh Dissipation Function)
Can’t dissipative forces be written as a derivative of some function? In 1873 Rayleigh observed the following: Suppose we have some “linear viscous”1 force.
This linear damping is actually the variation of some (quadratic) function:
Bq˙=∂q˙∂R(q˙)
where
R(q˙)=21q˙⊤Bq˙
is called the Rayleigh Dissipation Function. B here is a constant number (or matrix). The thicker the fluid, the “larger” B. Indeed, the force depends on the velocity q˙. Here we defined R via the power rule.
Rayleigh’s Euler-Lagrange Equation
We can derive the equations of motion for a system with Rayleigh dissipation by modifying the least action principle. Given kinetic energy K(q,q˙), potential energy V(q), and a dissipation functionR(q,q˙), we have
with respect to velocity. This construction accurately reflects reality if the mapping q˙↦R(q,q˙) satsifies the following properties:
The mapping must be convex (second derivative is nonnegative). As velocity increases, the dissipative force must reliably increase or remain constant.
It must be zero at q˙=0. The dissipative force only acts when there is some velocity.
It must be nonnegative otherwise. This ensures adherence to the second law of thermodynamics. The dissipative force should always be doing negative work, so the system should be losing energy.
Related Works
Helmholtz’s minimal dissipation principle
Originally, Rayleigh only considered quadratic R.
After 1970’s (Moreau) discovered that other non-quadratic R can recover nonlinear forces like Coulomb friction and plasticity.
There is a natural time discretization (Kane, Marsden, Ortiz, West 1999).
If K and R are quadratic (highest order of the variable in exactly 2) in q˙, then
∂q˙∂Kq˙=2Kand∂q˙∂Rq˙=2R
such that
dtd(K+V)=−2R
To design dissipation, just model the rate of energy dissipation.
Interlude (Equations of Motion for Discrete Time Dissipation)
Let’s try dropping the continuous time derivative and model the discrete time energy loss. For simplicity, assume K(q,q˙)=21q˙⊤Mq˙. The equation of motion is
Mq¨=−∂q∂V−∂q˙∂R
Suppose the space of positions is given by Q=Rm where each point has coordinate q=(q1,…,qm)⊤. Suppose the inertia is independent of position q and
KineticEnergy(q˙)=21q˙⊤Mq˙
and the potential energy is U=U(q1,…,qm). Then the equation of motion is
(Mq¨)i=−(dU)i=−∂qi∂U
Symplectic & Backward Euler with Dissipation
We can discretize time t(n)=nΔt. Denote the state at the n−th step as q(n). We can approximate the second time derivative as
(q¨)(n)≈Δt21(q(n−1)−2q(n)+q(n+1))
Given q(n−1),q(n), solve for q(n+1). We use the Euler method.
Symplectic (explicit):
Δt21(q(n−1)−2q(n)+q(n+1))=−M−1(dU)∣q(n)
Backward (implicit):
Δt21(q(n−1)−2q(n)+q(n+1))=−M−1(dU)∣q(n+1)
Example 1: Damped Harmonic Oscillator
We can try to simulate a damped spring. Recall the equations of motion for a spring and its solved form:
{q¨+ω2q=0q(t)=acos(ωt)+bsin(ωt)
From interlude, M−1dU∣q=ω2q. The symplectic form is
The determinant of the square matrix is 1, so the symplectic form is volume-preserving (area). Both eigenvalue norms are 1 when Δt2ω2<4 (conditional stability).
The determinant of the square matrix is <1 and so the area shrinks. All eigenvalue norms are <1 for all Δt2ω2 (unconditional stability).
Minimal Incremental Potential Principle
We can exploit the unconditional stability of the backward Euler method to design a variational principle for discrete time dissipation. Recall the backward Euler method:
Δt21(q(n−1)−2q(n)+q(n+1))=−(dU)∣q(n+1)
Let’s rearrange with qpred:=2q(n)−q(n−1).
Δt21(q(n+1)−qpred)+(dU)∣q(n+1)=0
This is actually an optimality condition for the following optimization problem:
q(n+1)=q∈Rmargmin(2Δt21∥q−qpred∥M2+U(q))
Sneakily, pred stands for “predicted position”.
source code
In terms of velocity, we can write
vnewvold=Δt1(q(n+1)−q(n))=Δt1(q(n)−q(n−1))
with the following visualization:
source code
So, the physical system will decide its new velocity by
vnew=v∈Rmargmin(21∥v−vold∥M2+U(q(n)+Δtv))
This equation is called the minimal incremental potential principle. In particular, the terms compete with one another:
The intertia term. It encourages the new velocity to be close to the old velocity. So any deviation from vold is penalized, scaled by the mass matrix M.
The potential term. The object is drawn toward lower energy states like falling under gravity or a spring returning to its rest position.
The true physical path is simply the exact velocity vector that minimizes the sum of these two penalties. Indeed, this means calculating the velocity for every time step requires a good numerical optimizer.
For collision and contact, we can add “smooth barrier” functions in potential and perform optimization properly.
The third term also competes with the first two terms. It is the dissipation penalty. The object wants to minimize the energy it bleeds out into the environment (i.e. heat from friction). Because R is zero when velocity is zero, this term effectively pulls the optimal velocity closer to zero.
Writing the system in F=ma,
MΔtvnew−vold=−∂q∂U−∂v∂R
Places to use a quadratic dissipation function
Car’s shock absorber. It is a piston pushing through oil (or a viscous fluid). It restructs motion proportional to velocity.
Lubricated sliding. Two metal plates separated by a thin layer of oil. It creates a smooth, linear drag force.
Quasi-Static System
To study a dissipative system, we often consdier a quasi-static regime, where inertia is negligible. In this case, the system is in balance with potential force and external force at all times. So,
For quadratic R, this determines a “terminal velocity” that the system will eventually reach.
Intuition
We can think of dragging a heavy block through thick mud (or an extremely viscous fluid). The block never really accelerates nor does it carry momentum. It’s speed is dictated by how hard it is pulled against the mud’s resistance. When the block is no longer being pulled, it stops.
This is as if the mass M approaches zero (because we basically have zero momentum). This is why it is “quasi-static”, because it’s kind of still (static) but not quite (quasi).
Importantly, the crossed out penalty term vanishes.
Traditionally, for solving a general force, we solve some kind of relation between f,q,v. Here, fext is an ireversible force that is not a function of q.
Dry Friction
source code
We have some laws of friction:
Amonton’s 1st law: friction force is proportional to the normal force
Amonton’s 2nd law: friction force is independent of the contact area
Coulomb’s law: Once the motion starts, the friction force is independent of velocity.
source code
The force fc at contact lies in a friction cone (in the dual space at contact, or the tangent cone).
At each point of contact, we have an outward normal (covector) n.
The relative velocity between contact should satisfy ⟨n∣v⟩≥0.
The normal (f⊥) and tangent part (f∣∣) of the contact force, and tangent velocity (v∣∣) should satisfy the following relations:
∣f∣∣∣≤μf⊥∣f∣∣∣<μf⊥⟺v∣∣=0
where μ is the coefficient of friction. In the image above, μ dictates the width of the friction cone.
When the tangent velocity is nonzero, the tangent force is in the same direction with it αf∣∣=♭R3v,α≥0
From physics, these two relations are merely:
Static Friction (stuck): If the required tangential force (the force pushing the object to the right) is strictly less than the boundary of the cone, the object is perfectly stuck and thus has zero tangential velocity.
Kinetic Friction (sliding): If the external push exceeds the cone’s edge, the friction force maxes out at the cone boundary ∣f∣∣∣=μ∣f⊥∣. The object begins to slide and the friction force points in the exact opposite direction of the motion.
Classical Approach for Contact
Suppose we want to model how a rigid body comes into contact with a wall or some other object. We first establish a set of points pi that will be in contact. Then
source code
This is computationally miserable. When a 3D object hits the floor, we have to keep track of the object’s state (c,R)∈Q and the contact space where the objects touch (p1,…,pk)∈R3×⋯×R3. To know if an object is sliding or stuck, we need to view the object’s linear and angular velocity (c˙,R˙) and map that to 3D velocities at every single contact point (p˙1,…,p˙k).
This translation is done via the Jacobian denoted by dϕ. Conversely, the floor pushes back on those chair legs by friction and normal forces (f1,…,fk). To know how those forces affect the chair’s motion, we need to map the net force and net torque back to the cneter of pass. This is done via the dual (tranpose, since R3) of the Jacobian, denoted by dϕ∗.
We then need to solve for velocity and contact forces so that all conditions are satisfied. Because the body is rigid, all the particles are connected.
The friction force at point p1 depends on its velocity.
But its velocity depends on the total rotation of the chair.
The total rotation of the chair depends on the forces pushing up on points p2,p3,p4.
Obviously, we cannot calculate them all in closed form. This is called the Linear Complementarity Problem (LCP). The solver would have to guess if each point is stuck, sliding, or lifting off the ground.
Dissipation Function for Dry Friction
We can take a variational approach to dry friction.
MΔtvnew−voldR(v)=−∂q∂U−∂v∂R=μ∣v∣
Newmark Algorithm
We initally chose the Backward Euler method for its simplicity and unconditional stability. However, it is only “first order” accurate, meaning it introduces a lot of numerical error over time.
The acceleration at current time can be read off from
a(n)=M−1∂q(n)∂U~(n)(q(n))
Velocity can be kept track of by
v(n)=v(n−1)+Δt((1−γ)a(n−1)+γa(n))
γ is a parameter that controls how much we trust the current acceleration a(n) vs the previous acceleration a(n−1). The prediction of the next time step
qpred(n+1):=q(n)+Δtv(n)+2Δt2(1−2β)a(n)
If we ignore the β parameter for a moment, this prediction is actually the classic kinematic equation from basic physiscs, x=x0+v+21at2. We are basically predicting the next position using the current velocity and current acceleration.
We then solve an optimization problem like before,
q(n+1)=q∈Rmargmin(2Δt21∥q−qpred∥M2+βU~(n)(q))
This is the Newmark algorithm.
Numerical Optimization for Contact
Since we have a variational formulation for contact and have shown that is simply an optimization problem, we can solve for contact forces and velocities using numerical optimization. This is a more direct approach than the classical LCP formulation.
Using the smooth barrier and dissipation function, every time step is actually one unconstrained optimization problem
Note that the initial guess (from the state of the previous time frame) for optimization is usually very close to the optimizer. We can use gradient descent using some metric ♭=H.
Now, we just need to choose a good H and a step size α>0.
Classic gradient descent uses H=I and a small step size α. This is very stable but can be slow to converge.
Newton’s method uses H=Hessian(L).
Quasi-Newton methods use an approximation of the Hessian.
Use line search for choosing α.
Footnotes
Imagine running your hand through water. As you move faster, the force pushing back on your hand gets stronger. The same principle is true for air resistance and friction between surfaces. ↩