# Friction simulation in case of body moving with constant velocity and no external force

I am trying to write a simple physics simulation but have troubles with how friction works.

Let's assume a body of mass $m$ is moving horizontally on a plane with initial velocity $v_0$. Can someone please explain me how friction works in this case?

Is there a constant friction force opposite to the direction of motion which suddenly becomes zero when the body velocity becomes zero? In a simulation it would never become exactly zero and thus the body position would oscillate. Would it be reasonable to blend kinematic friction over into static friction at low velocities? How does this work in reality?

This is a tough question to solve in general, but I've seen the following type of approach taken with a few explicit timestepping "contact algorithms" between two bodies in the finite-element type literature if there does not need to be a distinction between the static and dynamic coefficients of friction.

It can be viewed as a way to do what has been mentioned by DilithiumMatrix and David Hammen.

First, we project momentum $p$ forward for each body as if there was no friction, so

$p^{*} = p^{n} + \Delta t f^n$.

If there is no-slip contact, that means at the end of the step the body is moving with the velocity of the combined center of mass (in this case, I assume the ground is not going to move due to the body, so we can just use 0). We then know

$p^{n+1} = p^{*} + \Delta t f^n_c$.

Therefore, the required force on the body for no-slip contact is $f_c = \frac{-p^*}{\Delta t}$ since $p^{n+1} = 0$.

Now, I assume you know the normal force (e.g. due to the weight of the body), in which case you can see if $|\mu f^n_{normal}| > |f_c|$, in which case the object must come to a stop. Otherwise, you calculate the contact force as

$f_{contact} = -\mathrm{sign}(p^n) \mu f_{normal}$

And the final momentum is given by $p^{n+1} = p^* + \Delta t f_{contact}$. Or, altogether

$p^{n+1} = \begin{cases} 0 & \text{ if } |\mu f_{normal}| \ge |\frac{-p^{n}}{\Delta t} - f^n| \\ p^{n} + \Delta t (f^n -\mathrm{sign}(p^n) \mu f_{normal}) & \text{otherwise}\end{cases}$.

Please note that I left it in 1D and this only accounts for the tangential motion. You might be able to set the thresholds for $\mu$ where it shows up as two different values, to get the static and dynamic coefficients of friction but I have not tried that. E.g. since the static friction coefficient is greater than the dynamic one I believe

$p^{n+1} = \begin{cases} 0 & \text{ if } |\mu_{static} f_{normal}| \ge |\frac{- p^{n}}{\Delta t} - f^n| \\ p^{n} + \Delta t (f^n -\mathrm{sign}(p^n) \mu_{dynamic} f_{normal}) & \text{otherwise}\end{cases}$

will work without overshoot but will still stop "too early" if the object was in motion but the no-slip force was between the static and dynamic thresholds.

The simplest and easiest thing to do is chose a threshhold value for the speed. If the speed drops below that value, force the speed to be zero and implement your scheme for when the body is at rest. If you're on a level surface with no horizontal force components, the friction becomes zero.

Like you mentioned, you can't depend on the simulation to get to zero perfectly, but there's nothing wrong, in the limit, with forcing the zero.

If you are just taking into account surface friction (i.e. no air resistance) then yes, the friction force will be constant, opposite to the direction of motion until the object stops moving.

When the object stops moving, static friction keeps it in place. When people refer to the "force of static friction, $F_{fs}$", that is actually a maximum static-friction force. This means that if an external force is applied $|F_e| < |F_{fs}|$, static friction will match it, and prevent acceleration. If the external force exceeds the static friction ($|F_e| > |F_{fs}|$) then the object will start accelerating with a net force ($|F_e| - |F_{fs}|$).

In a simulation the velocity, and thus the kinetic friction should actually become exactly zero at some point, because you should implement your equations such that the friction force can never create a reverse velocity (i.e. you should manually prevent oscillation). One possible implementation would be something like:

Calculate the position at which the object should stop, call that $x_s$. Because you are using some finite time-step, you will tend to eventually reach some position past this value, $x_i > x_s$. In your code, you can check for this to happen, and simply set $x_i = x_s$ and $v_i = 0.0$ instead of integrating the equations of motion, i.e. instead of $v_i = v_{i-1} + a \, \Delta t$ and $x_i = x_{i-1} + v_i \, \Delta t$ (if you were using a simple Euler integration).

Is there a constant friction force opposite to the direction of motion which suddenly becomes zero when the body velocity becomes zero? In a simulation it would never become exactly zero and thus the body position would oscillate.

In reality, there's a distinction between kinetic and static friction. Your simulation of reality needs to reflect this distinction.

Simulations typically have fixed time steps. This is problematic with regard to collisions, and also with regard to things like kinetic / static friction. You need to develop a mechanism that splits the fixed simulation time steps in your simulation into smaller parts so as to capture those apparent discontinuities. In technical terms, your simulation needs a propagator (something that advances state over time) and a solver (something that tells the propagator to slow down). The solver essentially splits the fixed time steps of the simulation into smaller parts.

The solver is quite simple in the case of the simple simulation you are trying to create. Project the velocity forward over the simulation time step just using kinetic friction. You need to solve for when the velocity reaches zero if this would result in the object changing direction. When that would happen is fairly easy assuming a simple model of kinetic friction that makes velocity change linearly with time. (It's not so easy in general. There are papers galore on how to best write a solver.) When the sliding object's velocity gets below some limit, the object stops. An external force is now needed to make the object start moving again.

• Do you know a good reference paper? – Danvil Dec 26 '16 at 23:57
• There is a truly massive review paper on contact algorithms here (I cannot vouch for its correctness, but it seems to be a good place to start if looking for a particular class of algorithms): ipmnet.ru/~burago/papers/cont-e.pdf – neocpp Dec 28 '16 at 0:38
• @Danvil -- I'd recommend a book on physics engines (or game physics) instead of a paper. There are lots of them. – David Hammen Dec 28 '16 at 21:10
• @neocpp: Thank you! That was exactly what I was looking for. – Danvil Dec 29 '16 at 2:35
• @DavidHammen That is a good idea but I would be careful about distinguishing between methods that give accurate results vs just "visually correct" ones. In my experience most of the game-related engines don't solve physical systems to a high degree of fidelity (with good reason, as high fidelity and speed are often at odds). I would hope that a book would go over this, but depending on the application OP has in mind it might be important. – neocpp Dec 29 '16 at 3:44