I'm trying to simulate a 1D model of two bodies sliding on each other with a Coulomb friction in between.
As I have explained here I modeled the friction as :
- The force required to keep two bodies adhered $F_{a12}=\frac{m_2F_1-m_1F_2}{m_1+m_2}$
- kinetic friction force $F_{f_k12}=Sign\left(v_1-v_2\right)\mu_k F_{n12}$
- maximum static friction $F_{f_s12}=\mu_s F_{n12} $
- $F_{f12}=\left\{\begin{matrix} if \, v_1=v_2 \, and \, \left| F_{a12} \right|<F_{f_s12} \,\, then & F_{a12} \\ else & F_{f_k12} \end{matrix}\right.$
Considering the values as $\mu_s=0.3$, $\mu_k=0.2$, $F_{n12}=3$, $m_1=1$, $m_2=2$, $F_1=2\sin(5t)$, $F_2=2\sin(7t)$ I implemented the model in modelica language as:
model friction
//constants
parameter Real muk = 0.2;
parameter Real mus = 0.3;
parameter Real m1 = 1.0;
parameter Real m2 = 2.0;
parameter Real Fn12 = 3.0;
parameter Real absTol = 0.1;
//variables
Real X1, X2, V1, V2, A1, A2, F1, F2, Ff12, Fs12;
initial equation
X1 = 0;
X2 = 0;
V1 = 0;
V2 = 0;
equation
F1 = 2*sin(5 * time);
F2 = 2*sin(7 * time);
V1 = der(X1);
V2 = der(X2);
A1 = der(V1);
A2 = der(V2);
m1 * A1 = F1 - Ff12;
m2 * A2 = F2 + Ff12;
Fs12=(m2*F1-m1*F2)/(m1+m2);
if abs(V1 - V2) < absTol and abs(Fs12) < mus * Fn12 then
Ff12=Fs12;
else
Ff12 = muk * Fn12 * sign(V1 - V2);
end if;
end friction;
and this is the result for $x_1$ and $x_2$:
and I modeled the exact same thing in SIMULINK (download the .slx model here) and there is a completely different result:
Why am I getting two completely different results?! Am I doing a mistake in implementation or the difference is due to the different solvers these two programs use? Which one should I trust in that case?!
P.S. I just realized that there is something wrong with Wolfram SystemModeler solver. When I do the simulation in OponModelica the result is more similar.