# ODE events to switch between 5 equations (friction model)

I am modelling a 1 dof spring-mass-damper system with friction. As first attempt I modelled the friction according to the simple Coulomb model (figure A here http://article.sapub.org/image/10.5923.j.mechanics.20130301.04_006.gif) and it worked fine. Now I want to add the effect of the static friction when v = 0 m/s (figure C http://article.sapub.org/image/10.5923.j.mechanics.20130301.04_006.gif), but I cannot make it work. In fact I would expect to obtain something similar to the first model, but it is not so.

The equations I modelled are:

for the slipping case ($\dot{x}$ different from 0)

$m\ddot{x} + c\dot{x} + kx = -m\ddot{y} - \mu_{d} N$ if $\dot{x} > 0$

$m\ddot{x} + c\dot{x} + kx = -m\ddot{y} + \mu_{d} N$ if $\dot{x} < 0$

for the sticking case ($\dot{x} = 0$) I have 3 equations:

$m\ddot{x} + c\dot{x} + kx = - m\ddot{y} + kx$ if $|kx+m\ddot{y}| < \mu_{s} N$

If $|kx+m\ddot{y}| > \mu_{s} N$ then the equations are

$m\ddot{x} + c\dot{x} + kx = -m\ddot{y} -\mu_{s} N$ if $kx+m\ddot{y} > 0$

$m\ddot{x} + c\dot{x} + kx = -m\ddot{y} +\mu_{s} N$ if $kx+m\ddot{y} < 0$

where $N$ is the normal force and $-m\ddot{y}$ represents the logarithmic sweep base excitation given as $\ddot{y} = A*\sin{(\phi(t))}$.

So, the starting equation is chosen as follows

% Initial conditions
q0 = [0;0];

% Choose starting equation
if q0(2) ~= 0
flag1 = 0;
else
flag1 = 1;
end


Then, to switch from one equation to the other set I need events:

function [value,isterminal,direction] = events(t,q)
value = [q(2),q(2),...]; % Find the times when velocity changes sign
isterminal = [1,1,1]; % Stop the integration when the event functions
% are satisfied
direction = [1,-1,0];
end


The first 2 terms in the value look for changes in the velocity direction, but now I need to tell Matlab to choose between one of the 3 equations of the case $\dot{x} = 0$. The third condition I would add is

abs(k*q(1)+m*A*sin(2*pi*(60*f0/(R*log(2.))*(2.^(R/60*t)-1))))-mus*N


But then if I try to add the condition for the 2 remaining equations I get an error on input matrix dimension here

[t,q,te,qe,ie] = ode45(odefun,tspan,q0(:,1),options);

• I am no expert, and did not look at your links, but are you sure of your equations? Commonly $\tanh$ is used to regularize an "if-then" statement (e.g. see here). And something similar appears to be a standard approach for friction (e.g. see here). Oct 30 '15 at 17:58
• The use of the tanh is to avoid to write an equation for positive and one for negative dynamic friction force. But if I leave it as it is I have that at zero velocity I have zero friction force since tanh(0) =0 and it is not my case since I want to represent stiction
– Rhei
Oct 30 '15 at 18:14