When simulating a friction dynamic system, I have come to a problem when approaching steady-state.
In the example below, a box moves along a surface with a certain friction coefficient:
#!/usr/bin/env python # -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt MASS = 1 # kg G = 9.8 MU = 0.3 TIME_STEP = [0.1, 0.01, 0.001] SIM_TIME = 10 # s for time_step in TIME_STEP: t = np.linspace(0, SIM_TIME, int(SIM_TIME/time_step)) speed = 10 # m/s s = [] for i in t: Fr = -np.sign(speed)*MASS*G*MU speed += Fr*time_step s.append(speed) plt.plot(t, s)
Since the friction is only dependent on the speed unit vector, the system oscillates around the steady-state point instead of converging to 0. The oscillation vary depending on the time_step simulated, but it is there always.
The difficulty is that in the real system, the steady-state point is not known, so approaches like making the speed equal to zero when crossing the steady-state point are not applicable.
Is there a way for this to be coded in order to avoid those steady-state oscillations, and without loosing physical integrity?