Skip to content

Instantly share code, notes, and snippets.

@Foadsf
Last active August 9, 2017 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Foadsf/a106ec3658df3c1537ff3c2858d50ba6 to your computer and use it in GitHub Desktop.
Save Foadsf/a106ec3658df3c1537ff3c2858d50ba6 to your computer and use it in GitHub Desktop.
modeling multi-body Coulomb static friction in Modelica language
model multibody_Coulomb_static_friction
//constants
parameter Real muk=1.0;
parameter Real mus=1.3;
parameter Real m1=1.0;
parameter Real m2=2.0;
parameter Real m3=3.0;
parameter Real Fn12=1.0;
parameter Real Fn23=2.0;
/*
to solve the warning:
Translation Warning [multibody_Coulomb_static_friction: 43:3-47:9]: In component , in relation V1 == V2, == on Real numbers is only allowed inside functions.
based on this post: https://openmodelica.org/forum/default-topic/2263-openmodelica-translation-warning
*/
parameter Real absTol = 1e-10;
//variables
Real X1, X2, X3, V1, V2, V3, A1, A2, A3, F1, F2, F3, Ff12, Ff23;
initial equation
X1=0;
X2=0;
X3=0;
V1=0;
V2=0;
V3=-1;
equation
F1=sin(5*time);
F2=2*sin(7*time);
F3=3*sin(11*time);
V1=der(X1);
V2=der(X2);
V3=der(X3);
A1=der(V1);
A2=der(V2);
A3=der(V3);
m1*A1=F1-Ff12;
m2*A2=F2+Ff12-Ff23;
m3*A3=F3+Ff23;
if (abs(V1 - V2) < absTol) and (abs(m1*A1-F1)<mus*Fn12) and (abs(m2*A2-F2+Ff23)<mus*Fn12) then
A1=A2;
else
Ff12=muk*Fn12*sign(V1-V2);
end if;
if (abs(V3 - V2) < absTol) and (abs(m3*A3-F3)<mus*Fn23) and (abs(m2*A2-F2-Ff12)<mus*Fn23) then
A3=A2;
else
Ff23=muk*Fn23*sign(V2-V3);
end if;
end multibody_Coulomb_static_friction;
@tbeu
Copy link

tbeu commented Aug 9, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment