0
$\begingroup$

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

G = 9.8
MU = 0.3

TIME_STEP = [0.1, 0.01, 0.001]
SIM_TIME = 10 # s

fig, ax = plt.subplots()

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:
        speed += -np.sign(speed)*G*MU*time_step
        s.append(speed)

    ax.plot(t, s, label = "Time step {:1.3f} s".format(time_step))

ax.set_xlabel('Time (s)')
ax.set_ylabel('Speed (m/s)')
ax.legend(loc='upper right')

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.

Simulation Picture 1 Simulation Picture 2

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?

EDIT

The equations for the given system are:

$v_{0}=10$

$\dot{v}=-\frac{v}{\left | v \right |}\cdot g\cdot \mu $

$\endgroup$
  • 1
    $\begingroup$ Can you write down the equations for your system? $\endgroup$ – nicoguaro Jul 30 '19 at 18:45
  • $\begingroup$ What is the problem with taking a small timestep? $\endgroup$ – nicoguaro Jul 30 '19 at 22:30
  • $\begingroup$ In the real system, time step must be the same as the embedded system controller time step (0.02 s), hence there is a time step limitation. But this make the system unstable in some cases due those oscillations. $\endgroup$ – Guille Sanchez Jul 31 '19 at 6:39
  • $\begingroup$ An approach is to solve for the instant of discontinuity as the same time as the system evolution, then to use another set of equations after the discontinuity, for instance scipy.integrate.solve_ivp has an event option to do this $\endgroup$ – xdze2 Jul 31 '19 at 9:13
  • $\begingroup$ Those details turn the question into a different problem, I would add them as context. $\endgroup$ – nicoguaro Jul 31 '19 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.