Qurak

Friction models

Example 17 steps, run in order in one session. Every step was executed against the engine and the output below is what it produced.

Step 1
m = l = 1.;
beltv[t_] = .1;
spring[x_] = 1000.(l - x);

No output - this step sets something up for the next one.

Step 2
sys := {m x''[t] == spring[x[t]] + friction[x'[t]], x[0] == 1, x'[0] == 0};

No output - this step sets something up for the next one.

Step 3
viscous[v_] := -30.(v - beltv[t]);
friction[v_] := viscous[v];

No output - this step sets something up for the next one.

Step 4
{pos1, vel1} = NDSolveValue[sys, {x, x'}, {t, 0, 2}];

No output - this step sets something up for the next one.

Step 5
GraphicsRow[{Plot[{pos1[t]}, {t, 0, 1}, AxesLabel -> {"t", "x"}, PlotRange -> All], Plot[{vel1[t], beltv[t]}, {t, 0, 1}, AxesLabel -> {"t", "v"}, PlotRange -> All]}, ImageSize -> 500]
Output
-Graphics-
Step 6
coulomb[v_] := -25.Sign[v - beltv[t]];
friction[v_] := viscous[v] + coulomb[v];

No output - this step sets something up for the next one.

Step 7
{pos2, vel2} = NDSolveValue[sys, {x, x'}, {t, 0, 20}];

No output - this step sets something up for the next one.

Step 8
GraphicsRow[{Plot[{pos2[t]}, {t, 0, 1}, AxesLabel -> {"t", "x"}, PlotRange -> All], Plot[{vel2[t], beltv[t]}, {t, 0, 1}, AxesLabel -> {"t", "v"}, PlotRange -> All]}, ImageSize -> 500]
Output
-Graphics-
Step 9
stribeck[v_] := -.3Sign[v]Exp[-2Abs[v]];
friction[v_] := viscous[v] + coulomb[v] + stribeck[v];

No output - this step sets something up for the next one.

Step 10
{pos3, vel3} = NDSolveValue[sys, {x, x'}, {t, 0, 20}];

No output - this step sets something up for the next one.

Step 11
GraphicsRow[{Plot[{pos3[t]}, {t, 0, 1}, AxesLabel -> {"t", "x"}, PlotRange -> All], Plot[{vel3[t], beltv[t]}, {t, 0, 1}, AxesLabel -> {"t", "v"}, PlotRange -> All]}, ImageSize -> 500]
Output
-Graphics-
Step 12
friction[v_] := viscous[v] + coulomb[v] + stribeck[v];

No output - this step sets something up for the next one.

Step 13
staticsys := {x''[t] == If[stuck[t] == 1, beltv'[t], spring[x[t]] + friction[x'[t]]], x[0] == 1, x'[0] == 0};

No output - this step sets something up for the next one.

Step 14
μ = 100;
stick = WhenEvent[x'[t] == beltv[t], stuck[t] -> Boole[spring[x[t]]^2 < μ^2]];
slip = WhenEvent[spring[x[t]]^2 > μ^2, stuck[t] -> 0];

No output - this step sets something up for the next one.

Step 15
{pos4, vel4} = NDSolveValue[{staticsys, stick, slip, stuck[0] == 0}, {x, x'}, {t, 0, 8}, DiscreteVariables -> stuck[t]];

No output - this step sets something up for the next one.

Step 16
GraphicsRow[{Plot[{pos4[t]}, {t, 0, 8}, AxesLabel -> {"t", "x"}, PlotRange -> All], Plot[{vel4[t], beltv[t]}, {t, 0, 8}, AxesLabel -> {"t", "v"}, PlotRange -> All]}, ImageSize -> 500]
Output
-Graphics-
Step 17
Plot[{pos1[t], pos2[t], pos3[t], pos4[t]}, {t, 0, 2}, AxesLabel -> {"t", "x"}, PlotRange -> {0.9, 1.1}, PlotLegends -> {"viscous", "viscous+Coulomb", "viscous+Coulomb+Stribeck", "viscous+Coulomb+Stribeck+static"}, ImageSize -> 300]
Output
-Graphics-

Functions used

Related recipes

All recipes · Function reference · Use this from an MCP client