Skip to content

Instantly share code, notes, and snippets.

@johanrhodin
Last active September 9, 2015 16:59
Show Gist options
  • Save johanrhodin/5ffc0c9ba71c6135489c to your computer and use it in GitHub Desktop.
Save johanrhodin/5ffc0c9ba71c6135489c to your computer and use it in GitHub Desktop.
Two different ways to model friction
// New, in https://github.com/dzimmer/ZimmersModelicaTutorial/blob/master/Tutorial2015/BaseComponents/Friction/IdealDryFriction.mo
free = false;
f0 = R;
f0_max = S;
// velocity and acceleration of flanges
v_relfric = der(-s_rel);
a_relfric = der(v_relfric);
// Friction force
-f = if locked then sa * unitForce else if startForward then R else if startBackward then -R else if pre(mode) == Forward then R else -R;
// Old, from draft
v = der(flange_a.s - flange_b.s);
flange_a.f + flange_b.f = 0;
a = der(v);
flange_a.f = if Forward then R else if Backward then -R else if StartForw then R else if StartBack then -R else fR;
Forward = initial() and v > 0 or pre(StartForw) and v > 0 or pre(Forward) and not v <= 0;
Backward = initial() and v < 0 or pre(StartBack) and v < 0 or pre(Backward) and not v >= 0;
StartForw = pre(Stiction) and fR > S or pre(StartForw) and not (v > 0 or a <= 0 and not v > 0);
StartBack = pre(Stiction) and fR < (-S) or pre(StartBack) and not (v < 0 or a >= 0 and not v < 0);
Stiction = not (Forward or Backward or StartForw or StartBack);
0 = if Stiction or initial() then One * a else fR;
when Stiction and not initial() then
reinit(v, 0);
end when;
@johanrhodin
Copy link
Author

These are Modelica equations from IdealDryFriction, part of a Modelica tutorial that will be given at the Modelica conference.

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