# Pendulum, pulleys and friction

Considering the following physical situation: and writing the following code:

μs := 0.50
μk := 0.20

g := 9.81
M := 2.00
m := 0.30
L1 := 6.00
L2 := 1.00

xi := 0.00
vi1 := 0.50
Θi := 80.00 Pi/180
vi2 := 0.00

tmax := 10

T[t_] := Max[0, m g Cos[Θ[t]] + m (L2 + x[t]) Θ'[t]^2]

sol = NDSolve[{

If[stop[t] == 1 || stuck[t] == 1, 0, Evaluate[-μk m g + T[t]]] == M x''[t],
-m g Sin[Θ[t]] == m (L2 + x[t]) Θ''[t],

stop == If[L1 == 0, 1, 0],
stuck == If[vi2 == 0, Boole[μs M g >= T], 0],
x == xi,
x' == vi1,
Θ == Θi,
Θ' == vi2/L2,

WhenEvent[x[t] == L1, {stop[t] -> 1, x'[t] -> 0}],
WhenEvent[x'[t] == 0, Evaluate[stuck[t] -> Boole[μs M g >= T[t]]]],
WhenEvent[Evaluate[μs M g < T[t]], stuck[t] -> 0]

}, {Θ, x}, {t, tmax},

DiscreteVariables -> {stop, stuck}];

Plot[Evaluate[{x[t], Θ[t], T[t]} /. sol],{t, 0, tmax},
AxesLabel -> {"t", "fct[t]"},
PlotLegends -> {"x", "Θ", "T"},
PlotRange -> All]


you get: which is finally what you want! ^.*

There is just a suitable example of static friction in NDSolve documentation. The trick is to use stuck[t] function as an indicator of whether the block is under the effect of friction or not. Here is the solution:

NDSolve[{-P2 Sin[\[CapitalTheta][t]] ==
m (L + x[t]) \[CapitalTheta]''[t],
x''[t] ==
If[stuck[t] == 1, 0.0, Evaluate[(-Fk + T[t])/M]], \[CapitalTheta][
0] == \[CapitalTheta]i, \[CapitalTheta]' == vi1/L, x == xi,
x' == vi2, stuck == 0,
WhenEvent[x'[t] == 0,
Evaluate[stuck[t] -> Boole[Fs >= Abs[T[t]]]]],
WhenEvent[Evaluate[Fs < Abs[T[t]]],
stuck[t] -> 0]}, {\[CapitalTheta], x, x'}, {t, tmax},
DiscreteVariables -> stuck[t]];

• Sorry for the delay! I had to meditate and try a little and I have to say it's perfect! One last thing! How can I force you to stop integration ONLY of x(t) when, for example, x(t) = 10? – TeM Aug 16 '17 at 18:47
• @TeM Just use this same technique and add another discrete variable (e.g. stop[t]) into your equations and add event setting speed to zero x'[t]->0. – swish Aug 16 '17 at 19:00
• @TeM As I said you need another variable and not the same stuck[t]. The block starts to move again, because the event of T > Fs triggers and unstucks it. – swish Aug 17 '17 at 21:22
• You need to change the action stop[t] -> 1; x'[t] -> 0 to sequential {stop[t] -> 1, x'[t] -> 0}. Because the rule syntax for action is a special case and works only if it's the last one, so only x'[t] -> 0 applies and not stop[t] -> 1 in your case. – swish Aug 17 '17 at 22:12
• My guess it's fine, because the ball just starts rotating around the axis as some momentum got transfered to it. – swish Aug 17 '17 at 23:55